diff options
Diffstat (limited to 'gdb/tui')
-rw-r--r-- | gdb/tui/tui-interp.c | 2 | ||||
-rw-r--r-- | gdb/tui/tui-io.c | 4 | ||||
-rw-r--r-- | gdb/tui/tui.c | 11 | ||||
-rw-r--r-- | gdb/tui/tui.h | 6 |
4 files changed, 18 insertions, 5 deletions
diff --git a/gdb/tui/tui-interp.c b/gdb/tui/tui-interp.c index 10118af..44a1396 100644 --- a/gdb/tui/tui-interp.c +++ b/gdb/tui/tui-interp.c @@ -244,7 +244,7 @@ tui_interp::init (bool top_level) tui_initialize_io (); tui_initialize_win (); if (gdb_stdout->isatty ()) - tui_initialize_readline (); + tui_ensure_readline_initialized (); } void diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c index e7a8ac7..277b560 100644 --- a/gdb/tui/tui-io.c +++ b/gdb/tui/tui-io.c @@ -746,6 +746,10 @@ tui_setup_io (int mode) if (mode) { + /* Ensure that readline has been initialized before saving any + of its variables. */ + tui_ensure_readline_initialized (); + /* Redirect readline to TUI. */ tui_old_rl_redisplay_function = rl_redisplay_function; tui_old_rl_deprep_terminal = rl_deprep_term_function; diff --git a/gdb/tui/tui.c b/gdb/tui/tui.c index ac435d1..828e42b 100644 --- a/gdb/tui/tui.c +++ b/gdb/tui/tui.c @@ -268,8 +268,14 @@ tui_set_key_mode (enum tui_key_mode mode) /* Initialize readline and configure the keymap for the switching key shortcut. */ void -tui_initialize_readline (void) +tui_ensure_readline_initialized () { + static bool initialized; + + if (initialized) + return; + initialized = true; + int i; Keymap tui_ctlx_keymap; @@ -325,6 +331,9 @@ tui_initialize_readline (void) rl_bind_key_in_map ('q', tui_rl_next_keymap, tui_keymap); rl_bind_key_in_map ('s', tui_rl_next_keymap, emacs_ctlx_keymap); rl_bind_key_in_map ('s', tui_rl_next_keymap, tui_ctlx_keymap); + + /* Initialize readline after the above. */ + rl_initialize (); } /* Return the TERM variable from the environment, or "<unset>" diff --git a/gdb/tui/tui.h b/gdb/tui/tui.h index 816b1e9..79525ba 100644 --- a/gdb/tui/tui.h +++ b/gdb/tui/tui.h @@ -49,9 +49,9 @@ extern bool tui_is_window_visible (enum tui_win_type type); extern bool tui_get_command_dimension (unsigned int *width, unsigned int *height); -/* Initialize readline and configure the keymap for the switching - key shortcut. */ -extern void tui_initialize_readline (void); +/* Initialize readline and configure the keymap for the switching key + shortcut. May be called more than once without issue. */ +extern void tui_ensure_readline_initialized (); /* Enter in the tui mode (curses). */ extern void tui_enable (void); |