Class ::tycho::IndexBrowser


Inherits: ::tycho::ListBrowser - Source File - Contents: itk_option - public methods - protected methods - protected variables
A browser for an index. An index consists of a two element list: An index list is a list of entries, where each entry is a list with two or three items. If the entry has three items, they should be The third item has any syntax supported by the seeFragment method of the target editor. It may be a null string, {}, in which case the file is simply opened. In an HTML file, it can be the name associated with any named anchor. In a text file it could be a string of the form {line linenumber} or {range start end}, where start and end are of the form line.character.

If an entry in the index has only two items, then they are:

This allows for recursive indexes in a single file. When the user clicks on one of these two-item entries, the contents of the list box are replaced by the new index list.

If a hyperjump is taken into an index file, and a point is specified, then the index is searched for a matching entry. If a single matching entry is found, then the link is followed for that entry. Otherwise, the index is displayed with all matching entries shown.

If the -file option is given, that file is read for the contents of the listbox. Moreover, the directory of that file is used for relative filenames referenced by the index. Otherwise, the current working directory is used for relative file names.

The format of the file is that of an index, a list of two items. It can contain comment lines, which begin with a pound sign (#). These are ignored.

The example below opens up the tycho index

 
set win [::tycho::IndexBrowser [::tycho::autoName .ib] \
-file [file join $TYCHO lib idx tycho.idx]]
$win centerOnScreen
.

Itk_option

-file
Set or change the name of the file that specifies the contents of the listbox. This also specifies the directory relative to which file references are understood.

Public constructs

Public Methods

currentPoint
Return the text of the current entry.
help
Open a help window.
hyperJump filename {point {}}
Open a file and go to its internal point identified by name. If the filename is relative (it does not begin with "/"(unix), "~", or "$"), then prepend the directory of the file currently being edited or viewed. Then, expand the filename using ::tycho::expandPath and open the resulting file with ::tycho::File::openContext, which will choose an editor based on the filename extension. Finally, invoke seeFragment to view the specified point within the file. The format for the point argument depends on the type of file being opened. For HTML files, it will normally be the name of an anchor in the file. For text files, it will normally be either "{line linenumber}" or "{range start end}", where start and end have the form linenumber.characternumber.
seeFragment point
If a hyperjump is taken into an index file, and a point is specified, then the index is searched for a matching entry. If a single matching entry is found, then the link is followed for that entry. Otherwise, the index is displayed with all matching entries shown.

Protected constructs

Protected Methods

processItem filename
This procedure processes a user selection by performing a hyperjump to the specified file and point.
setContents contents
Given a list, use it to construct the index contents.

Protected Variables

CWD
The directory of the index file.
entries
The entries in the index.

Index of classes



Author: Edward A. Lee
Version: @(#)IndexBrowser.itcl 1.27 12/13/96
Copyright: (c) 1995-1996 The Regents of the University of California.