diff options
Diffstat (limited to 'lib/readline/terminal.c')
-rw-r--r-- | lib/readline/terminal.c | 94 |
1 files changed, 72 insertions, 22 deletions
diff --git a/lib/readline/terminal.c b/lib/readline/terminal.c index 4d2268c0..f3f5b6c4 100644 --- a/lib/readline/terminal.c +++ b/lib/readline/terminal.c @@ -66,6 +66,9 @@ #include "rlshell.h" #include "xmalloc.h" +#define CUSTOM_REDISPLAY_FUNC() (rl_redisplay_function != rl_redisplay) +#define CUSTOM_INPUT_FUNC() (rl_getc_function != rl_getc) + /* **************************************************************** */ /* */ /* Terminal and Termcap */ @@ -140,6 +143,16 @@ static char *_rl_term_ke; /* The key sequences sent by the Home and End keys, if any. */ static char *_rl_term_kh; static char *_rl_term_kH; +static char *_rl_term_at7; /* @7 */ + +/* Insert key */ +static char *_rl_term_kI; + +/* Cursor control */ +static char *_rl_term_vs; /* very visible */ +static char *_rl_term_ve; /* normal */ + +static void bind_termcap_arrow_keys PARAMS((Keymap)); /* Variables that hold the screen dimensions, used by the display code. */ int _rl_screenwidth, _rl_screenheight, _rl_screenchars; @@ -274,7 +287,10 @@ rl_resize_terminal () if (readline_echoing_p) { _rl_get_screen_size (fileno (rl_instream), 1); - _rl_redisplay_after_sigwinch (); + if (CUSTOM_REDISPLAY_FUNC ()) + rl_forced_update_display (); + else + _rl_redisplay_after_sigwinch (); } } @@ -287,6 +303,7 @@ struct _tc_string { search algorithm to something smarter. */ static struct _tc_string tc_strings[] = { + { "@7", &_rl_term_at7 }, { "DC", &_rl_term_DC }, { "IC", &_rl_term_IC }, { "ce", &_rl_term_clreol }, @@ -296,14 +313,15 @@ static struct _tc_string tc_strings[] = { "ei", &_rl_term_ei }, { "ic", &_rl_term_ic }, { "im", &_rl_term_im }, + { "kH", &_rl_term_kH }, /* home down ?? */ + { "kI", &_rl_term_kI }, /* insert */ { "kd", &_rl_term_kd }, + { "ke", &_rl_term_ke }, /* end keypad mode */ { "kh", &_rl_term_kh }, /* home */ - { "kH", &_rl_term_kH }, /* end */ { "kl", &_rl_term_kl }, { "kr", &_rl_term_kr }, + { "ks", &_rl_term_ks }, /* start keypad mode */ { "ku", &_rl_term_ku }, - { "ks", &_rl_term_ks }, - { "ke", &_rl_term_ke }, { "le", &_rl_term_backspace }, { "mm", &_rl_term_mm }, { "mo", &_rl_term_mo }, @@ -313,6 +331,8 @@ static struct _tc_string tc_strings[] = { "pc", &_rl_term_pc }, { "up", &_rl_term_up }, { "vb", &_rl_visible_bell }, + { "vs", &_rl_term_vs }, + { "ve", &_rl_term_ve }, }; #define NUM_TC_STRINGS (sizeof (tc_strings) / sizeof (struct _tc_string)) @@ -336,9 +356,6 @@ get_term_capabilities (bp) tcap_initialized = 1; } -#define CUSTOM_REDISPLAY_FUNC() (rl_redisplay_function != rl_redisplay) -#define CUSTOM_INPUT_FUNC() (rl_getc_function != rl_getc) - int _rl_init_terminal_io (terminal_name) const char *terminal_name; @@ -346,7 +363,6 @@ _rl_init_terminal_io (terminal_name) const char *term; char *buffer; int tty, tgetent_ret; - Keymap xkeymap; term = terminal_name ? terminal_name : sh_get_env_value ("TERM"); _rl_term_clrpag = _rl_term_cr = _rl_term_clreol = (char *)NULL; @@ -404,7 +420,10 @@ _rl_init_terminal_io (terminal_name) _rl_term_im = _rl_term_ei = _rl_term_ic = _rl_term_IC = (char *)NULL; _rl_term_up = _rl_term_dc = _rl_term_DC = _rl_visible_bell = (char *)NULL; _rl_term_ku = _rl_term_kd = _rl_term_kl = _rl_term_kr = (char *)NULL; + _rl_term_kh = _rl_term_kH = _rl_term_kI = (char *)NULL; + _rl_term_ks = _rl_term_ke = _rl_term_at7 = (char *)NULL; _rl_term_mm = _rl_term_mo = (char *)NULL; + _rl_term_ve = _rl_term_vs = (char *)NULL; #if defined (HACK_TERMCAP_MOTION) term_forward_char = (char *)NULL; #endif @@ -449,31 +468,36 @@ _rl_init_terminal_io (terminal_name) /* Attempt to find and bind the arrow keys. Do not override already bound keys in an overzealous attempt, however. */ - xkeymap = _rl_keymap; - _rl_keymap = emacs_standard_keymap; - _rl_bind_if_unbound (_rl_term_ku, rl_get_previous_history); - _rl_bind_if_unbound (_rl_term_kd, rl_get_next_history); - _rl_bind_if_unbound (_rl_term_kr, rl_forward); - _rl_bind_if_unbound (_rl_term_kl, rl_backward); - - _rl_bind_if_unbound (_rl_term_kh, rl_beg_of_line); /* Home */ - _rl_bind_if_unbound (_rl_term_kH, rl_end_of_line); /* End */ + bind_termcap_arrow_keys (emacs_standard_keymap); #if defined (VI_MODE) - _rl_keymap = vi_movement_keymap; + bind_termcap_arrow_keys (vi_movement_keymap); + bind_termcap_arrow_keys (vi_insertion_keymap); +#endif /* VI_MODE */ + + return 0; +} + +/* Bind the arrow key sequences from the termcap description in MAP. */ +static void +bind_termcap_arrow_keys (map) + Keymap map; +{ + Keymap xkeymap; + + xkeymap = _rl_keymap; + _rl_keymap = map; + _rl_bind_if_unbound (_rl_term_ku, rl_get_previous_history); _rl_bind_if_unbound (_rl_term_kd, rl_get_next_history); _rl_bind_if_unbound (_rl_term_kr, rl_forward); _rl_bind_if_unbound (_rl_term_kl, rl_backward); _rl_bind_if_unbound (_rl_term_kh, rl_beg_of_line); /* Home */ - _rl_bind_if_unbound (_rl_term_kH, rl_end_of_line); /* End */ -#endif /* VI_MODE */ + _rl_bind_if_unbound (_rl_term_at7, rl_end_of_line); /* End */ _rl_keymap = xkeymap; - - return 0; } char * @@ -610,3 +634,29 @@ _rl_control_keypad (on) tputs (_rl_term_ke, 1, _rl_output_character_function); #endif } + +/* **************************************************************** */ +/* */ +/* Controlling the Cursor */ +/* */ +/* **************************************************************** */ + +/* Set the cursor appropriately depending on IM, which is one of the + insert modes (insert or overwrite). Insert mode gets the normal + cursor. Overwrite mode gets a very visible cursor. Only does + anything if we have both capabilities. */ +void +_rl_set_cursor (im, force) + int im, force; +{ + if (_rl_term_ve && _rl_term_vs) + { + if (force || im != rl_insert_mode) + { + if (im == RL_IM_OVERWRITE) + tputs (_rl_term_vs, 1, _rl_output_character_function); + else + tputs (_rl_term_ve, 1, _rl_output_character_function); + } + } +} |