On Tue, 14 May 2013 12:43:59 -0700 (PDT)
SegundoBob <
bhos...@ieee.org> wrote:
> I have a Leo-Editor script that pops up a window to interact with the
> user and when the user is happy with his changes, my script closes the
> pop-up window and sets the headline of the currently selected node.
> Note that the user may change one or more nodes in this way and move
> around in the Leo-Editor file for quite some time before closing the
> Leo-Editor file. Unfortunately, when a script changes a headline, Leo-
> Editor does NOT set the file dirty flag. This is a serious problem
> for my script because the user could easily lose changes he has made.
If the issue is not becoming dirty for changes made to headlines *by
your script*, then I'd say this:
- the ' ' append trick shouldn't be needed, your script should
set the node and outline dirty explicitly with the relevant methods,
p.v.setDirty(), c.setChanged(True), etc. not sure exactly.
- there are use cases for scripts setting the dirty flags explicitly,
and use cases for scripts changing the outline without making it
dirty. You use case is the former, the latter is when you're
constructing views of data that don't need to be saved.
- at first glance your use case would seem more common and the views
use case less common, arguing for automatic dirtying in response to
scripted changes and the views use case needing to explicitly
undirty the outline
- *but* it's relatively simple to explicitly dirty the nodes /
outline, whereas explicitly undirtying them is tricky, because it
matters whether they were dirty or not before the script started
changing things, so I would argue that the status quo is cleanest
for the broadest range of cases. Scripts usually need to
explicitly call c.redraw() and other things too, so this
requirement isn't unique.
I'm guessing you hadn't seen the p.v.setDirty(), c.setChanged(True)
etc. methods?
Cheers -Terry