diff options
author | Stephane Carrez <stcarrez@nerim.fr> | 2001-07-21 20:49:56 +0000 |
---|---|---|
committer | Stephane Carrez <stcarrez@nerim.fr> | 2001-07-21 20:49:56 +0000 |
commit | 377c38eacc2d289a9863d374b9fa8bf6741f304d (patch) | |
tree | d827954a57ec4f856ace6232b5e223a2aad1640e /gdb/tui/tui.c | |
parent | 209fd6672950a2624d3c25cfdc2c07c5575c50a6 (diff) | |
download | gdb-377c38eacc2d289a9863d374b9fa8bf6741f304d.zip gdb-377c38eacc2d289a9863d374b9fa8bf6741f304d.tar.gz gdb-377c38eacc2d289a9863d374b9fa8bf6741f304d.tar.bz2 |
* tui.c (tui_change_windows): New function.
(tui_delete_other_windows): New function.
(tui_initialize_readline): Bind them to C-X 1 and C-X 2.
(tui_enable): Enable the keypad; call tui_update_variables.
(strcat_to_buf_with_fmt): Remove.
Diffstat (limited to 'gdb/tui/tui.c')
-rw-r--r-- | gdb/tui/tui.c | 112 |
1 files changed, 93 insertions, 19 deletions
diff --git a/gdb/tui/tui.c b/gdb/tui/tui.c index ae22249..370afb4 100644 --- a/gdb/tui/tui.c +++ b/gdb/tui/tui.c @@ -37,6 +37,7 @@ #include "tuiLayout.h" #include "tuiIO.h" #include "tuiRegs.h" +#include "tuiStack.h" #include "tuiWin.h" #include "readline/readline.h" #include "target.h" @@ -76,6 +77,91 @@ tui_switch_mode (void) return 0; } +/* Change the TUI layout to show a next layout. + This function is bound to CTRL-X 2. It is intended to provide + a functionality close to the Emacs split-window command. We always + show two windows (src+asm), (src+regs) or (asm+regs). */ +static int +tui_change_windows (void) +{ + if (!tui_active) + tui_switch_mode (); + + if (tui_active) + { + TuiLayoutType new_layout; + TuiRegisterDisplayType regs_type = TUI_UNDEFINED_REGS; + + new_layout = currentLayout (); + + /* Select a new layout to have a rolling layout behavior + with always two windows (except when undefined). */ + switch (new_layout) + { + case SRC_COMMAND: + new_layout = SRC_DISASSEM_COMMAND; + break; + + case DISASSEM_COMMAND: + new_layout = SRC_DISASSEM_COMMAND; + break; + + case SRC_DATA_COMMAND: + new_layout = SRC_DISASSEM_COMMAND; + break; + + case SRC_DISASSEM_COMMAND: + new_layout = DISASSEM_DATA_COMMAND; + break; + + case DISASSEM_DATA_COMMAND: + new_layout = SRC_DATA_COMMAND; + break; + + default: + new_layout = SRC_COMMAND; + break; + } + tuiSetLayout (new_layout, regs_type); + } + return 0; +} + + +/* Delete the second TUI window to only show one. */ +static int +tui_delete_other_windows (void) +{ + if (!tui_active) + tui_switch_mode (); + + if (tui_active) + { + TuiLayoutType new_layout; + TuiRegisterDisplayType regs_type = TUI_UNDEFINED_REGS; + + new_layout = currentLayout (); + + /* Kill one window. */ + switch (new_layout) + { + case SRC_COMMAND: + case SRC_DATA_COMMAND: + case SRC_DISASSEM_COMMAND: + default: + new_layout = SRC_COMMAND; + break; + + case DISASSEM_COMMAND: + case DISASSEM_DATA_COMMAND: + new_layout = DISASSEM_COMMAND; + break; + } + tuiSetLayout (new_layout, regs_type); + } + return 0; +} + /* Initialize readline and configure the keymap for the switching key shortcut. */ void @@ -87,6 +173,8 @@ tui_initialize_readline () rl_bind_key_in_map ('a', tui_switch_mode, emacs_ctlx_keymap); rl_bind_key_in_map ('A', tui_switch_mode, emacs_ctlx_keymap); rl_bind_key_in_map (CTRL ('A'), tui_switch_mode, emacs_ctlx_keymap); + rl_bind_key_in_map ('1', tui_delete_other_windows, emacs_ctlx_keymap); + rl_bind_key_in_map ('2', tui_change_windows, emacs_ctlx_keymap); } /* Enter in the tui mode (curses). @@ -108,8 +196,8 @@ tui_enable (void) w = initscr (); - cbreak(); - noecho(); + cbreak (); + noecho (); /*timeout (1);*/ nodelay(w, FALSE); nl(); @@ -122,6 +210,7 @@ tui_enable (void) tuiSetLocatorContent (0); showLayout (SRC_COMMAND); tuiSetWinFocusTo (srcWin); + keypad (cmdWin->generic.handle, TRUE); wrefresh (cmdWin->generic.handle); tui_finish_init = 0; } @@ -136,6 +225,8 @@ tui_enable (void) /* Install the TUI specific hooks. */ tui_install_hooks (); + tui_update_variables (); + tui_setup_io (1); tui_version = 1; @@ -213,23 +304,6 @@ strcat_to_buf (char *buf, int buflen, char *itemToAdd) else strncat (buf, itemToAdd, (buflen - strlen (buf))); } - - return; -} /* strcat_to_buf */ - -/* VARARGS */ -void -strcat_to_buf_with_fmt (char *buf, int bufLen, char *format, ...) -{ - char *linebuffer; - struct cleanup *old_cleanups; - va_list args; - va_start (args, format); - vasprintf (&linebuffer, format, args); - old_cleanups = make_cleanup (xfree, linebuffer); - strcat_to_buf (buf, bufLen, linebuffer); - do_cleanups (old_cleanups); - va_end (args); } #if 0 |