<?xml version="1.0" encoding="utf-8"?>
<!-- Created by Leo: http://leoeditor.com/leo_toc.html -->
<leo_file xmlns:leo="http://leoeditor.com/namespaces/leo-python-editor/1.1" >
<leo_header file_format="2"/>
<globals/>
<preferences/>
<find_panel_settings/>
<vnodes>
<v t="ekr.20131030071311.17125"><vh>Startup</vh>
<v t="ekr.20131030071311.18741"><vh>@button make-sphinx</vh></v>
<v t="ekr.20131030071311.17126"><vh>@settings</vh>
<v t="ekr.20181015143002.1"><vh>@bool body_pane_wraps = True</vh></v>
<v t="mhw.20181210130732.1"><vh>@bool put-expansion-bits-in-leo-files = False</vh></v>
<v t="ekr.20131030071311.18671"><vh>@string target_language = rest</vh></v>
<v t="ekr.20131030071311.17128"><vh>For rst3 command</vh>
<v t="ekr.20131030071311.17127"><vh>@bool rst3_call_docutils = True</vh></v>
<v t="ekr.20131030071311.17129"><vh>@bool rst3_write_intermediate_file = True</vh></v>
<v t="ekr.20131030071311.18669"><vh>@string rst3_write_intermediate_extension = .txt</vh></v>
</v>
</v>
</v>
<v t="ekr.20131019184243.16683"><vh>===== Leo's cheat sheet</vh></v>
<v t="ekr.20131019184243.16685"><vh>Key bindings</vh>
<v t="ekr.20131019184243.16686"><vh>Selecting outline nodes</vh></v>
<v t="ekr.20131019184243.16687"><vh>Moving outline nodes</vh></v>
<v t="ekr.20131019184243.16688"><vh>Moving the cursor</vh></v>
</v>
<v t="ekr.20160401160027.1"><vh>Executing minibuffer commands</vh></v>
<v t="ekr.20131019184243.16689"><vh>Frequently used commands</vh></v>
<v t="ekr.20131019184243.16690"><vh>Leo directives</vh></v>
<v t="ekr.20131019184243.16691"><vh>Settings</vh></v>
<v t="ekr.20131031101712.19298"><vh>Node types</vh></v>
<v t="ekr.20131019184243.16692"><vh>Notable Plugins</vh></v>
<v t="ekr.20131019184243.16693"><vh>External files (@&lt;file&gt; nodes)</vh>
<v t="ekr.20160410111255.1"><vh>Path expressions</vh></v>
<v t="ekr.20160410111226.1"><vh>Sections</vh></v>
</v>
<v t="ekr.20131019184243.16694"><vh>Scripting</vh>
<v t="ekr.20131019184243.16695"><vh>Pre-defined symbols</vh></v>
<v t="ekr.20170315015836.1"><vh>LeoApp class</vh></v>
<v t="ekr.20131019184243.16697"><vh>Commands class</vh></v>
<v t="ekr.20190101084845.1"><vh>Undoing commands</vh>
<v t="ekr.20190101092126.1"><vh>Undoably changing body text</vh></v>
<v t="ekr.20190101092129.1"><vh>Undoably changing multiple nodes</vh></v>
</v>
<v t="ekr.20131019184243.16698"><vh>VNode class</vh></v>
<v t="ekr.20131019184243.16699"><vh>Position class</vh></v>
<v t="ekr.20131019184243.16700"><vh>The leoGlobals module</vh></v>
<v t="ekr.20170311121717.1"><vh>Test driven development</vh></v>
<v t="ekr.20170403190104.1"><vh>Performance gotchas</vh></v>
<v t="ekr.20180503073939.1"><vh>Prompting for command arguments</vh>
<v t="ekr.20180503073954.1"><vh>Example 1: Prompt for one arg</vh></v>
<v t="ekr.20180503074530.1"><vh>Example 2: Prompt for 2 args</vh></v>
<v t="ekr.20180503132659.1"><vh>Example 3: Prompt for 3 args</vh></v>
</v>
<v t="ekr.20181015142534.3"><vh>Naming conventions in Leo's core</vh>
<v t="ekr.20181015142534.4"><vh>Official ivars</vh></v>
</v>
<v t="ekr.20181015142534.2"><vh>Widgets and wrappers</vh></v>
</v>
<v t="ekr.20170311122518.1"><vh>Command line options</vh></v>
<v t="ekr.20180405105738.1"><vh>Learning to be a Leo developer</vh>
<v t="ekr.20160315141648.1"><vh>Code academy</vh>
<v t="ekr.20160315141648.3"><vh>CA: uA's</vh></v>
<v t="ekr.20160315141648.4"><vh>CA: icons</vh></v>
<v t="ekr.20160315141648.5"><vh>CA: using git</vh></v>
<v t="ekr.20160315141648.6"><vh>CA: finding nodes with c.cloneFindByPredicate</vh></v>
</v>
<v t="ekr.20180405093138.1"><vh>Leo University</vh></v>
<v t="ekr.20181015142534.1"><vh>Architecture</vh></v>
</v>
<v t="ekr.20131030071311.18723"><vh>The rst3 tutorial</vh>
<v t="ekr.20131030071311.18732"><vh>@rst ~/myDocument.html</vh>
<v t="ekr.20131030071311.18733"><vh>Chapter I</vh>
<v t="ekr.20131030071311.18734"><vh>@rst-ignore</vh></v>
</v>
<v t="ekr.20131030071311.18735"><vh>@rst-ignore-tree Chapter 2+</vh>
<v t="ekr.20131030071311.18736"><vh>Chapter II</vh>
<v t="ekr.20131030071311.18737"><vh>translation</vh></v>
</v>
</v>
<v t="ekr.20131030071311.18738"><vh>Chapter XII</vh></v>
<v t="ekr.20131030071311.18739"><vh>@rst-no-head The End</vh></v>
</v>
<v t="ekr.20131102044158.16563"><vh>~/myDocument.html.txt</vh></v>
</v>
<v t="ekr.20180405093127.1"><vh>Rendering examples</vh>
<v t="ekr.20180405093127.9"><vh>@html display Leo tree using css</vh></v>
<v t="ekr.20180405093127.11"><vh>@image LeoSplash</vh></v>
<v t="ekr.20180405093127.12"><vh>@image splash screen</vh></v>
<v t="ekr.20180405093127.22"><vh>@svg bubbles from sources</vh></v>
<v t="ekr.20180405093127.23"><vh>@svg bubbles.svg from a link</vh></v>
<v t="ekr.20180405093127.31"><vh>Markdown example</vh></v>
<v t="ekr.20180405105451.1"><vh>pyplot examples</vh>
<v t="ekr.20180405093127.14"><vh>@pyplot barchar_demo</vh></v>
<v t="ekr.20180405093127.15"><vh>@pyplot basic_example</vh>
<v t="ekr.20180405093127.16"><vh>Figure 1</vh></v>
<v t="ekr.20180405093127.17"><vh>Figure 2</vh></v>
</v>
<v t="ekr.20180405093127.18"><vh>@pyplot matplotlib animate_decay</vh>
<v t="ekr.20180405093127.19"><vh>data_gen</vh></v>
<v t="ekr.20180405093127.20"><vh>init</vh></v>
<v t="ekr.20180405093127.21"><vh>run</vh></v>
</v>
</v>
<v t="ekr.20180405093127.30"><vh>reStructuredText docstring example</vh></v>
<v t="ekr.20180405093127.32"><vh>reStructureText text example</vh></v>
</v>
</vnodes>
<tnodes>
<t tx="ekr.20131019184243.16683">This Cheat Sheet contains a summary of many of Leo's important features.</t>
<t tx="ekr.20131019184243.16685">Here is a summary of Leo's key bindings.</t>
<t tx="ekr.20131019184243.16686">When focus is in the outline pane::

    Right-arrow (expand-and-go-right)
    Left-arrow (contract-or-go-left)
    Up-arrow (goto-prev-visible) 
    Down-arrow (goto-next-visible)
    
Regardless of focus::

    Alt-Home (goto-first-visible-node) 
    Alt-End (goto-last-visible-node)
    Alt-Right-arrow (expand-and-go-right)
    Alt-Left-arrow (contract-or-go-left)
    Alt-Up-arrow (goto-prev-visible) 
    Alt-Down-arrow (goto-next-visible)
</t>
<t tx="ekr.20131019184243.16687">When focus is in the outline::

    Shift-Down-arrow (move-outline-down) 
    Shift-Left-arrow (move-outline-left) 
    Shift-Right-arrow (move-outline-right) 
    Shift-Up-arrow (move-outline-up)

