I plan to modify the tkoutline code so the core outline functionality is available independent of the rest of the application. Functionality from the tkoutline application that won't be part of this widget includes menus, the notebook tab interface, persistence to and from files. I expect the following benefits from doing this:
- Make it easy for Tcl savvy users to add their own functionality (see Scripting tkoutline)
- Make it easy to have a curses based tkoutline
- Make it easy to have an outline in a Tcl/Tk browser plugin
- Make it easier to add display of attributes in columns (see columns and filter functionality)
- Make it easier to have one, two, and three pane modes
- Make it easy for others to embed an outline in their applications
This currently under developement, so it is likely to change...
- outline pathName ?tree? ?options?
Creates a new outline widget with the given window pathname. If a tree is given then the outline is populated with that tree. If the tree is not given, then a new one will be created. The tree, if given, must support the API of the tree data structure in tcllib 1.
This outline widget is built on top of the text widget. Knowledge of how the text widget 2 operates is useful in order to programmatically make use of the outline widget.
Options
- -bulletimages: Indicates whether the bullets will be displayed as images (1) or as text characters (0).
- -tree: An existing tree object to initialize the widget with. If this option is not provided, then a brand new tree with a single node will be automatically created.
- Others I haven't thought of yet.
Widget commands
- pathName tree command args
Allows information about the tree to be queried or manipulated. The syntax for command args is the same as that for the tree data structure in tcllib 3. Any operations that modify the tree through this interface will automatically be reflected in the display. As documented by tcllib a node in a tree can have any number of key/value pairs associated. The outline widget sets aside one special key called -expand which controls whether the node is expanded or collapsed in the display.
Note: All read operations are currently supported, but only insert, move, cut, and delete are supported for modification (splice and swap are not supported yet)
Examples
outline .o ;# Create the outline. A new tree with a single node is created. set newNode .o tree insert root 0 ;# Create a new node as the first child of root .o tree set $newNode title "My very own node" ;# Set the node's text .o tree set $newNode mykey "Some value" ;# Create a user-defined key/value set childNodes .o tree children root ;# Get a list of nodes that are children of root .o tree insert $newNode 0 ;# Add a child .o tree set $newNode expand 0 ;# Collapse node1 .o tree delete $newNode ;# Delete the node
- pathName treecmd
Returns the outline widget's tree command. Any modify operations performed on this tree will automatically update the display (just as if the tree subcommand were used). The purpose of this subcommand is so functionality can be written that only knows about the tcllib tree API and knows nothing about outlines.
- pathName getnode textindex
Returns the id of the node at the given text widget index see 4 for the syntax of textindex.
Example
set node .o getnode insert ;# Get the id of the node at the insertion cursor
- pathName selectnode node
Selects the text of the given node.
- pathName getstartidx node
Returns the starting text widget index for the text of the given node.
- pathName getendidx node
Returns the ending text widget index for the text of the given node.
- pathName getnextvisiblenode node
Returns the name of the node whose display location is just after the given node. The empty string is returned if no such node exists.
- pathName getprevvisiblenode node
Returns the name of the node whose display location is just before the given node. The empty string is returned if no such node exists.
- pathName configure ?option? ?value option value...?
Allows the options for the widget to be queried or set
- pathName text command args
Provides direct access to the text widget commands. In general, any modification of the text in the text widget should be avoided. Instead, modification of the text should be made via the tree structure.
- pathName textcmd
Returns the text widget command so that operations can be performed directly on the text widget without knowing about the outline widget.
Interactive operations
Here lists the functionality that will be built with the above core API and made available for the user to be able to interact with the outline.
- MoveNodeUp
- MoveNodeDown
- PromoteNode
- DemoteNode
- DeleteNode
- InsertChild
- InsertSibling
- DuplicateNode
- DuplicateSubtree
The code for this functionality can be viewed online at http://tkoutline.sourceforge.net/cvs/lib/outlinewidget