Once again, ask and ye shall receive.
Saving and restoring sessions sounded like a worthy, but
challenging coding project, but for Leo, it's a yawner.
the following two functions look like they'll be all I need,
I'm sure they can be improved.
Software sometimes feels manual, is visible.
Sometimes magical and invisible.
Leo scripting strikes me as visible magic.
def get_session():
"""Return a list of UNLs for open tabs.
"""
tabs = g.app.windowList
UNLs = []
for tab in tabs:
current = tab.c.currentPosition()
UNLs.append(current.get_UNL())
return UNLs
def restore_session(c, UNLs):
"""Open a tab for each item in UNLs.
"""
for unl in UNLs:
fname, unl = UNL.split("#")
ok, frame = g.openWithFileName(fname, c)
if ok:
this_c = frame.c
for pos in this_c.all_positions():
if pos.get_UNL() == unl:
this_c.setCurrentPosition(pos)
this_c.redraw()
break
--
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/leo-editor?hl=en.