body text changes from @command script lost when saved?

2012-11-16 Thread Curtis Carlsen

I have the following code in an @command node:


w = c.frame.body.bodyCtrl 
w.setFocus()
start,end = w.getSelectionRange()
w.insert(start, {)
w.insert(end+1, })
c.setChanged()
w.setFocus()
=

It brackets the current text selection with curly braces.

The code seems to work fine at first.  The braces appear in the body text.  
But when I do a save, the changes are reverted.  If I do an edit manually 
in the buffer before saving then the changes are retained.  It seems that 
the changes made by the script are not setting the text as changed.  Is 
this something to do with the undoer or something else?  I've checked in 
the docs and searched here, and found nothing relating.

-- 
You received this message because you are subscribed to the Google Groups 
leo-editor group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/leo-editor/-/88YaBrZtzx0J.
To post to this group, send email to leo-editor@googlegroups.com.
To unsubscribe from this group, send email to 
leo-editor+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en.



Re: body text changes from @command script lost when saved?

2012-11-16 Thread Edward K. Ream
On Fri, Nov 16, 2012 at 1:14 AM, Curtis Carlsen curtiscarl...@gmail.com wrote:

 I have the following code in an @command node:

[snip]

 The code seems to work fine at first...but when I do a save, the changes are 
 reverted.

Good question.

Your code changes the widget, but not the associated body text.
Adding the following as the last line works for me (tested code)::

p.b = w.getAllText()

Also note that the call to c.setChanged must be::

c.setChanged(True)

Edward

-- 
You received this message because you are subscribed to the Google Groups 
leo-editor group.
To post to this group, send email to leo-editor@googlegroups.com.
To unsubscribe from this group, send email to 
leo-editor+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en.