Regardless of focus::

    Alt-Shift-Down-arrow (move-outline-down) 
    Alt-Shift-Left-arrow (move-outline-left) 
    Alt-Shift-Right-arrow (move-outline-right) 
    Alt-Shift-Up-arrow (move-outline-up)
    Ctrl-D (move-outline-down)
    Ctrl-L (move-outline-left) 
    Ctrl-R (move-outline-right)
    Ctrl-U (move-outline-up)
</t>
<t tx="ekr.20131019184243.16688">When focus is in any of Leo's text panes (body pane, log pane, headlines):

    +-------------------+-----------------------+
    | **Key**           | **Move Cursor**       |
    +-------------------+-----------------------+
    | Arrow keys        | one character         |
    +-------------------+-----------------------+
    | Ctrl-LeftArrow    | back one word         |
    +-------------------+-----------------------+
    | Ctrl-RightArrow   | forward one word      |
    +-------------------+-----------------------+
    | Home              | beginning of line     |
    +-------------------+-----------------------+
    | End               | end of line           |
    +-------------------+-----------------------+
    | Ctrl-Home         | beginning of the body |
    +-------------------+-----------------------+
    | Ctrl-End          | end of body           |
    +-------------------+-----------------------+
    | PageDown          | down one page         |
    +-------------------+-----------------------+
    | PageUp            | up one page           |
    +-------------------+-----------------------+
    
Adding the Shift key modifier to any of the keys above
moves the cursor and extends the selected text.
</t>
<t tx="ekr.20131019184243.16689">For much more information, see Leo's Commands Reference: http://leoeditor.com/commands.html

Copy/Paste (text)::

    Ctrl-C (copy-text)
    Ctrl-K (kill)
    Ctrl-V (paste-text)
    Ctrl-X (cut-text)
    Ctrl-Y (yank)
    Alt-Y  (yank-pop)
    kill-...

Files::

    Ctrl-N (new) 
    Ctrl-O (open-outline)
    Ctrl-S (save-file) 
    Ctrl-Q (exit-leo)

Focus::

    Alt-T (focus-to-tree) 
    Ctrl-T (toggle-active-pane)
    Ctrl-Tab (tab-cycle-next)
    
Help::

    Alt-0 (vr-toggle)
    F1 (help) 
    F11 (help-for-command) 
    F12 (help-for-python)
    print-bindings
    print-settings
    help-for-...

Find/Replace::

    Ctrl-F (search-with-present-options) 
    Shift-Ctrl-R (replace-string)
    Ctrl-minus (replace-then-find) 
    F3 (find-next) 
    F2 (find-previous)
    
Minibuffer::

    Alt-X (full-command)
    Ctrl-G (keyboard-quit)

Nodes::

    Ctrl-I or Insert (insert-node)
    Ctrl-H (edit-headline)
    &lt;Return&gt; (when editing a headline) (end-edit-headline)
    Ctrl-Shift-C (copy-node)
    Ctrl-Shift-X (cut-node) 
    Ctrl-Shift-V (paste-node) 
    Ctrl-{ (promote)
    Ctrl-} (demote)
    Ctrl-M (mark) 

Undo::

    Ctrl-Z (undo)
    Ctrl-Shift-Z (redo)
</t>
<t tx="ekr.20131019184243.16690">Directives starting with '@ in the leftmost column
    
For full details, see Leo's Directives reference: http://leoeditor.com/directives.html

    @                       # starts doc part
    @c                      # ends doc part
    @color
    @doc                    # starts doc part
    @killcolor
    @nocolor
    @language python
    @language c
    @language rest          # restructured text
    @language plain         # plain text: no syntax coloring.
    @lineending lineending
    @pagewidth 100
    @raw, @end_raw          # @file only.
    @tabwidth -4            # use spaces
    @tabwidth 8             # use tabs
    @nowrap
    @wrap
    
Leading whitespace is allowed (and significant) for::

    @all
    @others
    </t>
<t tx="ekr.20131019184243.16691">For documentation see node: "About this file" in leoSettings.leo.

- Key bindings:     @shortcuts
- Visual settings:  @data qt-gui-plugin-style-sheet
- Enabling plugins: @enabled-plugins

To disable a binding for a key, bind it to do-nothing::

    do-nothing = Insert
    
This overrides the following default binding in leoSettings.leo::

    insert-node = Insert
</t>
<t tx="ekr.20131019184243.16692">See the docstring of these plugins for more details:

- bookmarks.py: Manages URL's used as bookmarks.
- contextmenu.py: Brings up context menu when user right-clicks a headline.
- mod_scripting.py: Supports @button and @command nodes.
- quicksearch.py: Adds Nav tab for searching.
- todo.py: Manages to-do lists and simple project management.
- valuespace.py: Creates an outline-oriented spreadsheet.
- viewrendered.py: Creates a rendering pane. Automatically loaded by Leo's help commands.
</t>
<t tx="ekr.20131019184243.16693">@&lt;file&gt; nodes create external files:

    @asis &lt;filename&gt;        write only, no sentinels, exact line endings
    @auto &lt;filename&gt;        recommended
    @clean &lt;filename&gt;       recommended
    @edit &lt;filename&gt;        @edit node contains entire file
    @file &lt;filename&gt;        recommended
    @nosent &lt;filename&gt;      write only, no sentinels

This table summarizes the differences between @&lt;file&gt; nodes:

                             Sections &amp;   File data in
    @&lt;file&gt; kind  Sentinels?  @others?    .leo file?    Notes             
    ------------  ---------- -----------  ------------  -----
    @asis            no         no           yes
    @auto            no         yes          no         1, 2
    @auto-xx         no         yes          no         1, 2
    @clean           no         yes          yes     
    @edit            no         no           no    
    @file            yes        yes          no
    @nosent          no         yes          yes
    
**Note 1**: @auto nodes read files using language-specific importers.
By default, the file's extension determines the importer:

    Extensions                  Importer
    ----------                  --------
    .c, .cc, .c++, .cpp,.cxx    C
    .cs', .c#'                  C Sharp
    .el                         Elisp
    .h, .h++                    C
    .html, .htm                 HTML
    .ini                        Config file
    .ipynb                      Jupyter notebook
    .java                       Java
    .js                         JavaScript
    .md                         Markdown
    .org                        Org Mode
    .otl                        Vim outline
    .pas                        Pascal
    .php                        PHP
    .py, .pyi, .pyw             Python
    .rest, .rst                 reStructuredText
    .ts                         TypeScript
    .xml                        XML
    
**Note 2**: You can also specify importers *explicitly* as follows:

    @auto-xxx           Importer
    ---------           --------
    @auto-ctext         ctext
    @auto-markdown      markdown
    @auto-md            markdown
    @auto-org           org-mode
    @auto-org-mode      org-mode
    @auto-otl           vimoutline
    @auto-vim-outline   vimoutline
    @auto-rst           reStructuredText
    
For full details, see Leo's Directives reference:
http://leoeditor.com/directives.html
    </t>
<t tx="ekr.20131019184243.16694">This section lists the ivars, properties, functions and methods most
commonly used in Leo scripts.

**Very important**: use Alt-1 (toggle-autocompleter) and Alt-2
(toggle-calltips) to recreate these lists as you type.

As an alternative to this chapter, Jacob Peck has written a more informal scripting tutorial:
http://blog.suspended-chord.info/2014/01/28/intro-to-leo-scripting/</t>
<t tx="ekr.20131019184243.16695">execute-script predefines::

    c: The commander of the present outline.
    g: The leo.core.leoGlobals module.
    p: The presently selected position, c.p.
    
@test scripts predefine all the above, plus::

    self: The instance of unittest.TestCase
</t>
<t tx="ekr.20131019184243.16697">Ivars:

    c.config                c's configuration object
    c.frame                 c's outer frame, a leoFrame instance.
    c.undoer                c's undo handler.
    c.user_dict             A temporary dict for use of scripts and plugins.
    
SubCommanders:

    # in leo/core...
    c.atFileCommands
    c.chapterController
    c.fileCommands
    c.findCommands
    c.importCommands
    c.keyHandler = c.k
    c.persistenceController
    c.printingController
    c.rstCommands
    c.shadowController
    c.tangleCommands
    c.testManager
    c.vimCommands

    # In leo/commands...
    c.abbrevCommands
    c.controlCommands
    c.convertCommands
    c.debugCommands
    c.editCommands
    c.editFileCommands
    c.gotoCommands
    c.helpCommands
    c.keyHandlerCommands
    c.killBufferCommands
    c.rectangleCommands
    c.spellCommands
    
For example, c.k is an instance of the LeoKeys class in leo/core/leoKeys.py.
    
Generators:

    c.all_positions()
    c.all_unique_positions()
    
New in Leo 5.5: All generators yield distinct positions.
    
