Improve GNU readline compat, patch by Steve Tell in 1997 and 1998

This changeset adds support for:
   * rl_prep_terminal(),
   * rl_deprep_terminal(), both of which are only wrappers to rl_ttyset().
   * rl_getc()

and:
   * (*rl_getc_function), defaults to rl_getc()
   * (*rl_event_hook)
   * (*rl_prep_term_function), defaults to rl_prep_terminal()
   * (*rl_deprep_term_function), defaults to rl_deprep_terminal()

For further details, see http://www.cs.unc.edu/~tell/dist/magic-readline.README

Differences from Steve's commit include: signal safety in rl_getc(), restart
read() on EINTR, and make sure to support "int meta_flag" to rl_prep_terminal()
which is the GNU syntax.  To that end I reused the inverse of rl_meta_chars.
This commit is contained in:
Joachim Nilsson
2010-08-05 01:08:30 +02:00
parent 6a8ecd7e2e
commit 0a75b182b1
3 changed files with 62 additions and 19 deletions

View File

@@ -30,14 +30,14 @@ typedef enum {
typedef char* (*rl_complete_func_t)(char*, int*);
typedef int (*rl_list_possib_func_t)(char*, char***);
typedef el_status_t (*el_keymap_func_t)(void);
typedef int (*rl_hook_func_t) (void);
typedef int (*rl_getc_func_t)(void);
typedef void (*rl_voidfunc_t)(void);
typedef void (*rl_vintfunc_t)(int);
/* Display 8-bit chars "as-is" or as `M-x'? Toggle with M-m. (Default:0 - "as-is") */
extern int rl_meta_chars;
/* Use these functions to set custom command/file completion, see cli.c for example usage. */
rl_complete_func_t rl_set_complete_func(rl_complete_func_t func);
rl_list_possib_func_t rl_set_list_possib_func(rl_list_possib_func_t func);
/* Editline specific functions. */
void el_bind_key_in_metamap(char c, el_keymap_func_t func);
@@ -59,4 +59,12 @@ extern void add_history(const char *line);
extern int read_history(const char *filename);
extern int write_history(const char *filename);
rl_complete_func_t rl_set_complete_func(rl_complete_func_t func);
rl_list_possib_func_t rl_set_list_possib_func(rl_list_possib_func_t func);
void rl_prep_terminal(int meta_flag);
void rl_deprep_terminal(void);
int rl_getc(void);
#endif /* __EDITLINE_H__ */