![]() |
Keyboard bindings | ![]() |
Keyboard shortcuts are defined using the kbd-map macro, which is implemented in
kernel/gui/kbd-define.scm
. The standard bindings can be found in the files *-kbd.scm, such as
generic/generic-kbd.scm
,
math/math-kbd.scm
or
text/text-kbd.scm
(relative to
src/TeXmacs/progs/
). See also the user manual section on creating your own keyboard shortcuts. The way keyboard events reach the editor is described in the event loop.
Each binding is of one of the following forms:
Typing keys inserts the string, which may contain symbols such as <alpha>. An optional third element gives a help text.
Typing keys evaluates the Scheme expressions expr.
Here keys is a string with a space-separated sequence of keystrokes, such as "C-x C-s" or "a var". Modifiers are written as prefixes S- (shift), C- (control), A- (alt) and M- (meta, which is the command key under macOS). Logical prefixes such as std, cmd, altcmd, special or structured:move are rewritten into physical modifiers according to the current look and feel (see
texmacs/keyboard/prefix-kbd.scm
); they should be preferred in portable key bindings. The key var (usually the tab key) is used to cycle through variants.
The bindings may be preceded by the following options:
The bindings are only valid in the given mode, such as in-math? (see contextual overloading). The mode may also be given alone, as in (kbd-map in-math? …). As for functions, the most recent binding of a key whose conditions hold is used.
The bindings are only valid when the expression cond evaluates to true.
The bindings are only defined for the given look and feels (such as emacs, gnome, kde, windows or macos). The profile std stands for all look and feels except emacs, and a prefix no- negates a profile (e.g. no-macos).
For instance:
(kbd-map
(:mode in-math?)
("std F5" (make 'sqrt))
("< = var" "<leqslant>")) |
Remove the bindings for the given key sequences, under the same conditions as in kbd-map.
Declare that the key prefix from should be rewritten into to. The optional which is pre (the rewriting is applied when the key bindings are defined) or post (the default: the rewriting is applied to the actual keystrokes).
(kbd-commands (name help expr) …)
Define commands which can be entered by typing a backslash followed by name. The macro kbd-symbols defines such commands for inserting the symbols <name>.
Besides key bindings, many keys call overloadable routines, such as kbd-enter, kbd-tab, kbd-remove, kbd-horizontal or kbd-vertical (see
generic/generic-edit.scm
). The behaviour of these keys inside specific tags can be customized by redefining these routines using tm-define with a :require option.