Most useful methods:

    c.isChanged()
    c.deletePositionsInList(aList, callback=None)
                            # safely deletes all the positions in aList.
    c.positionExists(p)
    c.redraw(p=None)        # Redraw the screen. Select p if given.
    c.redraw_later()        # Ensure that Leo redraws the outline.
    c.save()                # Save the present outline.
    c.selectPosition()      # Select the position, without redrawing the screen.
    
Suppressing screen flash when redrawing the outline:

    try:
        c.disable_redraw()
        &lt;&lt; Code that might otherwise update the outline &gt;&gt;
    finally:
        c.enable_redraw()
        c.redraw()
    
**Official ivars** of any leoFrame f:

    f.c                     is the frame’s commander.
    f.body                  is a leoBody instance.
    f.body.bodyCtl          is a leoQTextEditWidget instance.
    f.body.bodyCtrl.widget  is a LeoQTextBrowser(QTextBrowser) instance.
    f.log                   is a leoLog instance.
    f.tree                  is a leoQtTree instance.
    f.tree.treeWidget       is a LeoQTreeWidget (a QTreeWidget) instance.
    
Use autocompletion to explore these objects!
</t>
<t tx="ekr.20131019184243.16698">**Properties**:

    v.b:    v's body text.
    v.gnx:  v's gnx.
    v.h:    v's headline text.
    v.u:    v.unknownAttributes, a persistent Python dictionary.
    
v.u (uA's or unknownAttributes or userAttributes) allow plugins or scripts
to associate persistent data with vnodes. For details see:
http://leoeditor.com/customizing.html#adding-extensible-attributes-to-nodes-and-leo-files

*Important*: Generally speaking, vnode properties are fast, while the
corresponding position properties are much slower. Nevertheless, scripts
should usually use *position* properties rather than *vnode* properties
because the position properties handle recoloring and other details.
Scripts should use *vnode* properties only when making batch changes to
vnodes.
</t>
<t tx="ekr.20131019184243.16699">**Properties**:

    p.b: same as p.v.b. *Warning*: p.b = s is expensive.
    p.h: same as p.v.h. *Warning*: p.h = s is expensive.
    p.u: same as p.v.u.
    
**Generators**:

    p.children()
    p.parents()
    p.self_and_parents()
    p.self_and_siblings()
    p.following_siblings()
    p.subtree()
    p.self_and_subtree()
    
New in Leo 5.5: All generators yield distinct positions.

**Getters**:

    p.back()
    p.children()
    p.firstChild()
    p.hasBack()
    p.hasChildren()
    p.hasNext()
    p.hasParent()
    p.hasThreadBack()
    p.hasThreadNext()
    p.isAncestorOf(p2)
    p.isAnyAtFileNode()
    p.isAt...Node()
    p.isCloned()
    p.isDirty()
    p.isExpanded()
    p.isMarked()
    p.isRoot()
    p.isVisible()
    p.lastChild()
    p.level()
    p.next()
    p.nodeAfterTree()
    p.nthChild()
    p.numberOfChildren()
    p.parent()
    p.parents()
    p.threadBack()
    p.threadNext()
    p.visBack()
    p.visNext()
    
**Setters**:

    p.setDirty() *Warning*: p.setDirty() is expensive.
    p.setMarked()

**Operations on nodes**:

    p.clone()
    p.contract()
    p.doDelete(new_position)
    p.expand()
    p.insertAfter()
    p.insertAsNthChild(n)
    p.insertBefore()
    p.moveAfter(p2)
    p.moveToNthChildOf(parent,n)
    p.moveToRoot()
        
**Moving positions**:

The following move positions *themselves*: they change the node to which a
position refers. They do *not* change outline structure in any way! Use
these when generators are not flexible enough::

    p.moveAfter(p2)
    p.moveToBack()
    p.moveToFirstChild()
    p.moveToFirstChildOf(p2)
    p.moveToLastChild()
    p.moveToLastChildOf(p2)
    p.moveToLastNode()
    p.moveToNext()
    p.moveToNodeAfterTree(p2)
    p.moveToNthChild()
    p.moveToNthChildOf(p2)
    p.moveToParent()
    p.moveToRoot()
    p.moveToThreadBack()
    p.moveToThreadNext()
    p.moveToVisBack(c)
    p.moveToVisNext(c)
</t>
<t tx="ekr.20131019184243.16700">For full details, see @file leoGlobals.py in LeoPyRef.leo.

**g vars**:

    g.app
    g.app.gui
    g.app.windowlist
    g.unitTesting
    g.user_dict  # a temporary dict for use of scripts and plugins.
    
**g decorator**:

    @g.command(command-name)
    
**g functions** (the most interesting: there are many more in leoGlobals.py):
    
    g.angleBrackets()
    g.app.commanders()
    g.app.gui.guiName()
    g.es(*args,**keys)
    g.es_print(*args,**keys)
    g.es_exception()
    g.getScript(c,p,
        useSelectedText=True,
        forcePythonSentinels=True,
        useSentinels=True)
    g.openWithFileName(fileName,old_c=None,gui=None)
    g.os_path_... # Wrappers for os.path methods.
    g.pdb(message='')
    g.toEncodedString(s,encoding='utf-8',reportErrors=False)
    g.toUnicode(s, encoding='utf-8',reportErrors=False)
    g.trace(*args,**keys)
    g.warning(*args,**keys)
</t>
<t tx="ekr.20131030071311.17125">By convention, a Startup node contains settings, scripts, etc.
that mostly one wants to have hidden.
</t>
<t tx="ekr.20131030071311.17126">**Important**: to take effect, all settings must be descendants of this
@settings node.

**Note**: This file colors text as reStructuredText by default because of
the setting::

    @string target_language = rest
</t>
<t tx="ekr.20131030071311.17127"># Use False when using Sphinx</t>
<t tx="ekr.20131030071311.17128"></t>
<t tx="ekr.20131030071311.17129"></t>
<t tx="ekr.20131030071311.18669"></t>
<t tx="ekr.20131030071311.18671">The default language if no @language or @comment is in effect.

Valid values are (case is ignored):

actionscript,c,csharp,css,cweb,elisp,html,java,latex,
pascal,perl,perlpod,php,plain,plsql,python,rapidq,rebol,shell,tcltk.</t>
<t tx="ekr.20131030071311.18723">Here is an expanded version of the example from
http://leoeditor.com/tutorial-rst3.html

Control-click the URL above to open the page in your browser.

Notes:

1. The Startup node in this file contains the settings for the rst3
   command. If you use sphinx, **set @bool rst3_call_docutils = False**.
   
2. Leo will not create ~/myDocument.html automatically. Only the rst3
   command does that.
   
3. Executing the make-sphinx command will do everything needed to make
   myDocument.html. The @button make-sphinx node (a child of the Startup
   node) creates the make-sphinx command.
   
4. The node myDocument.html.txt is the intermediate file produced by the
   rst3 command.
</t>
<t tx="ekr.20131030071311.18732">#############
War and Peace
#############

        by Leo Tolstoy/Tolstoi
        
        BOOK ONE: 1805
</t>
<t tx="ekr.20131030071311.18733">"Well, Prince, so Genoa and Lucca are now just family estates of the
Buonapartes. But I warn you, if you don't tell me that this means war, if
you still try to defend the infamies and horrors perpetrated by that
Antichrist--I really believe he is Antichrist--I will have nothing more to
do with you and you are no longer my friend, no longer my 'faithful slave',
as you call yourself! But how do you do? I see I have frightened you--sit
down and tell me all the news."

It was in July, 1805, and the speaker was the well-known Anna Pavlovna
Scherer, maid of honor and favorite of the Empress Marya Fedorovna. With
these words she greeted Prince Vasili Kuragin, a man of high rank and
importance, who was the first to arrive at her reception. Anna Pavlovna had
had a cough for some days. She was, as she said, suffering from la grippe;
grippe being then a new word in St. Petersburg, used only by the elite.

...stuff happens...</t>
<t tx="ekr.20131030071311.18734">You can make whatever notes 
to yourself you like here, 
as these lines won't appear 
in the output files. :)

</t>
<t tx="ekr.20131030071311.18735">Neither this node nor any descendant node will appear in the output file.</t>
<t tx="ekr.20131030071311.18736">TL;DR

...la femme la plus seduisante de Petersbourg,* ...</t>
<t tx="ekr.20131030071311.18737">*The most fascinating woman in Petersburg.</t>
<t tx="ekr.20131030071311.18738">From the time the law of Copernicus was discovered and proved, the mere
recognition of the fact that it was not the sun but the earth that moves
sufficed to destroy the whole cosmography of the ancients.

...
</t>
<t tx="ekr.20131030071311.18739">..  and now we skip to the end of last chapter, while demonstrating use of an
..  organizer node (a node whose name does not appear in the output document),
..  and that rst comments appear as html comments (try 'View Source' on
..  output.html)

