User's Guide to the Forest Editor

This class provides a visual editor specialized for editing forests. A forest is a data structure that includes any number of trees. A tree is a data structure with nodes that are either a root or have exactly one parent, and that have any number of children. It is invoked automatically when opening any file with the ".fst" extension in its name. The forest editor is derived from the Graphics class, and therefore inherits all of its features.

Menu commands for adding new nodes, deleting nodes, and editing the name or contents of the nodes are provided. Here is an example of how to use the EditForest:

    ::tycho::view EditForest [list -file \
         $TYCHO/editors/visedit/test/sample.fst]

Clicking the left mouse button on any node selects it. Clicking away from any node deselects selected nodes. The selected node may be deleted using the Cut command, which also saves the node to the clipboard. A node in the clipboard may be pasted using the Paste command. If a node is selected when the Paste command is issued, then the node in the clipboard is pasted as a child of the selected node. Otherwise, it is pasted as a root node. The Copy command saves a node to the clipboard without deleting it. However, this node can only be pasted in another window, because every node is required to have a unique name.

A selected node may be edited using the Edit Node command. A new root may be added using the New Root command. A new child node may be added to a selected node using the New Child command.

The contents of a node is an arbitrary Tcl string. However, if the data takes a certain form, then the display and behavior of the editor can be controlled very precisely. In particular, the contents of the node can be a list, with items in the list being lists lists of the form "{keyword value}". The following keywords are currently understood:

label
The value field gives the label used to show the node in the display. If this is not present, then the node name is used.
color
The value field gives the color used to show the node in the display. If this is not present, then the node color is black. The color name is processed to make sure it is valid, and if not, black is used.
font
The value field gives the font used to show the node in the display. If this is not present, then the default variable-spacing font is chosen. The value can take any form understood by the getFont method of the FontManager class.
link
The value field gives a list with two elements, a filename and a point within the file, in the standard Tycho hyperlink format. Double clicking on the node will activate the hyperlink. The filename may be absolute or relative, and may begin with an environment variable (such as $TYCHO), or a user directory (~username). If the filename is relative, then the reference directory is that of the file of the top-level editor that contains this EditForestWidget. The point may be a string identifying a named anchor in an HTML file, or "{line linenumber}" or "{range start end}" for text files, or any other destination that is understood by the seePoint method of the widget that will display the hyperlink.
html
The value field gives HTML source code that will be rendered and displayed in a message window in response to a double click on the node. If both this field and the "link" field are given, then both will be activated by a double click.

Tycho Home Page


Copyright © 1996, The Regents of the University of California. All rights reserved.
Last updated: 96/12/07, comments to: tycho@eecs.berkeley.edu