My guess is using position methods is the way to go(*). I think there's
something about the way people come to Leo scripting that leads them down the
c.k.simulateCommand path, but I'm not really sure that's intentionally. My
feeling is that c.k.simulateCommand is best for occasional limited use, not for
the kind of thing you're doing. Complexity wise, the position methods are no
harder to use than c.k.simulateCommand, when your script gets to the level
yours has.
With the position methods there's typically no issue about unwanted display
updates, you just need to remember to call c.redraw() when you're done.
(*) one caveat for programmatically generated trees - for large trees it's
significantly faster to use vnodes instead of positions. There's very little
difference code wise, instead of
myNode = p.insertAfter()<< build big tree under myNode >>
it's basically
myNode = p.insertAfter().v<< build big tree under myNode >>
because most of the tree building methods positions have are available on
vnodes too (.h, .b, .insertAfter(), etc.)
Cheers -Terry
From: djc <[email protected]>
To: leo-editor <[email protected]>
Sent: Thursday, December 8, 2016 11:28 AM
Subject: Re: is there a command to turn off visual display of changes and then
turn them back on?
Sorry....not very well formatted question.
When I use the c.k.simulateCommand() method, it does an immediate redraw of the
outline. I would like to suppress the redraw until after I am done making
changes. I am looking at using position methods to do the same thing so that I
control the redraw, but haven't had time to suss it out yet.
Also, I have been doing some stress testing on large, programatically created
outlines to see if there are scale limits in Leo. I have found that Leo will
crash if I use c.k.simulateCommand() on a large number of nodes in one function.
I don't want to report this formally until I have a chance to dig into it more,
so this is just a heads up.
The specific code that I am working on is intended to build a journal with
weekly text files. This might be better served using a database, but I have
some specific requirements that make Leo and interesting potential
solution.....and it provides a great opportunity to learn the ins and outs of
the tool.
A code snip follows that illustrates what I am doing. This code does cause Leo
to hang, but not at consistent places in the operation, so I assuming that it
is a memory problem; perhaps stack space, or garbage collector overflow, or
some such.
monthNames = {"01-January","02-February","03-March","04-April","05-May",
"06-June","07-July","08-August","09-September","10-October","11-November","12-December"}
yr = 1960for np in c.all_positions():
if (c.p.h[:5] == 'Year:'): yr = int(c.p.h[-4:]) g.es(str(yr))
c.k.simulateCommand('goto-next-visible')
if (c.p.h[:5] == 'Year:'): c.k.simulateCommand('move-outline-right')
if (c.p.h in monthNames):
c.k.simulateCommand('move-outline-right')
c.k.simulateCommand('move-outline-right') elif (c.p.h[:1] == 'w'):
c.k.simulateCommand('move-outline-right')
c.k.simulateCommand('move-outline-right')
c.k.simulateCommand('move-outline-right')
On Wednesday, 7 December 2016 08:54:45 UTC-7, Edward K. Ream wrote:
On Wed, Dec 7, 2016 at 9:40 AM, djc <[email protected]> wrote:
Is there something like and echo_on and echo_off when using
c.k.simulateCommand()?
Not sure what you mean by "changes".
Edward
--
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.