(readline.info.gz) Binding Keys
Info Catalog
(readline.info.gz) Keymaps
(readline.info.gz) Readline Convenience Functions
(readline.info.gz) Associating Function Names and Bindings
2.4.3 Binding Keys
------------------
Key sequences are associate with functions through the keymap.
Readline has several internal keymaps: `emacs_standard_keymap',
`emacs_meta_keymap', `emacs_ctlx_keymap', `vi_movement_keymap', and
`vi_insertion_keymap'. `emacs_standard_keymap' is the default, and the
examples in this manual assume that.
Since `readline()' installs a set of default key bindings the first
time it is called, there is always the danger that a custom binding
installed before the first call to `readline()' will be overridden. An
alternate mechanism is to install custom key bindings in an
initialization function assigned to the `rl_startup_hook' variable
( Readline Variables).
These functions manage key bindings.
-- Function: int rl_bind_key (int key, rl_command_func_t *function)
Binds KEY to FUNCTION in the currently active keymap. Returns
non-zero in the case of an invalid KEY.
-- Function: int rl_bind_key_in_map (int key, rl_command_func_t
*function, Keymap map)
Bind KEY to FUNCTION in MAP. Returns non-zero in the case of an
invalid KEY.
-- Function: int rl_bind_key_if_unbound (int key, rl_command_func_t
*function)
Binds KEY to FUNCTION if it is not already bound in the currently
active keymap. Returns non-zero in the case of an invalid KEY or
if KEY is already bound.
-- Function: int rl_bind_key_if_unbound_in_map (int key,
rl_command_func_t *function, Keymap map)
Binds KEY to FUNCTION if it is not already bound in MAP. Returns
non-zero in the case of an invalid KEY or if KEY is already bound.
-- Function: int rl_unbind_key (int key)
Bind KEY to the null function in the currently active keymap.
Returns non-zero in case of error.
-- Function: int rl_unbind_key_in_map (int key, Keymap map)
Bind KEY to the null function in MAP. Returns non-zero in case of
error.
-- Function: int rl_unbind_function_in_map (rl_command_func_t
*function, Keymap map)
Unbind all keys that execute FUNCTION in MAP.
-- Function: int rl_unbind_command_in_map (const char *command, Keymap
map)
Unbind all keys that are bound to COMMAND in MAP.
-- Function: int rl_bind_keyseq (const char *keyseq, rl_command_func_t
*function)
Bind the key sequence represented by the string KEYSEQ to the
function FUNCTION, beginning in the current keymap. This makes
new keymaps as necessary. The return value is non-zero if KEYSEQ
is invalid.
-- Function: int rl_bind_keyseq_in_map (const char *keyseq,
rl_command_func_t *function, Keymap map)
Bind the key sequence represented by the string KEYSEQ to the
function FUNCTION. This makes new keymaps as necessary. Initial
bindings are performed in MAP. The return value is non-zero if
KEYSEQ is invalid.
-- Function: int rl_set_key (const char *keyseq, rl_command_func_t
*function, Keymap map)
Equivalent to `rl_bind_keyseq_in_map'.
-- Function: int rl_bind_keyseq_if_unbound (const char *keyseq,
rl_command_func_t *function)
Binds KEYSEQ to FUNCTION if it is not already bound in the
currently active keymap. Returns non-zero in the case of an
invalid KEYSEQ or if KEYSEQ is already bound.
-- Function: int rl_bind_keyseq_if_unbound_in_map (const char *keyseq,
rl_command_func_t *function, Keymap map)
Binds KEYSEQ to FUNCTION if it is not already bound in MAP.
Returns non-zero in the case of an invalid KEYSEQ or if KEYSEQ is
already bound.
-- Function: int rl_generic_bind (int type, const char *keyseq, char
*data, Keymap map)
Bind the key sequence represented by the string KEYSEQ to the
arbitrary pointer DATA. TYPE says what kind of data is pointed to
by DATA; this can be a function (`ISFUNC'), a macro (`ISMACR'), or
a keymap (`ISKMAP'). This makes new keymaps as necessary. The
initial keymap in which to do bindings is MAP.
-- Function: int rl_parse_and_bind (char *line)
Parse LINE as if it had been read from the `inputrc' file and
perform any key bindings and variable assignments found (
Readline Init File).
-- Function: int rl_read_init_file (const char *filename)
Read keybindings and variable assignments from FILENAME (
Readline Init File).
Info Catalog
(readline.info.gz) Keymaps
(readline.info.gz) Readline Convenience Functions
(readline.info.gz) Associating Function Names and Bindings
automatically generated byinfo2html