'Cleaning' a Text Window

All except GUI problems
Post Reply
User avatar
Robert
Posts: 177
Joined: Sat Sep 28, 2013 11:04 am
Location: Edinburgh, Scotland

'Cleaning' a Text Window

Post 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?
User avatar
Robert
Posts: 177
Joined: Sat Sep 28, 2013 11:04 am
Location: Edinburgh, Scotland

Re: 'Cleaning' a Text Window

Post 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);
luowy
Posts: 87
Joined: Thu Dec 17, 2015 1:32 pm

Re: 'Cleaning' a Text Window

Post by luowy »

you can use Models.BeginModification, EndModification to achieve it.
User avatar
Robert
Posts: 177
Joined: Sat Sep 28, 2013 11:04 am
Location: Edinburgh, Scotland

Re: 'Cleaning' a Text Window

Post by Robert »

luowy wrote:you can use Models.BeginModification, EndModification to achieve it.
Thanks, that does what I want.
Post Reply