Add support for el_bind_key() and example usage binding '?' in examples/cli.c

This changeset refactors el_bind_key_in_metamap() into two functions,
adding el_bind_key(), to provide the ability for the user to bind keys
in both the regular and the meta-key maps.

Several useful, but previously internal, functions have been made global to
facilitate the example code mentioned above. These are likely useful to the
user of this library as well:

  el_print_columns() - Display words in columns across a tty_cols wide screen.
  el_ring_bell()     - Can be used as default key binding function.
  el_find_word()     - Returns a copy of the word at rl_point.
This commit is contained in:
Joachim Nilsson
2010-08-05 12:48:51 +02:00
parent 27fcc878a1
commit 5e9177fd18
5 changed files with 86 additions and 43 deletions

View File

@@ -39,7 +39,15 @@ typedef void rl_vintfunc_t(int);
extern int rl_meta_chars;
/* Editline specific functions. */
void el_bind_key_in_metamap(char c, el_keymap_func_t func);
extern char * el_find_word(void);
extern void el_print_columns(int ac, char **av);
extern el_status_t el_ring_bell(void);
extern void el_bind_key(int key, el_keymap_func_t function);
extern void el_bind_key_in_metamap(int key, el_keymap_func_t function);
extern char *rl_complete(char *token, int *match);
extern int rl_list_possib(char *token, char ***av);
/* For compatibility with FSF readline. */
extern int rl_point;