keybindings

Binding keys

/Def -b allows you to bind a character string to a macro. Typing that string at the keyboard (which may mean pressing a single key that generates the string) will then call the macro.

/Def -B allows you to bind a symbolic keyname to a macro. There are several advantages in using symbolic key names over key code strings. First, you don't have to know what string is generated by the special keys on your keyboard. They will work on multiple terminals, based on the value of %TERM (assuming the keys are defined in the termcap database). Changing %TERM at any time will rebind the macros to the new codes.

The keynames recognized by tf are:

Unfortunately, even if your terminal has a particular key, your termcap entries may not define it, so you may not be able to use it by name. The arrow and function are pretty reliably defined, but many of the other keys are not. Also, terminal emulators often do not match all the key definitions.

They must be spelled as shown, but capitalization is ignored. The function keycode() can be used to find the string generated by a key (as defined in the termcap entry for %TERM).

Because TF runs in a terminal and not in a windowing system, it does not see actual keystrokes, but only the characters generated by a keystroke. If two different keys generate the same characters, TF can not tell them apart. In earlier versions, this meant that on many terminals TF could not distinguish the numeric keypad keys from arrow or digit keys, because they generated the same character sequences. Starting in 4.0 alpha 11, TF tries to put the keypad in "application mode", which on many terminals will make the keypad keys generate unique character sequences if Num Lock is on.

Note that before version 3.5 alpha 21 or beta 1, it was usually harmless to "/set TERM=vt100" on terminals that accepted a superset of vt100 display codes. However, the termcap key definitions are often different for terminals that are otherwise similar (e.g., vt100 and xterm share many display codes, but the key definitions are different), so setting %TERM incorrectly will interfere with the operation of named keys. Xterm users should also note that since 3.5 alpha 17, tf ignores xterm's ti and te capabilities that sometimes interfered with the operation of the scrollbar, so tricking tf with TERM=vt100 is no longer necessary.

Special keys

TF's input handler recognizes ^H and ^? as backspace and ^J and ^M as newline, even when they are not bound to macros. However, if a keybinding is defined for any of these keys, it will override the internal handling of that key.

At startup, tf also examines the terminal driver settings for keys corresponding to the /dokey functions BWORD, DLINE, REFRESH, and LNEXT, and binds them accordingly if different than the default bindings listed below.

Default keybindings

Named keys

Key	Command			Meaning
---	-------			-------
Up	/dokey UP		cursor up
Down	/dokey DOWN		cursor down
Right	/dokey RIGHT		cursor right
Left	/dokey LEFT		cursor left
F1	/help			help
Insert	/test insert:=!insert	toggle insert mode
Home	/dokey_home		cursor to beginning of line
PgDn	/dokey page		scroll 1 screenful at --More-- prompt

Unnamed key sequences

String	Command			Meaning
------	-------			-------
"^A"	/dokey_home		cursor to beginning of line
"^B"	/dokey_wleft		cursor to beginning of word
"^D"	/dokey_dch		delete character
"^E"	/dokey_end		cursor to end of line
"^F"	/dokey_wright		cursor to end of word
"^G"	/beep 1			beep
"^I"	/dokey page		scroll 1 screenful at --More-- prompt
"^J"	/dokey NEWLINE		execute current line
"^K"	/dokey_deol		delete to end of line
"^L"	/dokey redraw		redraw screen
"^M"	/dokey NEWLINE		execute current line
"^N"	/dokey recallf		recall forward input history
"^P"	/dokey recallb		recall backward input history
"^R"	/dokey REFRESH		refresh line
"^T"	/kb_transpose_chars	transpose characters
"^U"	/dokey DLINE		delete line
"^V"	/dokey LNEXT		input next key literally
"^W"	/dokey BWORD		delete backward word (space-delimited)
"^[^E"	/kb_expand_line		expand current line in place
"^[ "	/kb_collapse_space	change multiple spaces to a single space
"^[-"	/kb_goto_match		move cursor to matching parenthesis/bracket
"^[."	/kb_last_argument	input last word of previous line
"^[J"	/dokey selflush		selective flush (flush non-hilited text)
"^[_"	/kb_last_argument	input last word of previous line
"^[b"	/fg -<			foreground previous socket
"^[c"	/kb_capitalize_word	capitalize word
"^[d"	/dokey_dword		delete forward word
"^[f"	/fg ->			foreground next socket
"^[h"	/dokey hpage		scroll half screenful at --More-- prompt
"^[j"	/dokey flush		flush (discard text after --More-- prompt)
"^[l"	/kb_downcase_word	downcase word
"^[n"	/dokey searchf		search forward input history
"^[p"	/dokey searchb		search backward input history
"^[u"	/kb_upcase_word		upcase word
"^[v"	/test insert:=!insert	toggle insert mode
"^[^?"	/kb_backward_kill_word	delete backward word (punctuation-delimited)

Terminal keys

Some keys are interpeted by the terminal, not TF, so if you want to change them, you must do so outside of TF (e.g. with stty in unix). Typical unix terminal keys include:
^S
"stop" - stops terminal output.
^Q
"start" - restart terminal output after a "stop".
^C
"int" - generates a SIGINT signal.
^\
"quit" - generates a SIGQUIT signal.
^Z
"susp" - suspends the process

Other key bindings

Some additional keyboard operations can be defined by /loading these library files:
kb-bash.tf
keybindings like those in bash
kb-emacs.tf
keybindings like those in emacs
kbregion.tf
cut-and-paste operations
kbstack.tf
save the current line with ESC-DOWN and recall it later with ESC-UP.
See the comments at the top of each file for further documentation.

See: /dokey, /bind, completion, %wordpunct, signals.


Back to index
Back to tf home page
Copyright © 1995 - 1999 Ken Keys