From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephane Carrez To: gdb-patches@sources.redhat.com Subject: [PATCH]: Add configuration variables to TUI Date: Sat, 21 Jul 2001 12:45:00 -0000 Message-id: <3B59DCEB.46EE93C1@worldnet.fr> X-SW-Source: 2001-07/msg00548.html Hi! The following patch introduces the following configuration variables for TUI: set tui-active-border-mode -- Set the attribute mode to use for the active TUI window border set tui-border-kind -- Set the kind of border for TUI windows set tui-border-mode -- Set the attribute mode to use for the TUI window borders It allows to configure to use ascii (+ - |) or acs (graphics) to display borders. I've committed this patch (documentation is separate). 2001-07-21 Stephane Carrez * tuiGeneralWin.c (boxWin): Use the tui configuration variables. * tuiWin.h: Declare the new variables. * tuiWin.c (_initialize_tuiWin): Create TUI configuration variables. (tui_update_variables): New function. (translate): New function. (tui_border_kind_enums, tui_border_mode_enums): New tables. (tui_border_mode_translate): New table. (tui_border_kind_translate_*): New tables. (tui_active_border_mode): New variables. (tui_border_*): New variables. Index: tuiGeneralWin.c =================================================================== RCS file: /cvs/src/src/gdb/tui/tuiGeneralWin.c,v retrieving revision 1.6 diff -u -p -r1.6 tuiGeneralWin.c --- tuiGeneralWin.c 2001/07/16 22:13:38 1.6 +++ tuiGeneralWin.c 2001/07/21 19:42:14 @@ -23,8 +23,8 @@ #include "tui.h" #include "tuiData.h" #include "tuiGeneralWin.h" +#include "tuiWin.h" - /* ** local support functions */ @@ -84,26 +84,29 @@ tuiDelwin (WINDOW * window) } /* tuiDelwin */ -/* - ** boxWin(). - */ +/* Draw a border arround the window. */ void boxWin (TuiGenWinInfoPtr winInfo, int highlightFlag) { - if (m_genWinPtrNotNull (winInfo) && winInfo->handle != (WINDOW *) NULL) + if (winInfo && winInfo->handle) { + WINDOW *win; + int attrs; + + win = winInfo->handle; if (highlightFlag == HILITE) - box (winInfo->handle, '|', '-'); + attrs = tui_active_border_attrs; else - { -/* wattron(winInfo->handle, A_DIM); */ - box (winInfo->handle, ':', '.'); -/* wattroff(winInfo->handle, A_DIM); */ - } - } + attrs = tui_border_attrs; - return; -} /* boxWin */ + wattron (win, attrs); + wborder (win, tui_border_vline, tui_border_vline, + tui_border_hline, tui_border_hline, + tui_border_ulcorner, tui_border_urcorner, + tui_border_llcorner, tui_border_lrcorner); + wattroff (win, attrs); + } +} /* Index: tuiWin.h =================================================================== RCS file: /cvs/src/src/gdb/tui/tuiWin.h,v retrieving revision 1.4 diff -u -p -r1.4 tuiWin.h --- tuiWin.h 2001/07/18 22:03:22 1.4 +++ tuiWin.h 2001/07/21 19:42:16 @@ -43,5 +43,16 @@ extern void tuiResizeAll (void); extern void tuiRefreshAll (void); extern void tuiSigwinchHandler (int); +extern chtype tui_border_ulcorner; +extern chtype tui_border_urcorner; +extern chtype tui_border_lrcorner; +extern chtype tui_border_llcorner; +extern chtype tui_border_vline; +extern chtype tui_border_hline; +extern int tui_border_attrs; +extern int tui_active_border_attrs; + +extern int tui_update_variables (); + #endif /*_TUI_WIN_H*/ Index: tuiWin.c =================================================================== RCS file: /cvs/src/src/gdb/tui/tuiWin.c,v retrieving revision 1.12 diff -u -p -r1.12 tuiWin.c --- tuiWin.c 2001/07/20 23:06:48 1.12 +++ tuiWin.c 2001/07/21 19:42:18 @@ -79,6 +79,185 @@ static void _parseScrollingArgs (char *, ** PUBLIC FUNCTIONS ***************************************/ +/* Possible values for tui-border-kind variable. */ +static const char *tui_border_kind_enums[] = { + "space", + "ascii", + "acs", + NULL +}; + +/* Possible values for tui-border-mode and tui-active-border-mode. */ +static const char *tui_border_mode_enums[] = { + "normal", + "standout", + "reverse", + "half", + "half-standout", + "bold", + "bold-standout", + NULL +}; + +struct tui_translate +{ + const char *name; + int value; +}; + +/* Translation table for border-mode variables. + The list of values must be terminated by a NULL. + After the NULL value, an entry defines the default. */ +struct tui_translate tui_border_mode_translate[] = { + { "normal", A_NORMAL }, + { "standout", A_STANDOUT }, + { "reverse", A_REVERSE }, + { "half", A_DIM }, + { "half-standout", A_DIM | A_STANDOUT }, + { "bold", A_BOLD }, + { "bold-standout", A_BOLD | A_STANDOUT }, + { 0, 0 }, + { "normal", A_NORMAL } +}; + +/* Translation tables for border-kind, one for each border + character (see wborder, border curses operations). + -1 is used to indicate the ACS because ACS characters + are determined at run time by curses (depends on terminal). */ +struct tui_translate tui_border_kind_translate_vline[] = { + { "space", ' ' }, + { "ascii", '|' }, + { "acs", -1 }, + { 0, 0 }, + { "ascii", '|' } +}; + +struct tui_translate tui_border_kind_translate_hline[] = { + { "space", ' ' }, + { "ascii", '-' }, + { "acs", -1 }, + { 0, 0 }, + { "ascii", '-' } +}; + +struct tui_translate tui_border_kind_translate_ulcorner[] = { + { "space", ' ' }, + { "ascii", '+' }, + { "acs", -1 }, + { 0, 0 }, + { "ascii", '+' } +}; + +struct tui_translate tui_border_kind_translate_urcorner[] = { + { "space", ' ' }, + { "ascii", '+' }, + { "acs", -1 }, + { 0, 0 }, + { "ascii", '+' } +}; + +struct tui_translate tui_border_kind_translate_llcorner[] = { + { "space", ' ' }, + { "ascii", '+' }, + { "acs", -1 }, + { 0, 0 }, + { "ascii", '+' } +}; + +struct tui_translate tui_border_kind_translate_lrcorner[] = { + { "space", ' ' }, + { "ascii", '+' }, + { "acs", -1 }, + { 0, 0 }, + { "ascii", '+' } +}; + + +/* Tui configuration variables controlled with set/show command. */ +const char *tui_active_border_mode = "bold-standout"; +const char *tui_border_mode = "normal"; +const char *tui_border_kind = "acs"; + +/* Tui internal configuration variables. These variables are + updated by tui_update_variables to reflect the tui configuration + variables. */ +chtype tui_border_vline; +chtype tui_border_hline; +chtype tui_border_ulcorner; +chtype tui_border_urcorner; +chtype tui_border_llcorner; +chtype tui_border_lrcorner; + +int tui_border_attrs; +int tui_active_border_attrs; + +/* Identify the item in the translation table. + When the item is not recognized, use the default entry. */ +static struct tui_translate * +translate (const char *name, struct tui_translate *table) +{ + while (table->name) + { + if (name && strcmp (table->name, name) == 0) + return table; + table++; + } + + /* Not found, return default entry. */ + table++; + return table; +} + +/* Update the tui internal configuration according to gdb settings. + Returns 1 if the configuration has changed and the screen should + be redrawn. */ +int +tui_update_variables () +{ + int need_redraw = 0; + struct tui_translate *entry; + + entry = translate (tui_border_mode, tui_border_mode_translate); + if (tui_border_attrs != entry->value) + { + tui_border_attrs = entry->value; + need_redraw = 1; + } + entry = translate (tui_active_border_mode, tui_border_mode_translate); + if (tui_active_border_attrs != entry->value) + { + tui_active_border_attrs = entry->value; + need_redraw = 1; + } + + /* If one corner changes, all characters are changed. + Only check the first one. The ACS characters are determined at + run time by curses terminal management. */ + entry = translate (tui_border_kind, tui_border_kind_translate_lrcorner); + if (tui_border_lrcorner != (chtype) entry->value) + { + tui_border_lrcorner = (entry->value < 0) ? ACS_LRCORNER : entry->value; + need_redraw = 1; + } + entry = translate (tui_border_kind, tui_border_kind_translate_llcorner); + tui_border_llcorner = (entry->value < 0) ? ACS_LLCORNER : entry->value; + + entry = translate (tui_border_kind, tui_border_kind_translate_ulcorner); + tui_border_ulcorner = (entry->value < 0) ? ACS_ULCORNER : entry->value; + + entry = translate (tui_border_kind, tui_border_kind_translate_urcorner); + tui_border_urcorner = (entry->value < 0) ? ACS_URCORNER : entry->value; + + entry = translate (tui_border_kind, tui_border_kind_translate_hline); + tui_border_hline = (entry->value < 0) ? ACS_HLINE : entry->value; + + entry = translate (tui_border_kind, tui_border_kind_translate_vline); + tui_border_vline = (entry->value < 0) ? ACS_VLINE : entry->value; + + return need_redraw; +} + + /* ** _initialize_tuiWin(). ** Function to initialize gdb commands, for tui window manipulation. @@ -86,6 +265,8 @@ static void _parseScrollingArgs (char *, void _initialize_tuiWin (void) { + struct cmd_list_element *c; + /* Define the classes of commands. They will appear in the help list in the reverse of this order. */ @@ -132,6 +313,48 @@ cmd : the command window\n"); add_com ("w", class_xdb, _tuiXDBsetWinHeight_command, "XDB compatibility command for setting the height of a command window.\n\ Usage: w <#lines>\n"); + + /* Define the tui control variables. */ + c = add_set_enum_cmd + ("tui-border-kind", class_tui, + tui_border_kind_enums, (char*) &tui_border_kind, + "Set the kind of border for TUI windows.\n" + "This variable controls the border of TUI windows:\n" + "space use a white space\n" + "ascii use ascii characters + - | for the border\n" + "acs use the Alternate Character Set\n", + &setlist); + add_show_from_set (c, &showlist); + + c = add_set_enum_cmd + ("tui-border-mode", class_tui, + tui_border_mode_enums, (char*) &tui_border_mode, + "Set the attribute mode to use for the TUI window borders.\n" + "This variable controls the attributes to use for the window borders:\n" + "normal normal display\n" + "standout use highlight mode of terminal\n" + "reverse use reverse video mode\n" + "half use half bright\n" + "half-standout use half bright and standout mode\n" + "bold use extra bright or bold\n" + "bold-standout use extra bright or bold with standout mode\n", + &setlist); + add_show_from_set (c, &showlist); + + c = add_set_enum_cmd + ("tui-active-border-mode", class_tui, + tui_border_mode_enums, (char*) &tui_active_border_mode, + "Set the attribute mode to use for the active TUI window border.\n" + "This variable controls the attributes to use for the active window border:\n" + "normal normal display\n" + "standout use highlight mode of terminal\n" + "reverse use reverse video mode\n" + "half use half bright\n" + "half-standout use half bright and standout mode\n" + "bold use extra bright or bold\n" + "bold-standout use extra bright or bold with standout mode\n", + &setlist); + add_show_from_set (c, &showlist); } >From Stephane.Carrez@worldnet.fr Sat Jul 21 12:47:00 2001 From: Stephane Carrez To: gdb-patches@sources.redhat.com Subject: [PATCH]: Fix tui register window Date: Sat, 21 Jul 2001 12:47:00 -0000 Message-id: <3B59DD75.20477113@worldnet.fr> X-SW-Source: 2001-07/msg00549.html Content-length: 1959 Hi! I've committed the following patch that fixes the display in the TUI register window: - the register formatting uses 16 characters to print the register name the effect is that the ` ' string is too big to fit in the register window and it is truncated. The patch reduces to 8 chars the name of register (until some best solution is found). - it's necessary to touch the window when the register has changed. Stephane 2001-07-21 Stephane Carrez * tuiRegs.c (tuiDisplayRegistersFrom): Call touchwin. (_tuiRegisterFormat): Reduce size of format result. Index: tuiRegs.c =================================================================== RCS file: /cvs/src/src/gdb/tui/tuiRegs.c,v retrieving revision 1.9 diff -u -p -r1.9 tuiRegs.c --- tuiRegs.c 2001/07/19 22:47:46 1.9 +++ tuiRegs.c 2001/07/21 19:46:08 @@ -347,6 +347,8 @@ tuiDisplayRegistersFrom (int startElemen makeWindow (dataItemWin, DONT_BOX_WINDOW); scrollok (dataItemWin->handle, FALSE); } + touchwin (dataItemWin->handle); + /* ** Get the printable representation of the register ** and display it @@ -603,6 +605,7 @@ _tuiRegisterFormat (char *buf, int bufLe char *name; struct cleanup *cleanups; char *p; + int pos; name = REGISTER_NAME (regNum); if (name == 0) @@ -619,7 +622,23 @@ _tuiRegisterFormat (char *buf, int bufLe do_registers_info (regNum, 0); /* Save formatted output in the buffer. */ - strncpy (buf, tui_file_get_strbuf (stream), bufLen); + p = tui_file_get_strbuf (stream); + pos = 0; + while (*p && *p == *name++ && bufLen) + { + *buf++ = *p++; + bufLen--; + pos++; + } + while (*p == ' ') + p++; + while (pos < 8 && bufLen) + { + *buf++ = ' '; + bufLen--; + pos++; + } + strncpy (buf, p, bufLen); /* Remove the possible \n. */ p = strchr (buf, '\n'); >From Stephane.Carrez@worldnet.fr Sat Jul 21 12:51:00 2001 From: Stephane Carrez To: gdb-patches@sources.redhat.com Subject: [RFA]: TUI documentation Date: Sat, 21 Jul 2001 12:51:00 -0000 Message-id: <3B59DE3F.851F5879@worldnet.fr> X-SW-Source: 2001-07/msg00550.html Content-length: 9438 Hi! The following patch adds a new chapter to gdb documentation to describe the TUI. It also document the -tui option. I have verified the patch with: make gdb.dvi make gdb.info xdvi/info Can you approve this patch? Stephane 2001-07-21 Stephane Carrez * gdb.texinfo (TUI): New chapter, document the TUI. (Mode Options): Document the -tui option. Index: gdb.texinfo =================================================================== RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v retrieving revision 1.44 diff -u -p -r1.44 gdb.texinfo --- gdb.texinfo 2001/07/06 04:07:29 1.44 +++ gdb.texinfo 2001/07/21 19:49:50 @@ -137,6 +137,7 @@ Copyright (C) 1988-2001 Free Software Fo * Configurations:: Configuration-specific information * Controlling GDB:: Controlling @value{GDBN} * Sequences:: Canned sequences of commands +* TUI:: @value{GDBN} Text User Interface * Emacs:: Using @value{GDBN} under @sc{gnu} Emacs * Annotations:: @value{GDBN}'s annotation interface. * GDB/MI:: @value{GDBN}'s Machine Interface. @@ -1026,13 +1027,14 @@ Run using @var{device} for your program' @c FIXME: kingdon thinks there is more to -tty. Investigate. @c resolve the situation of these eventually -@c @item -tui -@c @cindex @code{--tui} -@c Use a Terminal User Interface. For information, use your Web browser to -@c read the file @file{TUI.html}, which is usually installed in the -@c directory @code{/opt/langtools/wdb/doc} on HP-UX systems. Do not use -@c this option if you run @value{GDBN} from Emacs (see @pxref{Emacs, ,Using -@c @value{GDBN} under @sc{gnu} Emacs}). +@item -tui +@cindex @code{--tui} +Activate the Terminal User Interface when starting. +The Terminal User Interface manages several text windows on the terminal, +showing source, assembly, registers and @value{GDBN} command outputs +(@pxref{TUI, ,@value{GDBN} Text User Interface}). +Do not use this option if you run @value{GDBN} from Emacs +(@pxref{Emacs, ,Using @value{GDBN} under @sc{gnu} Emacs}). @c @item -xdb @c @cindex @code{--xdb} @@ -12973,6 +12975,244 @@ printf "foo, bar-foo = 0x%x, 0x%x\n", fo The only backslash-escape sequences that you can use in the format string are the simple ones that consist of backslash followed by a letter. +@end table + +@set TUI TUI +@node TUI +@chapter @value{GDBN} Text User Interface +@cindex Tui + +@menu +* TUI Overview:: TUI overview +* TUI Keys:: TUI key bindings +* TUI Commands:: TUI specific commands +* TUI Configuration:: TUI configuration variables +@end menu + +The @value{GDBN} Text User Interface, @value{TUI} in short, +is a terminal interface which uses the @code{curses} library +to show the source file, the assembly output, the program registers +and @value{GDBN} commands in separate text windows. +The @value{TUI} is available only when @value{GDBN} is configured +with the @code{--enable-tui} configure option. + +@node TUI Overview +@section TUI overview + +The @value{TUI} has two display modes that can be switched while +@value{GDBN} runs: + +@itemize @bullet +@item +A curses (or @value{TUI}) mode in which it displays several text +windows on the terminal. + +@item +A standard mode which corresponds to the @value{GDBN} configured without +the @value{TUI}. +@end itemize + +In the @value{TUI} mode, @value{GDBN} can display several text window +on the terminal: + +@table @emph +@item command +This window is the @value{GDBN} command window with the @value{GDBN} +prompt and the @value{GDBN} outputs. The @value{GDBN} input is still +managed using readline but through the @value{TUI}. The @emph{command} +window is always visible. + +@item source +The source window shows the source file of the program. The current +line as well as active breakpoints are displayed in this window. +The current program position is shown with the @samp{>} marker and +active breakpoints are shown with @samp{*} markers. + +@item assembly +The assembly window shows the disassembly output of the program. + +@item register +This window shows the processor registers. It detects when +a register is changed and when this is the case, registers that have +changed are highlighted. + +@end table + +The source, assembly and register windows are attached to the thread +and the frame position. They are updated when the current thread +changes, when the frame changes or when the program counter changes. +These three windows are aranged by the @value{TUI} according to several +layouts. The layout defines which of these three windows are visible. + +@node TUI Keys +@section TUI Key Bindings + +The @value{TUI} installs several key bindings in the readline keymaps +(@pxref{Command Line Editing}). +They allow to leave or enter in the @value{TUI} mode or they operate +directly on the @value{TUI} layout and windows. The following key bindings +are installed for both @value{TUI} mode and the @value{GDBN} standard mode. + +@table @key +@item C-x C-a +@item C-x a +@item C-x A +Enter or leave the @value{TUI} mode. When the @value{TUI} mode is left, +the curses window management is left and @value{GDBN} operates using +its standard mode writing on the terminal directly. When the @value{TUI} +mode is entered, the control is given back to the curses windows. +The screen is then refreshed. + +@item C-x 1 +Use a @value{TUI} layout with only one window. The layout will +either be @samp{source} or @samp{assembly}. When the @value{TUI} mode +is not active, it will switch to the @value{TUI} mode. + +Think of this key binding as the Emacs @key{C-x 1} binding. + +@item C-x 2 +Use a @value{TUI} layout with at least two windows. When the current +layout shows already two windows, a next layout with two windows is used. +When a new layout is chosen, there will always be a common window between +the previous layout and the new one. + +Think of it as the Emacs @key{C-x 2} binding. + +@end table + +The following key bindings are handled only by the @value{TUI} mode: + +@table @key +@item PgUp +Scroll the active window one page up. + +@item PgDn +Scroll the active window one page down. + +@item Up +Scroll the active window one line up. + +@item Down +Scroll the active window one line down. + +@item Left +Scroll the active window one column left. + +@item Right +Scroll the active window one column right. + +@item C-L +Refresh the screen. + +@end table + +In the @value{TUI} mode, the arrow keys are used by the active window +for scrolling. This means they are not available for readline. It is +necessary to use other readline key bindings such as @key{C-p}, @key{C-n}, +@key{C-b} and @key{C-f}. + +@node TUI Commands +@section TUI specific commands + +The @value{TUI} has specific commands to control the text windows. +These commands are always available, that is they do not depend on +the current terminal mode in which @value{GDBN} runs. When @value{GDBN} +is in the standard mode, using these commands will automatically switch +in the @value{TUI} mode. + +@table @code +@item layout @var{next | prev | } +Change the current TUI layout. + +@item layout next +Display the next layout. + +@item layout prev +Display the previous layout. + +@item layout src +Display the source window only. + +@item layout asm +Display the assembly window only. + +@item layout split +Display the source and assembly window. + +@item regs +Display the register window together with the source or assembly window. + +@item focus @var{next | prev | } +Set the focus to the named window. +This command allows to change the active window so that scrolling keys +can be affected to another window. + +@item refresh +Refresh the screen. This is similar to using @key{C-L} key. + +@item update +Update the source window and the current execution point. + +@item winheight @var{name} +@var{count} +@itemx winheight @var{name} -@var{count} +Change the height of a window. + +@end table + +@node TUI Configuration +@section TUI configuration variables + +The @value{TUI} has several configuration variables that control the +appearance of windows on the terminal. + +@table @code +@item set tui-border-kind @var{kind} +Select the border appearance for the source, assembly and register windows. +The possible values are the following: +@table @code +@item space +Use a space character to draw the border. + +@item ascii +Use ascii characters + - and | to draw the border. + +@item acs +Use the Alternate Character Set to draw the border. + +@end table + +@item set tui-active-border-mode @var{mode} +Select the attributes to display the border of the active window. +The possible values are @code{normal}, @code{standout}, @code{reverse}, +@code{half}, @code{half-standout}, @code{bold} and @code{bold-standout}. + +@item set tui-border-mode @var{mode} +Select the attributes to display the border of other windows. +The @var{mode} can be one of the following: +@table @code +@item normal +Use normal attributes to display the border. + +@item standout +Use standout mode. + +@item reverse +Use reverse video mode. + +@item half +Use half bright mode. + +@item half-standout +Use half bright and standout mode. + +@item bold +Use extra bright or bold mode. + +@item bold-standout +Use extra bright or bold and standout mode. + +@end table + @end table @node Emacs >From Stephane.Carrez@worldnet.fr Sat Jul 21 12:57:00 2001 From: Stephane Carrez To: gdb-patches@sources.redhat.com Subject: Re: [PATCH]: TUI I/O management Date: Sat, 21 Jul 2001 12:57:00 -0000 Message-id: <3B59DFCE.457DA12@worldnet.fr> References: <3B575959.A2187384@worldnet.fr> X-SW-Source: 2001-07/msg00551.html Content-length: 68 > I'll commit this patch in one day or two. Committed. Stephane