In the first case it was necessary to renounce the consciousness of an
unreal immobility in space and to recognize a motion we did not feel; in
the present case it is similarly necessary to renounce a freedom that does
not exist, and to recognize a dependence of which we are not conscious.
   
--- The End ---
</t>
<t tx="ekr.20131030071311.18741">@language python
import os
trace = True
g.cls()
c.setComplexCommand('make-sphinx')
c.save()
aList = c.rstCommands.rst3()
if aList:
    path = g.os_path_finalize_join(g.app.loadDir,'..','doc','html')
    os.chdir(path)
    if len(aList) &gt; 1: g.execute_shell_commands('make clean',trace=trace)
    g.execute_shell_commands('make html',trace=trace)
    fn = aList[0].h.strip() if len(aList) == 1 else 'leo_toc.html'
    fn = g.os_path_finalize_join(path,'_build','html',g.os_path_basename(fn))
    if g.os_path_exists(fn):
        # Don't wait for this command to exit!
        g.execute_shell_commands(['&amp;%s' % (fn)],trace=trace)
</t>
<t tx="ekr.20131031101712.19298">Supported by Leo's core:

- @chapters, @chapter
- @rst, @rst-no-head, @rst-ignore, @rst-ignore-tree
- @settings
- @test, @testsetup, @testclass
- @url

Within @settings trees:

- @bool, @color, @directory, @encoding, @int
- @float, @font, @ratio, @path, @string
- @enabled-plugins
- @buttons, @commands
- @menus, @menu, @menuat, @item
- @openwith, @shortcuts

Supported by plugins:

- bookmarks.py: @bookmarks, @bookmark
- at_folder.py: @folder
- at_produce.py: @produce
- at_view.py: @clip, @strip, @view
- expfolder.py: @expfolder
- mod_scripting.py: @button, @command, @script
- viewrendered.py: @graphics-script, @image, @html, @md, @movie and @svg
- rss.py: @feed

</t>
<t tx="ekr.20131102044158.16563">.. rst3: filename: ~/myDocument.html

#############
War and Peace
#############

        by Leo Tolstoy/Tolstoi
        
        BOOK ONE: 1805

Chapter I
+++++++++

"Well, Prince, so Genoa and Lucca are now just family estates of the
Buonapartes. But I warn you, if you don't tell me that this means war,
if you still try to defend the infamies and horrors perpetrated by
that Antichrist--I really believe he is Antichrist--I will have
nothing more to do with you and you are no longer my friend, no longer
my 'faithful slave,' as you call yourself! But how do you do? I see
I have frightened you--sit down and tell me all the news."

...stuff happens...

Chapter XII
+++++++++++

From the time the law of Copernicus was discovered and proved, the
mere recognition of the fact that it was not the sun but the earth
that moves sufficed to destroy the whole cosmography of the
ancients.

...

.. and now we skip to the end of last chapter, while demonstrating use of an
    organizer node (a node whose name does not appear in the output document),
    and that rst comments appear as html comments (try 'View Source' on
    output.html)

In the first case it was necessary to renounce the consciousness
of an unreal immobility in space and to recognize a motion we did
not feel; in the present case it is similarly necessary to renounce
a freedom that does not exist, and to recognize a dependence of
which we are not conscious.
   
--- The End ---

