Keyboard transformations

The editor has a very flexible capability of redefining the keyboard layout. These keyboard redefinitions are not only for rearranging the keys with which the commands are executed, but whole sequences can be assigned to a single key. This allows the user to define his own powerful and custom made commands. For example, if the user prefers to use different keys than the default ones for particular actions, new keys can be assigned to the actions. Or if a particular command is not exactly what a user is used to, it can be changed to his liking. One can also access all the special characters built into the display fonts such as those for national character sets using the keyboard redefinition feature. Commands can be designed that are only activated after hitting several keys as well. This is of use when emulating another editor with which one might be familiar. Of course such a flexible environment has some strict rules. In this chapter the keyboard redefinition capabilities of stedi are explained in detail.

The way the keyboard can be reprogrammed is somewhat involved as a special file is required which defines the new layout. Such a file can be made in the editor, but then must be translated into a binary file that in turn can be read by the editor to reconfigure the keys. An outline of what you have to do to redefine some keys of the keyboard is as follows.

First you must create a file which makes the key change assignments. The syntax of this file will be explained below but the general form of a key redefinition statement in this file is similar to an equation. On the left side a list of key codes are given, then an equals sign, and then a second list of key codes. This has the effect of assigning the actions represented by the key codes on the right side of the statement to the key strokes on the left side.

Next you must translate this file into a binary file which the editor can read. For this purpose, a utility program is provided called `keycomp'. This program takes the key redefinition file as input, and it creates the binary file needed to be read in by the editor. Then, to make the key redefinitions become effective, the binary file must be read into the editor using the K command from the command line. This command causes stedi to read in the file and store its contents in a special buffer. Finally, if the DW command is issued, the contents of this buffer will become part of the default file so that at a later startup the new keyboard layout will be available again. A subsequent reading of the default file will not affect the keyboard layout. It can only be changed when the default file is read at startup time or by using the K command.

The use of keycomp, the compiler for keyboard transformation programs, allows the editor to skip much error checking. Also, unpredictable results may occur if a file is read by the editor that was not made by the key compiler as a keyboard transformation file with the K command. There is some error checking and the binary files can even be exchanged between machines with a different byte ordering scheme (there are limits though). In what follows, first, the syntax of the key redefinition file will be explained. Then through a collection of examples, the key codes will be explained and the capabilities of this feature explored. Finally the `K' command and the use of the key redefinition file compiler keycomp will be explained. For those of you who can't wait to try out this feature, you may wish to skip to the end of the chapter after reading only a few examples.



Subsections