Yesterday's work was a huge step forward. It provides a solid platform for studying pyzo within Leo.
I'm glad I wrote up yesterday's work last night, because soon afterwards I got several big shocks:
1. The init code (in the pyzo plugin) is unsound when there are multiple Leo outlines!
Leo should create pyzo docks at the end of startup ("start2" time) rather than after loading an outline ("after-create-leo-frame" time).
2. Only a single, global, copy of each of Leo's docks should exist.
With the exception of Leo's Log pane, there is no reason at all to create per-outline docks.
This post discusses these surprises, and propose a new gui. All Leo users should be aware of the proposed changes. Feel free to ignore the details.
The pyzo plugin improperly inits pyzo
Alas, the code (in the plugin) that inits pyzo code is unsound when there are multiple outlines. The plugin re-initializes vars like pyzo.main, pyzo.editors, pyzo.shells, etc.
for each new outline! This has no chance of working. Pyzo assumes that only one copy of these vars exists.
All docks should be singletons, shared between outlines
This was the initial surprise. With the pyzo_in_leo plugin enabled, creating a new outline creates an all-new set of docks! This would be extremely annoying for the user, who would then have to reposition or hide all the newly-created docks.
Yes, Leo's "new" command could hide all (pyzo) docks, but would be a hack. As I considered alternatives, I suddenly saw that pyzo only uses one copy of each of its docks. I then saw that the pyzo_in_leo plugin's init code is unsound, as describe above.
Finally, I saw that it's silly to create separate Leo panes/docks for each new outline. The only exception is the Log pane. There are (minor) advantages to having a separate log pane/dock for each outline.
The proposed gui
- There will be a single Outlines dock, similar to Pyzo's Editors dock, containing one tab for each Leo outline.
- There might be a single Bodies dock, containing one tab for each body editor.
- Leo's Log dock might be shared among all of Leo's outlines. An alternative would be to switch the contents of the Log dock when switching outlines. We shall see...
Implications
The visual changes are minor. Most users will hardly notice them.
Few users presently configure docks differently for different outlines. Most users will welcome having a single arrangement for all docks.
My biggest concern is that Leo's scripting api might change. Existing Leonine scripts must continue to work. The acid test will be Leo's console gui plugin.
Summary
Leo's gui must change to accommodate pyzo. Happily, this is worth doing on its own merits.
All docks (both Leo's and pyzo's) will be shared between outlines (and pyzo editors). Docks won't move when changing outlines. A single Outline dock will contain all Leo outlines, each in its own tab.
This project will be done in a new "gui" branch. There will be a long period of testing. Compatibility with existing scripts will be maintained as much as possible. This will be the next phase of the pyzo in Leo project.
Edward