User's Guide to the Tycho File Class

The File class in Tycho is the base class for most editors. It provides a top-level window with a menu bar at the top. It also provides some common key bindings that are therefore shared by all derived classes, and it handles autosave and crash recovery. By itself, this class is not very useful; the derived classes are the ones actually used.

File Access Commands

The following commands are available in the File menu as well through key bindings.

C-x C-f
open a file
C-x C-v
switch to a new file in the same window
C-x i
insert a file
C-x C-s
save the current file
C-x C-w
save to some other file name
C-x p
print the contents (not yet implemented)
C-x C-r
evaluate a file (only valid in some derived classes)
C-x C-q
toggle read-only (possibly invoking version control)
C-x v
invoke revision control
C-x k
close the window
C-x C-c
exit the program

In addition to the above, the File menu provides the following command without any key binding:

Revert
Revert to the previously saved version of this file.

The File class also provides the following binding with no corresponding menu entry:

C-x o
move the focus to another window

Version Control

The version control or revision control mechanism built into the File class interfaces to either SCCS, a Unix "source code control system", or RCS, a public domain improvement. When the "Revision Control" command in the File menu is invoked, then if the file is already under version control by either SCCS or RCS, a control panel will appear that permits the user to check out the file (if it is not checked out), check in the file (if it is checked out), examine the version history, or unedit the file (cancel changes made since the file was checked out). The version history mechanism displays the comments that were filed with checkins as well as version numbers and dates. Double clicking on an older version will cause that version to be displayed in a new window.

If the file is not currently under revision control, then invoking the "Revision Control" command will query the user about whether the file should be placed under revision control. The list of revision control systems presented to the user can be set as an option, but currently includes only SCCS and RCS, with SCCS being the default.

Revision control is also used by the "Toggle read-only" command, if the file is already under revision control. If it is not, then the read-only permissions are simply changed without the intervention of any revision control system.

The Tycho development group uses SCCS, and has configured the options to follow our style. In particular, when a file is put under the control of SCCS, it is required to have "ID keywords", which are strings like %W% and/or %D%. When a file is checked in, these get converted into version numbers. In addition, in order to support copyright notices, %Q% gets converted into the current year. Another useful ID keyword is %G%, which gets converted into the current date.

Window Menu

File objects have a Window menu in the menu bar. The menu contains commands that somewhat duplicate typical window manager functions, but are provided in order to have convenient key bindings. It also contains commands to open new, blank editors for any type of editor that has been registered with the File class. In addition, all open editors that are associated with named files are listed. This makes it easier to find editors that may have been buried by other windows on the screen. Note that if the editor is open in another screen of a virtual window manager, it will not appear when you issue the command in the Window menu. Also, if an editor has the name "NoName" associated with it, it does not appear in the Window menu. To give it a name, use SaveAs (in the File menu).

Window Control Commands

A few window control menu commands and associated key bindings are provided for convenience.

C-x 0
iconify the window
C-x 1
full size
C-x 6
original size

Eventually, this list will be more complete, but in the current version, bugs in the interface to the window manager make this impossible.

Registering an Editor with the File Class

Since Tycho is meant to be an extensible system, it is expected that users will create new editors. Integrating these editors into Tycho is easy. Just issue the following command:

::tycho::File::registerEditor {.foo} ::tycho::EditFoo {Foo editor}
The first argument, "{.foo}" gives zero or more filename extensions that will cause your editor to be used in place of the default editor. The second argument is the name of the editor class to use. The third argument is the text that will be inserted into the Window menu. With the above example, a Tycho "Open File" command on a file called "file.foo" will cause an instance of ::tycho::EditFoo to be created. The syntax of the command that creates the instance will be:
::tycho::EditFoo .some_name -file file.foo
The name is generated automatically. The -file option must (obviously) be understood by the editor. But that is the only constraint on the editor.

Help Menu

The Help menu provides access to the on-line documentation for Tycho. The "User's Guide" entry in the menu will bring up a user's guide for the widget in which you invoke the command, if one exists. The "Index" entry will bring up the master Tycho index.

Keyboard Traversal of the Menus

The mechanism for keyboard traversal of the menus is exactly that provided in Tk. Thus, the following explanation is from the Tk man pages, written by John Ousterhout.

"The menus can be invoked using the Alt key (sometimes "Alt Graph") together with the underlined character in the menu title. Once the menu is posted, typing the underlined character in a menu item will invoke it. The F10 key will post the "File" menu.

Autosave and Crash Recovery

Periodically, if its data has been modified, a File object will save the data to a file with the same name as the current file but with the prefix "#auto#". This file is automatically removed when you save the modified data.

If you are running Ptolemy with Tycho, then Tycho will also attempt to save modified data when the program crashes. This is important because Ptolemy is fundamentally an extensible system, into which users routinely add their own code, so it is not uncommon in the process of doing code development to get crashes. The crash recovery files have the prefix "#crash". There is no guarantee that their contents will be correct, since often the crash occurs due to corrupted data.

Tycho Home Page


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