This will be wonderful quality of life improvements. If you can, without terrible effort or stress, "borrow" the best of Pyzo then I think Leo will benefit mightily.
As another data point it may be worth studying xo's syntax highlighting code <https://github.com/scopatz/xo>. xo is a minimal console based text editor written in Python that uses pygments for syntax highlighting. The author, Anthony Scopatz, is another skilled Python programmer who I put in same category as Almar Klein. On Tuesday, March 5, 2019 at 9:27:24 AM UTC-5, Edward K. Ream wrote: > > This post explores what Leo and pyzo <https://pyzo.org/>have to offer > each other. > > *tl;dr*: It will be much easier to use pyzo features and code in Leo than > adding Leonine features to pyzo. > > *Studying pyzo* > > Yesterday I created a personal study repository of pyzo here > <https://github.com/edreamleo/pyzo>. This allows me to track (back up) > localized changes to pyzo. The git commits are a record of my work. > > Not surprisingly, it is far easier to study pyzo code with Leo than with > pyzo. Also not surprisingly, it's far easier to understand what pyzo > offers by actually playing with it. > > *Embedding pyzo's features and code into Leo* > > Here is a partial list of pyzo features that should(!) be added to Leo. > > *Windowing*: pyzo allows any pane to be dragged to a new position. Each > pane has a label area which can be dragged anywhere else. pyzo remembers > the arrangement of panes on exit, and restores the arrangement when it > restarts. This is, I'm pretty sure, a feature of Qt, and it will likely be > fairly easy to implement. It's a more intuitive and general solution than > Leo's toggle-split-direction command, the new pane Easter Egg. Leo must > have this. It's the extensible window management that Leo has needed for a > long time. In pyzo, users create new panes using the tools menu. Again, > Leo should so something like this. > > *Qt Styles*: The pyzo View menu allows users to select a Qt Style. The > default style is "cleanlooks", which imo is way better than the native > styles. The style is indeed very clean and highlights the location of drag > areas. Leo should have this. > > *File Browser*: The pyzo file browser is excellent. It need not always > be visible (It will be a window option), but at the least it should be part > of a dialog when opening files. > > *IPython and kernels*: Pyzo has an interactive "Shells" window, and the > "Logger" window also supports IPython features. Both these windows are > superior to Leo's buggy python_console plugin. I intend to move the code > for both these into Leo. > > *Yoton*: Yoton <https://yoton.readthedocs.io/en/latest/>is a separate > project for interprocess communication, bundled with pyzo, and used by the > pyzo "Shells" and "Logger" windows. It should be part of Leo. > > *Syntax coloring*: Here is the heart of the pyzo syntax coloring code: > > tokens = list(parser.parseLine(line, previousState)) > for token in tokens : > # Handle block state > if isinstance(token, parsers.BlockState): > self.setCurrentBlockState(token.state) > else: > # Get format > try: > styleFormat = nameToFormat(token.name) > charFormat = styleFormat.textCharFormat > except KeyError: > continue > # Set format > self.setFormat(token.start,token.end-token.start,charFormat) > # Is this a cell? > if (fullLineFormat is None) and styleFormat._parts.get('underline' > ,'') == 'full': > fullLineFormat = styleFormat > > This is a spectacular simplification on Leo's own colorizing code, but it > requires a separate "tokenizing" of each line. There are two possible ways > to use this code: > > 1. Add a line tokenizer based on Leo's existing files in leo/modes. > 2. Use the code above as a template for pygments <http://pygments.org/>. > I'll explore this first. It might eliminate all of leo/modes! > > > *Embedding Leonine features in pyzo* > > Pyzo uses lines of the form "## name" to define *chunks*. Chunks continue > until the next class or method definition. Chunks are not replacements for > either @others or << sections >> both of which require an explicit end > point. I considered adding lines like ##<, ##>, ##<others and ##others>, > but such new sentinel lines would, naturally, clutter the external files. > > It is tantalizing to think that the pyzo way of breaking files into > classes and methods could somehow eliminate all forms of @<file> nodes in > Leo. I considered that possibility yesterday, for several hours. But the > result would not be Leo. Specifically, the result would lack the following > crucial capabilities: > > - Organizer nodes. @clean does this, without embedded sentinels. > - gnx's (unique, invariant data). > - uA's (arbitrary data). > - Clones, living in a separate outline, not an external file. > > *Summary* > > Leonine features could be added to pyzo only at great cost. Almar Klein > is unlikely to be interested. > > Pyzo's most important features *will* be added to Leo: > > - Leo's windows will be more intuitive, more flexible and better looking. > - Pyzo's file browser is the best I've seen. > - Pyzo's "Shells" and "Logger" window would be important additions. > - Pyzo's colorizing code suggests how Leo could support pygments. That > might eliminate the entire leo/modes directory! > - Yoton is an important tool, worth understanding and using in its own > right. > > This list shows the value of playful exploration. It's much easier than > deep study of code :-) > > 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.
