[ Home ] [ Authors ] [ Index ] [ Abbreviations ] [ Key bindings ]

The Edit and EditText Classes

The Edit class, derived from File, is a top-level window that contains an emacs-like editor with emacs-like key bindings. It has full capabilities for editing text, saving files, etc. The help window gives additional information.

You may create an instance of the Edit class as follows:

::tycho::Edit .e
.e centerOnScreen
To read a file into the text widget, try
.e insertFile
There are many public methods associated with this class. See the class documentation for details.

EditText Class

The top-level Edit class window is implemented by packing into it a megawidget that implements the editor itself. This megawidget, the EditText class, can be used stand-alone inside any other widget or window. For example, the EntryQuery class uses EditText for multi-line entries.

Classes derived from Edit should similarly be divided into a top-level window class and a megawidget. This gives maximum flexibility for using the classes in unanticipated ways. The convention is that text editing widgets have the suffix "Text" appended to the name of the corresponding top-level window class. Thus, EditText is the widget used in the Edit class. Similarly, HTMLText is a widget used in the HTML class.

We can create an instance of the EditText megawidget in its own top-level window as follows:

::tycho::TopLevel .t
::tycho::EditText .t.t
pack .t.t
.t centerOnScreen
Notice that you can enter text into the text window. If you are an emacs user, you will find the keystrokes used for navigating through the text familiar. To delete the above example:
delete object .t
EditText has a number of options. For example:
::tycho::TopLevel .p
::tycho::EditText .p.t \
    -text "Initial text in the text widget" \
    -readonly "yes" \
    -width 60 \
    -scrollbar 0 \
    -height 20
pack .p.t
.p centerOnScreen
Notice that because of the -readonly option, you cannot modify the text. You can change this, and read in a file as follows:
.p.t configure -readonly no
.p.t readFile $ptolemy/tycho/kernel/Color.tcl
There are a large number of other public methods for EditText. See the class documentation. To delete the above example:
delete object .p


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