Page 1 of 1

'Cleaning' a Text Window

Posted: Mon Nov 19, 2018 3:39 pm
by Robert
I wish to open a Text Window, write into it, and then have it marked 'Clean' as if I had just read it from file.

I use the code fragments:

Code: Select all

IMPORT  Sequencers, TextModels, TextViews

VAR seq: ANYPTR; text : TextModels.Model; view : TextViews.View;

  text := ...; (* sets up my Text *)
  view  :=  TextViews.dir.New (text);
  Views.OpenView (view);
  ... Write to text ...
  seq  :=  text ().Domain ().GetSequencer ();
  WITH  seq : Sequencers.Sequencer  DO  seq.SetDirty (FALSE)  END
This does indeed 'clean' the icon in the top left of the Window, but does not empty the Edit->Undo stack. How do I do that?

Re: 'Cleaning' a Text Window

Posted: Mon Nov 19, 2018 4:16 pm
by Robert
If I replace

Code: Select all

  Views.OpenView (view);
  ... Write to text ...
  seq  :=  text ().Domain ().GetSequencer ();
  WITH  seq : Sequencers.Sequencer  DO  seq.SetDirty (FALSE)  END
with the two "lines" below I get a satisfactory solution for my problem.

Code: Select all

  ... Write to text ...
  Views.OpenView (view);

Re: 'Cleaning' a Text Window

Posted: Tue Nov 20, 2018 8:24 am
by luowy
you can use Models.BeginModification, EndModification to achieve it.

Re: 'Cleaning' a Text Window

Posted: Thu Nov 22, 2018 4:57 pm
by Robert
luowy wrote:you can use Models.BeginModification, EndModification to achieve it.
Thanks, that does what I want.