Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.atnf.csiro.au/computing/software/smongo/sm_7.html
Дата изменения: Unknown
Дата индексирования: Tue Oct 2 13:33:15 2012
Кодировка:

Поисковые слова: п п п п п п п п п п п п п п п
SM - Changing Key-Bindings

Go to the previous, next section.

Changing Key-Bindings

As mentioned above, it is possible to redefine the meanings of keys to the history (and macro) editor. The command EDIT keyword key-sequence will make typing that sequence of keys correspond to the command keyword. For example, to make ^R redraw the current line, you could say EDIT refresh ^R. The keyword can be any in the list below, or any single character. Each character in the key-sequence can be a single character, ^c, or \nnn where nnn is an octal number. Alternatively, READ EDIT filename will read a file specifying the new bindings which has two lines of header, followed by pairs of keyword key-sequence. Lines starting with a # are comments. An example is the file for VMS users given below.

A problem can come up with multiple-key sequences. Imagine that you have bound some function to ^X^A, for example

        EDIT end_of_line ^X^A
then what happens when you try it? SM sees the ^X and uses its default binding, exit_editor, and then sees a ^A and goes to the start of the line, which wasn't the desired effect. The solution is to tell SM that ^X is not a legal key, in which case it will either ring the terminal bell (if there are no key-sequences starting with an ^X), or wait for the next key. In short,
        EDIT illegal ^X
        EDIT end_of_line ^X^A
should work.

On a somewhat similar topic, the KEY (@xref{KEY}) command may be used to define a key to generate a string. See the end of the section on macros for how this works.

All the current key definitions may be listed using LIST EDIT, including the KEY definitions. The names of operators, and their default bindings, are given in the following table:

^A
start_of_line
^B
previous_char
^C
^D
delete_char
^E
end_of_line
^F
next_char
^G
illegal
^H, DEL
delete_previous_char
^I
tab
^J
carriage_return
^K
kill_to_end
^L
refresh
^M, ^@
carriage_return
^N
next_line
^O
insert_line_above
^P
previous_line
^Q, ESC-q
quote_next
^R
search_reverse
^S
search_forward
^T
toggle_overwrite
^U
delete_to_start
^V
scroll_forward
^W, ESC-h
delete_previous_word
^X
exit_editor
^Y
yank_buffer
^Z
attach_to_shell
ESC-<
first_line
ESC->
last_line
\034
escape
ESC-b
previous_word
ESC-d
delete_next_word
ESC-f
next_word
ESC-g
goto_line
ESC-u
undelete_word
ESC-v
scroll_back
ESC-y
yank_previous_buffer
ESC-^D
delete_from_history
^
history_char

A simple example of a bindings file for a hardened VMS user might be

# This is a set of DCL-ish key maps for SM
# name   key
toggle_overwrite        ^A
start_of_line           ^H
delete_previous_word    ^J
yank_buffer             ^R
search_reverse          ^[r
attach_to_shell         ^Y
Note that that's the two characters ^ and A not control-A. It could just as well have been written \001. We need a new character for yank_buffer now that ^Y is otherwise engaged, and I have chosen ^R (which means that I can't use ^R to search backwards, so I chose ESC-r for that). You should be warned that some terminal protocols map ^M to ^J, so this use of ^J could render you unable to issue commands. As mentioned above, in an emergency ^@ can be used instead of ^M.

When SM is started, or whenever the TERMTYPE command is used to change terminals, the arrow keys are bound to the commands previous_line, ext_line, previous_char, and ext_char. For terminals such as a Televideo-912, which uses characters such as ^K for arrow motion, these can supersede the previous meanings (in this case kill_to_end); The only fix is to use the EDIT or READ EDIT command to get what you want, probably within a macro.

If you want to use ' as your history character instead of ^ you need to say edit history_char ` edit ^ ^. If you try to use a character special to SM such as ! this won't work (you'll get a syntax error) and you'll have to use the next alternative, namely put the commands into a file and say read edit filename, for example:

# Change the history character
# name   key
history_char   !
^              ^
Because this particular change is so common, it's possible to specify that ` be your history character simply by including a line history_char ` in your `.sm' file (or you can choose your own character. Choosing 0 has the effect of using the default, ^).

SM needs to know something about the terminal that you are using, so as to run the history/macro editor. This is entirely separate from the problem of describing the terminal's graphics. It will try to discover what sort of terminal you're on by using the value of term from your `.sm' file, or failing that the value of the environment variable TERM (Unix) or the logical variable TERM (VMS). A term entry of selanar -21 is equivalent to a TERMTYPE selanar -21 command. You can also use the TERMTYPE command directly. SM then uses the terminal type specified to look up its properties in the termcap database (see section Termcap -- A Terminal Database). You can also use TERMTYPE to specify the size of the screen, or to turn off SM's idea of where the cursor is. On some terminals, you can only send a cursor to an absolute position and this is chosen to be the bottom of the screen. This is not what you want for, e.g., a VT240 as it will lead to your graph scrolling off the screen. The use of a negative screen size to TERMTYPE will disable this cursor motion, but will also make editing lines slower. If a line of your graph is being deleted when the SM prompt appears, you may need to use TERMTYPE dumb or TERMTYPE none.

Go to the previous, next section.