'Cleaning' a Text Window

All except GUI problems

'Cleaning' a Text Window

Postby Robert » Mon Nov 19, 2018 3:39 pm

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: 112
Joined: Sat Sep 28, 2013 11:04 am
Location: Edinburgh, Scotland

Re: 'Cleaning' a Text Window

Postby Robert » Mon Nov 19, 2018 4:16 pm

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

Re: 'Cleaning' a Text Window

Postby luowy » Tue Nov 20, 2018 8:24 am

you can use Models.BeginModification, EndModification to achieve it.
luowy
 
Posts: 29
Joined: Thu Dec 17, 2015 1:32 pm

Re: 'Cleaning' a Text Window

Postby Robert » Thu Nov 22, 2018 4:57 pm

luowy wrote:you can use Models.BeginModification, EndModification to achieve it.

Thanks, that does what I want.
User avatar
Robert
 
Posts: 112
Joined: Sat Sep 28, 2013 11:04 am
Location: Edinburgh, Scotland


Return to BlackBox Framework

Who is online

Users browsing this forum: No registered users and 0 guests

cron