[Idle-dev] Hide code?

Edward K. Ream edream@tds.net
Sun, 04 Nov 2001 10:43:49 -0600


> This concept is called "folding" and it is available in quite a number of
> programmers text editors.  In idle we can just open the class browser and
> double click on the entries there to quickly jump around in a large module.
> The overhead of implementing folding in the idle editor may be prohibitive.

I have spent the last 5 years examining the implications of folding for
programming.  Yes, the class and path browsers do provide folding, with
the following limitations:

1. Most browsers do not let the user arrange the tree as the user sees
fit.  The user is not allowed to add "organizing nodes" or indeed any
new kind of node.  The user is not allowed to move nodes around or
reorganize the outline in any way.

2. Most browsers remember neither the selected node, nor the top visible
node, nor the expansion state of nodes, and so do not restore the tree
as it was when the user last examined it.

3. Most browsers/editors do not understand the structure implied by
"folding" and have no operations that act on tree nodes as true
objects.  For example, most editors do not allow a search to be limited
to a particular part of a tree.

4. There is no way for the programming language to use the tree
structure.  It is not possible, for example, to name a part of the tree
and to reference that tree by name.

These limitations are, in fact, severe.  Leo removes them all.  I am
presently at work on a Python + Tk version of Leo using some IDLE code. 
In the future I hope to move this work into IDLE itself.

Bruce is correct, it is possible to implement folding with special
comment lines.  This is exactly what Leo does. I call these comment
lines "sentinels".  In fact, Leo uses almost a dozen different sentinels
to handle special cases.  Leo2 demonstrates that parsing sentinels on
opening a file is fast and robust.

What makes Leo significant is this: a source file with embedded
sentinels is simultaneously a source file and an outline.  Compilers and
text editors will view the file as text.  Leo, or any other outline
aware browser (maybe IDLE some day!) will view the file as an extremely
capable outline.

See the URL below for full details of Leo.  Leo is Open Software, hosted
on SourceForge and distributed under the Python License.

Edward
--------------------------------------------------------------------
Edward K. Ream   email:  edream@tds.net
Leo: Literate Editor with Outlines
Leo: http://personalpages.tds.net/~edream/front.html
--------------------------------------------------------------------