</t>
<t tx="ekr.20160315141648.1">Leo's Code Academy posts discuss how to do useful things in Leo. The following are distilled from online discussions about Leo's scripting.</t>
<t tx="ekr.20160315141648.3">uA's (user Attributes) associate arbitrary data with any vnode. uA's are dictionaries of dictionaries--an **outer dictionary** and zero or more **inner dictionaries**. The outer dictionary associates plugin names (or Leo's core) with inner dictionaries. The inner dictionaries carry the actual data.

The v.u or p.v properties get and set uA's. You can think of p.u as a synonym for p.v.unknownAttributes on both sides of an assignment. For example::

    plugin_name = 'test_plugin'
    d = p.u.get(plugin_name,{})
    d ['n'] = 8
    p.u [plugin_name] = d

p.u is the outer dictionary. p.u.get.(plugin_name, {}) is the inner dictionary. The last line is all that is needed to update the outer dictionary!

It is easy to search for particular uA's. The following script prints all the keys in the outer-level uA dictionaries:

    for p in c.all_unique_positions():
        if p.u:
            print(p.h, sorted(p.u.keys()))

This is a typical usage of Leo's generators.  Generators visit each position (or node) quickly. Even if you aren't going to program much, you should be aware of how easy it is to get and set the data in each node. In fact, now would be a great time to read Leo's Scripting Tutorial again :-) This will allow you to "dream bigger" with Leo.

The following script creates a list of all positions having an icon, that is, an outer uA dict with a 'icon' key.

    aList = [p.copy() for p in c.all_unique_positions() if 'icon' in p.u]
    print('\n'.join([p.h for p in aList]))

*Important*: If you don't understand these lines, please study Python's list comprehensions.  They are incredibly useful. '\n'.join(aList) is a great idiom to know.  str.join is one of python's most useful string methods. It converts between lists and strings.
</t>
<t tx="ekr.20160315141648.4">@language rest

This script inserts three icons in the current outline node. Running the script again will insert three more::

@language python

    table = (
        'edittrash.png',
        'connect_no.png',
        'error.png',
    )
    for icon in table:
        fn = g.os_path_finalize_join(g.app.loadDir,
            '..', 'Icons', 'Tango', '16x16', 'status', icon)
        if g.os_path_exists(fn):
            c.editCommands.insertIconFromFile(path=fn)
        
@language rest
        
This deletes all icons of the node at position p::

    c.editCommands.deleteNodeIcons(p=p)
</t>
<t tx="ekr.20160315141648.5">Using Leo’s latest sources from GitHub is highly recommended. Once git is installed, the following gets the latest Leo sources::

    git clone https://github.com/leo-editor/leo-editor.git

Thereafter, you can update Leo's sources with::

    git pull

Git is great in tracking history and reverting unwanted changes. And it has many other benefits.

Using git is very similar to using bzr or hg or any other SCCS.  To change Leo, you add files, you commit files, and you push files.  That's about it.
</t>
<t tx="ekr.20160315141648.6">@language rest

c.cloneFindByPredicate is a powerful new addition to Leo.  Here is its docstring:

    Traverse the tree given using the generator, cloning all positions for
    which predicate(p) is True. Undoably move all clones to a new node, created
    as the last top-level node. Returns the newly-created node. Arguments:

    generator,      The generator used to traverse the tree.
    predicate,      A function of one argument p returning true if p should be included.
    failMsg=None,   Message given if nothing found. Default is no message.
    flatten=False,  True: Move all node to be parents of the root node.
    iconPath=None,  Full path to icon to attach to all matches.
    redraw=True,    True: redraw the screen.
    undo_type=None, The undo/redo name shown in the Edit:Undo menu.
                    The default is 'clone-find-predicate'
                    
For example, clone-find-all-marked command is essentially:
    
@language python

    @cmd('clone-find-all-marked')
    def cloneFindMarked(self, flatten):
        
        def isMarked(p):
            return p.isMarked()
            
        self.cloneFindByPredicate(
            generator = self.all_unique_positions,
            predicate = isMarked,
            failMsg = 'nothing found',
            flatten = flatten,
            undoType = 'clone-find-marked',
        )
        
@language rest

The predicate could filter on an attribute or *combination* of attributes. For example, the predicate could return p has attributes A and B but *not* attribute C. This instantly gives Leo full database query capabilities. If we then hoist the resulting node we see *all and only* those nodes satisfying the query.

These following position methods make it easy to skip @ignore trees or @&lt;file&gt; trees containing @all::
        
    p.is_at_all()          True if p is an @&lt;file&gt; node containing an @all directive.
    p.in_at_all()          True if p is in an @&lt;file&gt; tree whose root contains @all.
    p.is_at_ignore()       True if p is an @ignore node
    p.in_at_ignore_tree()  True if p is in an @ignore tree.

For example, here is how to gather only those marked nodes that lie outside any @ignore tree::

@language python

    def isMarked(p):
        return p.isMarked() and not p.in_at_ignore_tree()
      
    c.cloneFindByPredicate(
        generator = self.all_unique_positions,
        predicate = isMarked,
        flatten = flatten,
        undoType = 'gather-marked',
    )
</t>
<t tx="ekr.20160401160027.1">Alt-X puts focus in the minibuffer. Ctrl-G escapes from the minibuffer.

Once there, you can use tab completion to reduce typing. For example, &lt;Alt-X&gt;open&lt;tab&gt; shows all commands that start with open.

Hit &lt;Enter&gt; to run a complete command.

Ctrl-P (repeat-complex-command) repeat the last command entered from the minibuffer.

Leo maintains a **command history list** of all minibuffer commands you have entered.

When focus is in the minibuffer, UpArrow shows the previous minibuffer command, and DnArrow show the commands before that.

The body text of an @data history-list *setting node* preloads commands into the command history list, ignoring lines starting with '#'. For example::

    run-pylint
    beautify-tree
    cff
    sort-lines
    # show-data
    check-clones
    expand-log-pane
    contract-log-pane</t>
<t tx="ekr.20160410111226.1">**Section names** have the form::

    &lt;&lt; any text, except double closing angle brackets &gt;&gt;
    
**Section-definition nodes** have headlines starting with a section name.

Leo performs **expansions** for all @&lt;file&gt; nodes except @asis.

Expansion of @all:

- Leo replaces @all by the *unexpanded* body text of *all* nodes.

Expansion of section names and @others:

- Leo replaces section names in body text by the *expanded*
  text of the corresponding section definition node.
  
- Leo replaces @others with the *expanded* text of all nodes
  that *aren't* section-definition nodes.
</t>
<t tx="ekr.20160410111255.1">Within @path and @&lt;file&gt; paths, Leo evaluates ``{{exp}}`` with the the following symbols defined: ``c``, ``g``, ``p``, ``os`` and ``sys``.  For example::

    @file {{os.path.abspath(os.curdir)}}/abc.py
    
refers to the file abc.py in (absolute path of) the current directory.
</t>
<t tx="ekr.20170311121717.1">- Use imp.reload to reload all changed modules.
- Make sure to *instantiate* any changed objects.
- See "Unit testing with Leo" for full details.
</t>
<t tx="ekr.20170311122518.1">@nowrap

Usage: launchLeo.py [options] file1, file2, ...

Options:
  -h, --help            show this help message and exit
  --debug               enable debug mode
  --diff                use Leo as an external git diff
  --fullscreen          start fullscreen
  --ipython             enable ipython support
  --fail-fast           stop unit tests after the first failure
  --gui=GUI             gui to use (qt/qttabs/console/null)
  --listen-to-log       start log_listener.py on startup
  --load-type=LOAD_TYPE
                        @&lt;file&gt; type for loading non-outlines from command
                        line
  --maximized           start maximized
  --minimized           start minimized
  --no-cache            disable reading of cached files
  --no-plugins          disable all plugins
  --no-splash           disable the splash screen
  --screen-shot=SCREENSHOT_FN
                        take a screen shot and then exit
  --script=SCRIPT       execute a script and then exit
  --script-window=SCRIPT_WINDOW
                        open a window for scripts
  --select=SELECT       headline or gnx of node to select
  --session-restore     restore previously saved session tabs at startup
  --session-save        save session tabs on exit
  --silent              disable all log messages
  --trace-binding=BINDING
                        trace key bindings
  --trace-focus         trace changes of focus
  --trace-plugins       trace imports of plugins
  --trace-setting=SETTING
                        trace where setting is set
  --trace-shutdown      trace shutdown logic
  -v, --version         print version number and exit
  --window-size=WINDOW_SIZE
                        initial window size (height x width)</t>
<t tx="ekr.20170315015836.1">Ivars:

    g.app                   A LeoApp instance.
    g.app.gui               A LeoGui instance. 
    g.app.pluginsController A LeoPluginsController instance.
    g.app.*                 Leo's global variables.
</t>
<t tx="ekr.20170403190104.1">**Warning**: The p.b and p.h setters and p.setDirty() are *very* expensive:

- p.b = s calls c.setBodyString(p, s) which will recolor body text and update the node's icon.
- p.h = s calls c.setHeadString(p, s) which calls p.setDirty().
- p.setDirty() changes the icons of all ancestor @file nodes.

In contrast, the corresponding p.v.b and p.v.b setters and p.v.setDirty() are extremely fast.

Usually, code *should* use the p.b and p.h setters and p.setDirty(), despite their cost, because they update Leo's outline pane properly. Calling c.redraw() is *not* enough.

These performance gotchas become important for repetitive commands, like cff, replace-all and recursive import. In such situations, code should use p.v.b and p.v.h setters instead of p.b and p.h setters.
</t>
<t tx="ekr.20180405093127.1">Here are some demos of Leo's rendering capabilities.

To see these examples:

1. enable Leo's viewrendered.py (VR) plugin.

2. Show the VR pane with Alt-0, vr-toggle.</t>
<t tx="ekr.20180405093127.11">../Icons/Leosplash.GIF

This is a comment</t>
<t tx="ekr.20180405093127.12">c:\leo.repo\leo-editor\leo\Icons\SplashScreen.ico

</t>
<t tx="ekr.20180405093127.14">#!/usr/bin/env python
# a bar plot with errorbars
import numpy as np
import matplotlib.pyplot as plt

N = 5
menMeans = (20, 35, 30, 35, 27)
menStd = (2, 3, 4, 1, 2)

ind = np.arange(N)  # the x locations for the groups
width = 0.35       # the width of the bars

fig, ax = plt.subplots()

rects1 = ax.bar(ind, menMeans, width, color='r', yerr=menStd)

womenMeans = (25, 32, 34, 20, 25)
womenStd = (3, 5, 2, 3, 3)
rects2 = ax.bar(ind + width, womenMeans, width, color='y', yerr=womenStd)

# add some text for labels, title and axes ticks
ax.set_ylabel('Scores')
ax.set_title('Scores by group and gender')
ax.set_xticks(ind + width)
ax.set_xticklabels(('G1', 'G2', 'G3', 'G4', 'G5'))

ax.legend((rects1[0], rects2[0]), ('Men', 'Women'))


def autolabel(rects):
    # attach some text labels
    for rect in rects:
        height = rect.get_height()
        ax.text(rect.get_x() + rect.get_width()/2., 1.05*height,
                '%d' % int(height),
                ha='center', va='bottom')

autolabel(rects1)
autolabel(rects2)

plt.ion()
    # sets interactive mode. Prevents this message:
    # QCoreApplication::exec: The event loop is already running
plt.show()</t>
<t tx="ekr.20180405093127.15"># http://matplotlib.org/1.5.1/examples/animation/basic_example.html
if 0:
    import numpy as np
    import matplotlib.pyplot as plt
    import matplotlib.animation as animation

@others

if 0:
    plt.ion()
    # sets interactive mode. Prevents this message:
    # QCoreApplication::exec: The event loop is already running
plt.show()</t>
<t tx="ekr.20180405093127.16">if 1:
    
    def update_line(num, data, line):
        line.set_data(data[..., :num])
        return line, # a tuple.

    fig1 = plt.figure()
    data = np.random.rand(2, 25)
    l, = plt.plot([], [], 'r-')
    plt.xlim(0, 1)
    plt.ylim(0, 1)
    plt.xlabel('x')
    plt.title('test')
    line_ani = animation.FuncAnimation(fig1, update_line, 25,
        fargs=(data, l),
        interval=50,
        blit=True)
</t>
<t tx="ekr.20180405093127.17">fig2 = plt.figure()
x = np.arange(-9, 10)
y = np.arange(-9, 10).reshape(-1, 1)
base = np.hypot(x, y)
ims = []
for add in np.arange(15):
    ims.append((plt.pcolor(x, y, base + add, norm=plt.Normalize(0, 30)),))
animation.ArtistAnimation(fig2, ims,
    interval=50,
    repeat_delay=3000,
    blit=True)
#im_ani.save('im.mp4', metadata={'artist':'Guido'})</t>
<t tx="ekr.20180405093127.18"># http://matplotlib.org/1.5.1/examples/animation/animate_decay.html
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation

@others

# global data.
fig, ax = plt.subplots()
line, = ax.plot([], [], lw=2)
ax.grid()
xdata, ydata = [], []
ani = animation.FuncAnimation(
    fig, run, data_gen, blit=False, interval=10,
    repeat=False, init_func=init)

plt.ion()
    # sets interactive mode. Prevents this message:
    # QCoreApplication::exec: The event loop is already running
plt.show()</t>
<t tx="ekr.20180405093127.19">def data_gen(t=0):
    cnt = 0
    while cnt &lt; 1000:
        cnt += 1
        t += 0.1
        yield t, np.sin(2*np.pi*t) * np.exp(-t/10.)
</t>
<t tx="ekr.20180405093127.20">def init():
    ax.set_ylim(-1.1, 1.1)
    ax.set_xlim(0, 10)
    del xdata[:]
    del ydata[:]
    line.set_data(xdata, ydata)
    return line,
</t>
<t tx="ekr.20180405093127.21">def run(data):
    # update the data
    t, y = data
    xdata.append(t)
    ydata.append(y)
    xmin, xmax = ax.get_xlim()
    if t &gt;= xmax:
        ax.set_xlim(xmin, 2*xmax)
        ax.figure.canvas.draw()
    line.set_data(xdata, ydata)
    return line,</t>
<t tx="ekr.20180405093127.22">@nocolor-node
&lt;?xml version="1.0" standalone="no"?&gt;
&lt;!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"&gt;
&lt;svg width="20cm" height="15cm" viewBox="0 0 800 600"
     xmlns="http://www.w3.org/2000/svg"
     xmlns:xlink="http://www.w3.org/1999/xlik/"
     baseProfile="tiny" version="1.2"&gt;
   &lt;title&gt;Spheres&lt;/title&gt;
   &lt;desc&gt;Semi-transparent bubbles on a colored background.&lt;/desc&gt;
     &lt;defs&gt;
       &lt;!-- Create radial gradients for each bubble. --&gt;
       &lt;radialGradient id="blueBubble" gradientUnits="userSpaceOnUse"
                       cx="0" cy="0" r="100" fx="-50" fy="-50"&gt;
         &lt;stop offset="0%" stop-color="white" stop-opacity="1" /&gt;
         &lt;stop offset="25%" stop-color="#cdcdff" stop-opacity=".65" /&gt;
         &lt;stop offset="100%" stop-color="#cdaacd" stop-opacity=".75" /&gt;
       &lt;/radialGradient&gt;
       &lt;radialGradient id="redBubble" gradientUnits="userSpaceOnUse"
                       cx="0" cy="0" r="100" fx="-50" fy="-50"&gt;
         &lt;stop offset="0%" stop-color="white" stop-opacity="1" /&gt;
         &lt;stop offset="25%" stop-color="#ffcdcd" stop-opacity=".65" /&gt;
         &lt;stop offset="100%" stop-color="#bbbb99" stop-opacity=".75" /&gt;
       &lt;/radialGradient&gt;
       &lt;radialGradient id="greenBubble" gradientUnits="userSpaceOnUse"
                       cx="0" cy="0" r="100" fx="-50" fy="-50"&gt;
         &lt;stop offset="0%" stop-color="white" stop-opacity="1" /&gt;
         &lt;stop offset="25%" stop-color="#cdffcd" stop-opacity=".65" /&gt;
         &lt;stop offset="100%" stop-color="#99aaaa" stop-opacity=".75" /&gt;
       &lt;/radialGradient&gt;
       &lt;radialGradient id="yellowBubble" gradientUnits="userSpaceOnUse"
                       cx="0" cy="0" r="100" fx="-50" fy="-50"&gt;
         &lt;stop offset="0%" stop-color="white" stop-opacity="1" /&gt;
         &lt;stop offset="25%" stop-color="#ffffcd" stop-opacity=".65" /&gt;
         &lt;stop offset="100%" stop-color="#bbbbaa" stop-opacity=".75" /&gt;
       &lt;/radialGradient&gt;
       &lt;radialGradient id="background" gradientUnits="userSpaceOnUse"
                       cx="0" cy="0" r="400" fx="250" fy="250"&gt;
         &lt;stop offset="0%" stop-color="#ffffee" /&gt;
         &lt;stop offset="100%" stop-color="#ccccaa" /&gt;
       &lt;/radialGradient&gt;
       &lt;linearGradient id="surface" gradientUnits="userSpaceOnUse"
                       x1="-100" y1="200" x2="400" y2="200"&gt;
         &lt;stop offset="0%" stop-color="#ffffcc" /&gt;
         &lt;stop offset="100%" stop-color="#bbbb88" /&gt;
       &lt;/linearGradient&gt;

       &lt;!-- Create radial gradients for each circle to make them look like
            spheres. --&gt;
       &lt;radialGradient id="blueSphere" gradientUnits="userSpaceOnUse"
                       cx="0" cy="0" r="100" fx="-50" fy="-50"&gt;
         &lt;stop offset="0%" stop-color="white" /&gt;
         &lt;stop offset="75%" stop-color="blue" /&gt;
         &lt;stop offset="100%" stop-color="#222244" /&gt;
       &lt;/radialGradient&gt;
       &lt;radialGradient id="redSphere" gradientUnits="userSpaceOnUse"
                       cx="0" cy="0" r="100" fx="-50" fy="-50"&gt;
         &lt;stop offset="0%" stop-color="white" /&gt;
         &lt;stop offset="75%" stop-color="red" /&gt;
         &lt;stop offset="100%" stop-color="#442222" /&gt;
       &lt;/radialGradient&gt;
       &lt;radialGradient id="greenSphere" gradientUnits="userSpaceOnUse"
                       cx="0" cy="0" r="100" fx="-50" fy="-50"&gt;
         &lt;stop offset="0%" stop-color="white" /&gt;
         &lt;stop offset="75%" stop-color="green" /&gt;
         &lt;stop offset="100%" stop-color="#113311" /&gt;
       &lt;/radialGradient&gt;
       &lt;radialGradient id="yellowSphere" gradientUnits="userSpaceOnUse"
                       cx="0" cy="0" r="100" fx="-50" fy="-50"&gt;
         &lt;stop offset="0%" stop-color="white" /&gt;
         &lt;stop offset="75%" stop-color="yellow" /&gt;
         &lt;stop offset="100%" stop-color="#444422" /&gt;
       &lt;/radialGradient&gt;
       &lt;radialGradient id="shadowGrad" gradientUnits="userSpaceOnUse"
                       cx="0" cy="0" r="100" fx="-50" fy="50"&gt;
         &lt;stop offset="0%" stop-color="black" stop-opacity="1.0" /&gt;
         &lt;stop offset="100%" stop-color="black" stop-opacity="0.0" /&gt;
       &lt;/radialGradient&gt;

       &lt;!-- Define a shadow for each sphere. --&gt;
       &lt;circle id="shadow" fill="url(#shadowGrad)" cx="0" cy="0" r="100" /&gt;
       &lt;g id="bubble"&gt;
         &lt;circle fill="black" cx="0" cy="0" r="50" /&gt;
         &lt;circle fill="#a6ce39" cx="0" cy="0" r="33" /&gt;
         &lt;path fill="black" d="M 37,50 L 50,37 L 12,-1 L 22,-11 L 10,-24 L -24,10
                               L -11,22 L -1,12 Z" /&gt;
         &lt;circle cx="0" cy="0" r="100" /&gt;
       &lt;/g&gt;
     &lt;/defs&gt;
   &lt;g&gt;
     &lt;rect fill="url(#background)" x="0" y="0" width="800" height="600" /&gt;
   &lt;/g&gt;

   &lt;g transform="translate(200,700)"&gt;
     &lt;use xlink:href="#bubble" fill="url(#blueBubble)" /&gt;
     &lt;animateTransform attributeName="transform" type="translate" additive="sum"
         values="0,0; 0,-800" begin="1s" dur="10s" fill="freeze" repeatCount="indefinite" /&gt;
   &lt;/g&gt;
   &lt;g transform="translate(315,700)"&gt;
     &lt;g transform="scale(0.5,0.5)"&gt;
       &lt;use xlink:href="#bubble" fill="url(#redBubble)" /&gt;
     &lt;/g&gt;
     &lt;animateTransform attributeName="transform" type="translate" additive="sum"
         values="0,0; 0,-800" begin="3s" dur="7s" fill="freeze" repeatCount="indefinite" /&gt;
   &lt;/g&gt;
   &lt;g transform="translate(80,700)"&gt;
     &lt;g transform="scale(0.65,0.65)"&gt;
       &lt;use xlink:href="#bubble" fill="url(#greenBubble)" /&gt;
     &lt;/g&gt;
     &lt;animateTransform attributeName="transform" type="translate" additive="sum"
         values="0,0; 0,-800" begin="5s" dur="9s" fill="freeze" repeatCount="indefinite" /&gt;
   &lt;/g&gt;
   &lt;g transform="translate(255,700)"&gt;
     &lt;g transform="scale(0.3,0.3)"&gt;
       &lt;use xlink:href="#bubble" fill="url(#yellowBubble)" /&gt;
     &lt;/g&gt;
     &lt;animateTransform attributeName="transform" type="translate" additive="sum"
         values="0,0; 0,-800" begin="2s" dur="6s" fill="freeze" repeatCount="indefinite" /&gt;
   &lt;/g&gt;
   &lt;g transform="translate(565,700)"&gt;
     &lt;g transform="scale(0.4,0.4)"&gt;
       &lt;use xlink:href="#bubble" fill="url(#blueBubble)" /&gt;
     &lt;/g&gt;
     &lt;animateTransform attributeName="transform" type="translate" additive="sum"
         values="0,0; 0,-800" begin="4s" dur="8s" fill="freeze" repeatCount="indefinite" /&gt;
   &lt;/g&gt;
   &lt;g transform="translate(715,700)"&gt;
     &lt;g transform="scale(0.6,0.6)"&gt;
       &lt;use xlink:href="#bubble" fill="url(#redBubble)" /&gt;
     &lt;/g&gt;
     &lt;animateTransform attributeName="transform" type="translate" additive="sum"
         values="0,0; 0,-800" begin="1s" dur="4s" fill="freeze" repeatCount="indefinite" /&gt;
   &lt;/g&gt;
   &lt;g transform="translate(645,700)"&gt;
     &lt;g transform="scale(0.375,0.375)"&gt;
       &lt;use xlink:href="#bubble" fill="url(#greenBubble)" /&gt;
     &lt;/g&gt;
     &lt;animateTransform attributeName="transform" type="translate" additive="sum"
         values="0,0; 0,-800" begin="0s" dur="11s" fill="freeze" repeatCount="indefinite" /&gt;
   &lt;/g&gt;
   &lt;g transform="translate(555,700)"&gt;
     &lt;g transform="scale(0.9,0.9)"&gt;
       &lt;use xlink:href="#bubble" fill="url(#yellowBubble)" /&gt;
     &lt;/g&gt;
     &lt;animateTransform attributeName="transform" type="translate" additive="sum"
         values="0,0; 0,-800" begin="3s" dur="7.5s" fill="freeze" repeatCount="indefinite" /&gt;
   &lt;/g&gt;

   &lt;g transform="translate(360,700)"&gt;
     &lt;g transform="scale(0.5,0.5)"&gt;
       &lt;use xlink:href="#bubble" fill="url(#blueBubble)" /&gt;
     &lt;/g&gt;
     &lt;animateTransform attributeName="transform" type="translate" additive="sum"
         values="0,0; 0,-800" begin="3s" dur="6s" fill="freeze" repeatCount="indefinite" /&gt;
   &lt;/g&gt;
   &lt;g transform="translate(215,700)"&gt;
     &lt;g transform="scale(0.45,0.45)"&gt;
       &lt;use xlink:href="#bubble" fill="url(#redBubble)" /&gt;
     &lt;/g&gt;
     &lt;animateTransform attributeName="transform" type="translate" additive="sum"
         values="0,0; 0,-800" begin="5.5s" dur="7s" fill="freeze" repeatCount="indefinite" /&gt;
   &lt;/g&gt;
   &lt;g transform="translate(420,700)"&gt;
     &lt;g transform="scale(0.75,0.75)"&gt;
       &lt;use xlink:href="#bubble" fill="url(#greenBubble)" /&gt;
     &lt;/g&gt;
     &lt;animateTransform attributeName="transform" type="translate" additive="sum"
         values="0,0; 0,-800" begin="1s" dur="9s" fill="freeze" repeatCount="indefinite" /&gt;
   &lt;/g&gt;
   &lt;g transform="translate(815,700)"&gt;
     &lt;g transform="scale(0.6,0.6)"&gt;
       &lt;use xlink:href="#bubble" fill="url(#yellowBubble)" /&gt;
     &lt;/g&gt;
     &lt;animateTransform attributeName="transform" type="translate" additive="sum"
         values="0,0; 0,-800" begin="2s" dur="9.5s" fill="freeze" repeatCount="indefinite" /&gt;
   &lt;/g&gt;

   &lt;g transform="translate(225,375)" &gt;
     &lt;g transform="scale(1.0,0.5)" &gt;
       &lt;path d="M 0 0 L 350 0 L 450 450 L -100 450 z"
             fill="url(#surface)" stroke="none" /&gt;
     &lt;/g&gt;
   &lt;/g&gt;
     &lt;g transform="translate(200,0)" &gt;
     &lt;g transform="translate(200,490) scale(2.0,1.0) rotate(45)" &gt;
       &lt;rect fill="#a6ce39" x="-69" y="-69" width="138" height="138" /&gt;
       &lt;circle fill="black" cx="0" cy="0" r="50" /&gt;
       &lt;circle fill="#a6ce39" cx="0" cy="0" r="33" /&gt;
       &lt;path fill="black" d="M 37,50 L 50,37 L 12,-1 L 22,-11 L 10,-24 L -24,10
                             L -11,22 L -1,12 Z" /&gt;
       &lt;animateTransform attributeName="transform"  type="rotate" additive="sum" values="0; 360"
                  begin="0s" dur="10s" fill="freeze" repeatCount="indefinite" /&gt;
     &lt;/g&gt;
     &lt;g transform="translate(200,375)"&gt;
       &lt;use xlink:href="#shadow" transform="translate(25,55) scale(1.0,0.5)" /&gt;
       &lt;circle fill="url(#blueSphere)" cx="0" cy="0" r="100" /&gt;
     &lt;/g&gt;
     &lt;g transform="translate(315,440)"&gt;
       &lt;g transform="scale(0.5,0.5)"&gt;
         &lt;use xlink:href="#shadow" transform="translate(25,55) scale(1.0,0.5)" /&gt;
         &lt;circle fill="url(#redSphere)" cx="0" cy="0" r="100" /&gt;
       &lt;/g&gt;
     &lt;/g&gt;
     &lt;g transform="translate(80,475)"&gt;
       &lt;g transform="scale(0.65,0.65)"&gt;
         &lt;use xlink:href="#shadow" transform="translate(25,55) scale(1.0,0.5)" /&gt;
         &lt;circle fill="url(#greenSphere)" cx="0" cy="0" r="100" /&gt;
       &lt;/g&gt;
     &lt;/g&gt;
     &lt;g transform="translate(255,525)"&gt;
       &lt;g transform="scale(0.3,0.3)"&gt;
         &lt;use xlink:href="#shadow" transform="translate(25,55) scale(1.0,0.5)" /&gt;
         &lt;circle fill="url(#yellowSphere)" cx="0" cy="0" r="100" /&gt;
       &lt;/g&gt;
     &lt;/g&gt;
   &lt;/g&gt;
&lt;/svg&gt;</t>
<t tx="ekr.20180405093127.23">..\Icons\bubbles.svg
</t>
<t tx="ekr.20180405093127.30">@nowrap

''' Creates a window for *live* rendering of rst, html, etc.  (Qt only).

Commands
========

viewrendered.py creates the following (``Alt-X``) commands:

``viewrendered``
    opens a new window where the current body text is rendered as HTML
    (if it starts with '&lt;'), or otherwise reStructuredText.
``viewrendered-big``
    as above, but zoomed in, useful for presentations
``viewrendered-html``
    displays the html source generated from reStructuredText, useful for
    debugging

``viewrendered``
   sets the process current directory (os.chdir()) to the path
   to the node being rendered, to allow relative paths to work in
``.. image::`` directives.

reStructuredText errors and warnings may be shown.  For example, both::

    Heading
    -------

    `This` is **really** a line of text.

and::

    &lt;h1&gt;Heading&lt;h1&gt;

    &lt;tt&gt;This&lt;/tt&gt; is &lt;b&gt;really&lt;/b&gt; a line of text.

will look something like:

**Heading**

`This` is **really** a line of text.

Settings
========

@string view-rendered-default-kind = rst
----------------------------------------

The default kind of rendering.  One of (big,rst,html)
    
@bool view-rendered-auto-create = False
---------------------------------------

When True, the plugin will create a rendering pane automatically.

'''
</t>
<t tx="ekr.20180405093127.31">@language md

# Title

This is **bold** and *italics*.

Control-clicks follow url's in body text.&lt;br&gt;
Plain clicks follow url's in the VR pane.

Here is [Leo's home page](&lt;http://leoeditor.com/).

### Section

- Bullet list
- Another item
- Third item.

Here is some python code:

    def spam():
        pass
</t>
<t tx="ekr.20180405093127.32">@language rest

#####
Title
#####

This is **bold** and *italics*.

Control-clicks follow url's in body text.

Plain clicks follow url's in the VR pane.

More info at `Leo's home page &lt;http://leoeditor.com/&gt;`_.

Section
=======

- Bullet list
- Another item
- Third item.

Here is some python code::

    def spam():
        '''This is a docstring.'''
        pass</t>
<t tx="ekr.20180405093127.9">&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;style&gt;
ul.leo-tree-example  {
    background-color: #ffffec;
    zoom: 75%; # blurs icons a bit.
}
ul.leo-tree-example li {
    background-repeat: no-repeat;
    background-position: 0px 5px;
    padding-left: 27px;
}
li {
    background-image:
url('https://raw.github.com/vivainio/leo/master/leo/Icons/box00.GIF');
    background-repeat: no-repeat;
    background-position: 0px 5px;
    padding-left: 27px;
}
li.selected {
    background-color: lightgrey;
}
li.leaf {
    list-style-type: none;
}
li.plus {
  list-style-image: url('http://leoeditor.com/plusnode.gif')
}
li.minus {
  list-style-image: url('http://leoeditor.com/minusnode.gif')
}
li.leaf {
  background-image: url('http://leoeditor.com/box00.GIF')
}
li.body {
  background-image: url('http://leoeditor.com/box01.GIF')
}
li.mark {
  background-image: url('http://leoeditor.com/box02.GIF')
}
li.mark-body {
  background-image: url('http://leoeditor.com/box03.GIF')
}
li.clone {
  background-image: url('http://leoeditor.com/box04.GIF')
}
li.clone-body {
  background-image: url('http://leoeditor.com/box05.GIF')
}
li.clone-mark {
  background-image: url('http://leoeditor.com/box06.GIF')
}
li.clone-mark-body {
  background-image: url('http://leoeditor.com/box07.GIF')
}
li.dirty {
  background-image: url('http://leoeditor.com/box08.GIF')
}
li.dirty-body {
  background-image: url('http://leoeditor.com/box09.GIF')
}
li.dirty-mark {
  background-image: url('http://leoeditor.com/box10.GIF')
}
li.dirty-mark-body {
  background-image: url('http://leoeditor.com/box11.GIF')
}
li.dirty-clone {
  background-image: url('http://leoeditor.com/box12.GIF')
}
li.dirty-clone-body {
  background-image: url('http://leoeditor.com/box13.GIF')
}
li.dirty-clone-mark {
  background-image: url('http://leoeditor.com/box14.GIF')
}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;ul class="leo-tree-example"&gt;
&lt;li class='plus clone-mark'&gt;
test
&lt;/li&gt;
&lt;ul&gt;
  &lt;li class='plus clone-body'&gt;
  child
  &lt;/li&gt;
  &lt;ul&gt;
    &lt;li class='leaf body'&gt;
    grandchild
    &lt;/li&gt;
  &lt;/ul&gt;
  &lt;li class='plus clone-body'&gt;
  child
  &lt;/li&gt;
  &lt;ul&gt;
    &lt;li class='leaf body'&gt;
    grandchild
    &lt;/li&gt;
  &lt;/ul&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;/body&gt;
&lt;/html&gt;</t>
<t tx="ekr.20180405093138.1">Leo University is a project devoted to help people become Leo developers.

Here is the main page.  It contains links to individual lessons.
https://github.com/leo-editor/leo-editor/issues/816
</t>
<t tx="ekr.20180405105451.1">These will work only if numpy and pyplot are installed.</t>
<t tx="ekr.20180405105738.1"></t>
<t tx="ekr.20180503073939.1"></t>
<t tx="ekr.20180503073954.1">@language python

# To see this in action (from this file):
# - Ctrl-B to define the command.
# - Execute the i1 command

@g.command('i1')
def i1_command(event):
    c = event.get('c')
    if not c: return
        
    def callback(args, c, event):
        g.trace(args)
        c.bodyWantsFocus()

    c.interactive(callback, event, prompts=['Prompt: '])</t>
<t tx="ekr.20180503074530.1">@language python

# To see this in action (from this file):
# - Ctrl-B to define the command.
# - Execute the i2 command.

@g.command('i2')
def i2_command(event):
    c = event.get('c')
    if not c: return
        
    def callback(args, c, event):
        g.trace(args)
        c.bodyWantsFocus()

    c.interactive(callback, event,
        prompts=['Find: ', ' Replace: '])
</t>
<t tx="ekr.20180503132659.1">@language python

# To see this in action (from this file):
# - Ctrl-B to define the command.
# - Execute the i3 command

@g.command('i3')
def i3_command(event):
    c = event.get('c')
    if not c: return
        
    def callback(args, c, event):
        g.trace(args)
        c.bodyWantsFocus()

    c.interactive(callback, event,
        prompts=['One: ', ' Two: ', ' Three: '])
</t>
<t tx="ekr.20181015142534.1">Leo uses a model/view/controller architecture.

- Controller: The Commands class and its helpers in leoCommands.py and leoEditCommands.py.

- Model: The VNode and Position classes in leoNodes.py.

- View: The gui-independent base classes are in the node "Gui Base Classes". The Qt-Specific subclasses are in the node "Qt gui".

**Important**: The general organization of these classes have changed hardly at all in Leo's 20+ year history.  The reason is that what each class does is fairly obvious.  How the gets the job done may have changed drastically, but *that's an internal implementation detail of the class itself*.  This is the crucial design principle that allows Leo's code to remain stable.  *Classes do not know or meddle in the internal details of other classes*.  As a result, nobody, including EKR, needs to remember internal details.
</t>
<t tx="ekr.20181015142534.2">A **widget** is an actual Qt widget. Leo's core seldom accesses widgets directly.  Instead, a  **wrapper class** defines a standard api that hides the details of the underlying gui **text** widgets.

Leo's core uses the wrapper api almost exclusively. That is, Leo's core code treats wrappers *as if* they were only text widgets there are!

A back door exists for special cases. All wrapper classes define an official ``widget`` ivar, so core or plugin code can gain access to the real Qt widget using wrapper.widget. Searching for wrapper.widget will find all gui-dependent snippets of code in Leo's core.
</t>
<t tx="ekr.20181015142534.3">LeoPyRef.leo contains all of Leo's core source code.

Leo's code uses the following conventions throughout:

c:  a commander.
ch: a character.
d:  a dialog or a dict.
f:  an open file.
fn: a file name.
g:  the leoGlobals module.
i, j, k: indices into a string.
p:  a Position.
s:  a string.
t:  a text widget.
u:  an undoer.
w:  a gui widget.
v:  a Vnode
z:  a local temp.

In more limited contexts, the following conventions apply:

si:     a g.ShortcutInfo object.
ks:     a g.KeyStroke object
stroke: a KeyStroke object.

btw:    leoFrame.BaseTextWrapper
stw:    leoFrame.StringTextWrapper

bqtw:   qt_text.BaseQTextWrapper
lqtb:   qt_text.LeoQTextBrowser
qhlw:   qt_text.QHeadlineWrapper
qmbw:   qt_text.QMinibufferWrapper
qlew:   qt_text.QLineEditWrapper
qsciw:  qt_text.QScintiallaWrapper
qtew:   qt_text.QTextEditWrapper

Names defined in Leo's core are unlikely to change, especially names used outside their defining module. This includes virtually everything in leoGlobals.py, and many names in leoCommands.py and other files. </t>
<t tx="ekr.20181015142534.4">The following 'official' ivars (instance vars) will always exist:

c.frame                 The frame containing the log,body,tree, etc.
c.frame.body            The body pane.
c.frame.body.widget     The gui widget for the body pane.
c.frame.body.wrapper    The high level interface for the body widget.
c.frame.iconBar         The icon bar.
c.frame.log             The log pane.
c.frame.log.widget      The gui widget for the log pane.
c.frame.log.wrapper     The high-level interface for the log pane.
c.frame.tree            The tree pane.

The following were official ivars that no longer exist:

c.frame.body.bodyCtrl   Use c.frame.body.wrapper instead.
c.frame.log.logCtrl     Use c.frame.log.wrapper instead.
</t>
<t tx="ekr.20181015143002.1">True: Wrap body text.

</t>
<t tx="ekr.20190101084845.1">If you want to make a command undoable, you must create "before" and "after" snapshots of the parts of the outline that may change. Here are some examples.  Leo's source code contains many other examples.

    </t>
<t tx="ekr.20190101092126.1">To undo a single change to body text::

    command = 'my-command-name'
    b = c.undoer.beforeChangeNodeContents(p, oldYScroll=ypos)
    # Change p's body text.
    c.undoer.afterChangeNodeContents(p,
        command=command, bunch=b, dirtyVnodeList=[])
</t>
<t tx="ekr.20190101092129.1">If your command changes multiple nodes, the pattern is::

    u, undoType = c.undoer, 'command-name'
    u.beforeChangeGroup(c.p, undoType)
    dirtyVnodeList = []
    changed = False
    # For each change, do something like the following:
    for p in to_be_changed_nodes:
        # Change p.
        dirtyVnodeList.append(p.v)
        u.afterChangeNodeContents(p, undoType, bunch)
        changed = True
    if changed:
        u.afterChangeGroup(c.p, undoType,
            reportFlag=False,
            dirtyVnodeList=dirtyVnodeList)
</t>
<t tx="mhw.20181210130732.1">True (recommended):
    Write "E" attribute bits in &lt;v&gt; elements.
    Leo outlines will record the expansion state of all nodes.
    
False: (Good for files like unitTest.leo)
    Suppress "E" attribute bits in &lt;v&gt; elements.
    Only the ancestors of the presently selected node will
    be expanded when Leo opens an outline.</t>
</tnodes>
</leo_file>
