Leo (text editor)


Leo is an open-source text editor/outliner that features clones as its central tool of organization, navigation, customization and scripting.

Languages

Leo can manipulate text or code in any human or computer programming language, as Leo is a language-independent or "adaptable LPE". Syntax highlighting is provided for many different programming languages. Leo is written in Python and can be extended with plugins written in Python. The GUI uses the Qt toolkit; the syntax-aware editor is based on Scintilla. Leo outlines are stored as XML files.

Trees, clones and views

Leo's foremost functionality, in addition to text editing, is that of an outliner, with a "vast range of convenience features for structuring and managing outlines" both by drag-and-drop via GUI and by keyboard commands. Leo's outline pane shows a tree of data nodes. Nodes contain headlines, body text, and other information. Headlines naturally serve as descriptions of the body text. For example, @file nodes are nodes whose headline starts with @file. Leo trees are in fact directed acyclic graphs; nodes may have more than one parent. Leo calls such nodes clones. Clones appear in several places in the outline pane. Views are simply nodes whose children contain clones. A single outline may contain arbitrarily many views of the nodes contained therein.

External files

@file nodes represent external files, files on the computer's file system other than the outline file. When saving an outline Leo automatically writes all changed @file trees back to the external files. Comments, called sentinel lines, in external files represent the outline structure. When Leo reads an outline, these comments allow Leo to recreate @file trees using only the data in the external file. @auto nodes represent external files without using sentinel comments. When reading @auto nodes, Leo uses the program structure of the external file to create the @auto tree.

Scripting

Leo's outline or hierarchical structure is distinct from the web of interleaved program and documentation "chunks" associated with classic literate programming tools. The body text of any Leo node may contain a Leo script, a Python script executed in the context of a Leo outline. A simple API gives Leo scripts full access to all data in loaded outlines, as well as full access to Leo's own source code. The API includes Python iterators that allow scripts to traverse outlines easily. Scripts may be composed of any tree of nodes. A markup language similar to noweb tells Leo how to create scripts from an outline. Headlines control and guide scripts. Examples are: