Class ::tycho::EditItcl


Inherits: ::tycho::EditTcl - Source File - Contents: itk_option - public methods - public proc - protected variable
This class defines a text widget containing an emacs-like editor with some context-specific features for editing Itcl files. Specifically, in addition to features provided by the base class, it keeps track of classes that are defined within so that it can delete the class definitions and instances before evaluating the file. Note that for this to work, all derived classes must be accessible by auto-loading. This implies some formatting restrictions on the source code file. Specifically, class definitions must appear with the keyword "class" starting in column zero and the class name following it on the same line.

This class inherits its hyperlink mechanism from EditTcl. However, because of the namespaces in Itcl, the tagLinks method will only tag references that are completely qualified. For example, "::tycho::EditTcl" will be identified as a link, but "EditTcl" will not. Unfortunately, since Itcl is dynamically scoped, it appears that there is no way around this. The entries in the auto_index array are fully qualified, and there is no way to tell without actually executing a piece of code in some context what namespaces to search for an identifier. We might consider putting in some special support for the tycho namespace, but it would be hard to do much more.


Itk_option

-optioncolor black
The color of Itcl options.

Public constructs

Public Methods

bodyTemplate
Insert a body template.
evaluate
Override the base class to undefine classes defined in the file or the selection to be evaluated. Note that derived classes are undefined and not redefined. They will hopefully be auto-loaded next time they are needed. Also note that this will only work if the class name is fully qualified. Thus, if the declaration is "class ::tycho::foo", the class can be re-evaluated, but if it is "class tycho::foo", then there is no way to tell from the source code what namespace it is defined in.

A number of objects may be deleted as a side effect of invoking this command. These include all objects of classes defined in the file or of derived classes. However, this command is fairly fragile anyway. In particular, if a deleted object is component of another object, that other object may be left in an invalid state. In version 2.0 and 2.1 of Itcl, this can cause a core dump. For now, we issue a warning, pending a better fix.

fileTemplate
Insert the blank itcl template into the file. FIXME: we should promote this to the FILE class.
gendocBuffer
Generate and display a doc file from the current file. If the doc file already exists and is newer than the source file, then it is simply displayed, not regenerated.
getClassName
Guess about the class name from the filename If the file has not been parsed then the className variable might not be set. If it is not set, guess on the className from the name of the file.
help
Open a window with help on the current widget.
parseNow start stop
Invoke the base class parser to color comments, the strings "NOTE" and "FIXME", and procedure names. Then identify class definitions and methods. To recognize class definitions, it requires that "class" be the first non-space token on the line, followed by the class name on the same line. Note that the program that makes the auto-load index has the even tighter restriction that the keyword must start at column zero, and reloading will not work without auto-loading anyway.

Public Proc

gendoc filename
Generate and display a doc file. If the doc file already exists and is newer than the source file, then it is simply displayed, not regenerated.

Protected constructs

Protected Variable

className

Index of classes



Author: Edward A. Lee, Christopher Hylands
Version: @(#)EditItcl.itcl 1.39 12/07/96
Copyright: (c) 1995-1996 The Regents of the University of California.