Home | History | Annotate | Line # | Download | only in tui
tui-win.c revision 1.9
      1  1.1  christos /* TUI window generic functions.
      2  1.1  christos 
      3  1.9  christos    Copyright (C) 1998-2020 Free Software Foundation, Inc.
      4  1.1  christos 
      5  1.1  christos    Contributed by Hewlett-Packard Company.
      6  1.1  christos 
      7  1.1  christos    This file is part of GDB.
      8  1.1  christos 
      9  1.1  christos    This program is free software; you can redistribute it and/or modify
     10  1.1  christos    it under the terms of the GNU General Public License as published by
     11  1.1  christos    the Free Software Foundation; either version 3 of the License, or
     12  1.1  christos    (at your option) any later version.
     13  1.1  christos 
     14  1.1  christos    This program is distributed in the hope that it will be useful,
     15  1.1  christos    but WITHOUT ANY WARRANTY; without even the implied warranty of
     16  1.1  christos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     17  1.1  christos    GNU General Public License for more details.
     18  1.1  christos 
     19  1.1  christos    You should have received a copy of the GNU General Public License
     20  1.1  christos    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
     21  1.1  christos 
     22  1.1  christos /* This module contains procedures for handling tui window functions
     23  1.1  christos    like resize, scrolling, scrolling, changing focus, etc.
     24  1.1  christos 
     25  1.1  christos    Author: Susan B. Macchia  */
     26  1.1  christos 
     27  1.1  christos #include "defs.h"
     28  1.1  christos #include "command.h"
     29  1.1  christos #include "symtab.h"
     30  1.1  christos #include "breakpoint.h"
     31  1.1  christos #include "frame.h"
     32  1.1  christos #include "cli/cli-cmds.h"
     33  1.9  christos #include "cli/cli-style.h"
     34  1.1  christos #include "top.h"
     35  1.1  christos #include "source.h"
     36  1.9  christos #include "gdbsupport/event-loop.h"
     37  1.9  christos #include "gdbcmd.h"
     38  1.9  christos #include "async-event.h"
     39  1.1  christos 
     40  1.1  christos #include "tui/tui.h"
     41  1.5  christos #include "tui/tui-io.h"
     42  1.9  christos #include "tui/tui-command.h"
     43  1.1  christos #include "tui/tui-data.h"
     44  1.9  christos #include "tui/tui-layout.h"
     45  1.1  christos #include "tui/tui-wingeneral.h"
     46  1.1  christos #include "tui/tui-stack.h"
     47  1.1  christos #include "tui/tui-regs.h"
     48  1.1  christos #include "tui/tui-disasm.h"
     49  1.1  christos #include "tui/tui-source.h"
     50  1.1  christos #include "tui/tui-winsource.h"
     51  1.1  christos #include "tui/tui-win.h"
     52  1.1  christos 
     53  1.1  christos #include "gdb_curses.h"
     54  1.1  christos #include <ctype.h>
     55  1.1  christos #include "readline/readline.h"
     56  1.9  christos #include "gdbsupport/gdb_string_view.h"
     57  1.1  christos 
     58  1.1  christos #include <signal.h>
     59  1.1  christos 
     60  1.8  christos static void tui_set_tab_width_command (const char *, int);
     61  1.8  christos static void tui_refresh_all_command (const char *, int);
     62  1.8  christos static void tui_all_windows_info (const char *, int);
     63  1.8  christos static void tui_scroll_forward_command (const char *, int);
     64  1.8  christos static void tui_scroll_backward_command (const char *, int);
     65  1.8  christos static void tui_scroll_left_command (const char *, int);
     66  1.8  christos static void tui_scroll_right_command (const char *, int);
     67  1.8  christos static void parse_scrolling_args (const char *,
     68  1.1  christos 				  struct tui_win_info **,
     69  1.1  christos 				  int *);
     70  1.1  christos 
     71  1.1  christos 
     72  1.1  christos #ifndef ACS_LRCORNER
     73  1.1  christos #  define ACS_LRCORNER '+'
     74  1.1  christos #endif
     75  1.1  christos #ifndef ACS_LLCORNER
     76  1.1  christos #  define ACS_LLCORNER '+'
     77  1.1  christos #endif
     78  1.1  christos #ifndef ACS_ULCORNER
     79  1.1  christos #  define ACS_ULCORNER '+'
     80  1.1  christos #endif
     81  1.1  christos #ifndef ACS_URCORNER
     82  1.1  christos #  define ACS_URCORNER '+'
     83  1.1  christos #endif
     84  1.1  christos #ifndef ACS_HLINE
     85  1.1  christos #  define ACS_HLINE '-'
     86  1.1  christos #endif
     87  1.1  christos #ifndef ACS_VLINE
     88  1.1  christos #  define ACS_VLINE '|'
     89  1.1  christos #endif
     90  1.1  christos 
     91  1.1  christos /* Possible values for tui-border-kind variable.  */
     92  1.1  christos static const char *const tui_border_kind_enums[] = {
     93  1.1  christos   "space",
     94  1.1  christos   "ascii",
     95  1.1  christos   "acs",
     96  1.1  christos   NULL
     97  1.1  christos };
     98  1.1  christos 
     99  1.1  christos /* Possible values for tui-border-mode and tui-active-border-mode.  */
    100  1.1  christos static const char *const tui_border_mode_enums[] = {
    101  1.1  christos   "normal",
    102  1.1  christos   "standout",
    103  1.1  christos   "reverse",
    104  1.1  christos   "half",
    105  1.1  christos   "half-standout",
    106  1.1  christos   "bold",
    107  1.1  christos   "bold-standout",
    108  1.1  christos   NULL
    109  1.1  christos };
    110  1.1  christos 
    111  1.1  christos struct tui_translate
    112  1.1  christos {
    113  1.1  christos   const char *name;
    114  1.1  christos   int value;
    115  1.1  christos };
    116  1.1  christos 
    117  1.1  christos /* Translation table for border-mode variables.
    118  1.1  christos    The list of values must be terminated by a NULL.
    119  1.1  christos    After the NULL value, an entry defines the default.  */
    120  1.9  christos static struct tui_translate tui_border_mode_translate[] = {
    121  1.1  christos   { "normal",		A_NORMAL },
    122  1.1  christos   { "standout",		A_STANDOUT },
    123  1.1  christos   { "reverse",		A_REVERSE },
    124  1.1  christos   { "half",		A_DIM },
    125  1.1  christos   { "half-standout",	A_DIM | A_STANDOUT },
    126  1.1  christos   { "bold",		A_BOLD },
    127  1.1  christos   { "bold-standout",	A_BOLD | A_STANDOUT },
    128  1.1  christos   { 0, 0 },
    129  1.1  christos   { "normal",		A_NORMAL }
    130  1.1  christos };
    131  1.1  christos 
    132  1.1  christos /* Translation tables for border-kind, one for each border
    133  1.1  christos    character (see wborder, border curses operations).
    134  1.1  christos    -1 is used to indicate the ACS because ACS characters
    135  1.1  christos    are determined at run time by curses (depends on terminal).  */
    136  1.9  christos static struct tui_translate tui_border_kind_translate_vline[] = {
    137  1.1  christos   { "space",    ' ' },
    138  1.1  christos   { "ascii",    '|' },
    139  1.1  christos   { "acs",      -1 },
    140  1.1  christos   { 0, 0 },
    141  1.1  christos   { "ascii",    '|' }
    142  1.1  christos };
    143  1.1  christos 
    144  1.9  christos static struct tui_translate tui_border_kind_translate_hline[] = {
    145  1.1  christos   { "space",    ' ' },
    146  1.1  christos   { "ascii",    '-' },
    147  1.1  christos   { "acs",      -1 },
    148  1.1  christos   { 0, 0 },
    149  1.1  christos   { "ascii",    '-' }
    150  1.1  christos };
    151  1.1  christos 
    152  1.9  christos static struct tui_translate tui_border_kind_translate_ulcorner[] = {
    153  1.1  christos   { "space",    ' ' },
    154  1.1  christos   { "ascii",    '+' },
    155  1.1  christos   { "acs",      -1 },
    156  1.1  christos   { 0, 0 },
    157  1.1  christos   { "ascii",    '+' }
    158  1.1  christos };
    159  1.1  christos 
    160  1.9  christos static struct tui_translate tui_border_kind_translate_urcorner[] = {
    161  1.1  christos   { "space",    ' ' },
    162  1.1  christos   { "ascii",    '+' },
    163  1.1  christos   { "acs",      -1 },
    164  1.1  christos   { 0, 0 },
    165  1.1  christos   { "ascii",    '+' }
    166  1.1  christos };
    167  1.1  christos 
    168  1.9  christos static struct tui_translate tui_border_kind_translate_llcorner[] = {
    169  1.1  christos   { "space",    ' ' },
    170  1.1  christos   { "ascii",    '+' },
    171  1.1  christos   { "acs",      -1 },
    172  1.1  christos   { 0, 0 },
    173  1.1  christos   { "ascii",    '+' }
    174  1.1  christos };
    175  1.1  christos 
    176  1.9  christos static struct tui_translate tui_border_kind_translate_lrcorner[] = {
    177  1.1  christos   { "space",    ' ' },
    178  1.1  christos   { "ascii",    '+' },
    179  1.1  christos   { "acs",      -1 },
    180  1.1  christos   { 0, 0 },
    181  1.1  christos   { "ascii",    '+' }
    182  1.1  christos };
    183  1.1  christos 
    184  1.1  christos 
    185  1.1  christos /* Tui configuration variables controlled with set/show command.  */
    186  1.9  christos static const char *tui_active_border_mode = "bold-standout";
    187  1.1  christos static void
    188  1.1  christos show_tui_active_border_mode (struct ui_file *file,
    189  1.1  christos 			     int from_tty,
    190  1.1  christos 			     struct cmd_list_element *c,
    191  1.1  christos 			     const char *value)
    192  1.1  christos {
    193  1.1  christos   fprintf_filtered (file, _("\
    194  1.1  christos The attribute mode to use for the active TUI window border is \"%s\".\n"),
    195  1.1  christos 		    value);
    196  1.1  christos }
    197  1.1  christos 
    198  1.9  christos static const char *tui_border_mode = "normal";
    199  1.1  christos static void
    200  1.1  christos show_tui_border_mode (struct ui_file *file,
    201  1.1  christos 		      int from_tty,
    202  1.1  christos 		      struct cmd_list_element *c,
    203  1.1  christos 		      const char *value)
    204  1.1  christos {
    205  1.1  christos   fprintf_filtered (file, _("\
    206  1.1  christos The attribute mode to use for the TUI window borders is \"%s\".\n"),
    207  1.1  christos 		    value);
    208  1.1  christos }
    209  1.1  christos 
    210  1.9  christos static const char *tui_border_kind = "acs";
    211  1.1  christos static void
    212  1.1  christos show_tui_border_kind (struct ui_file *file,
    213  1.1  christos 		      int from_tty,
    214  1.1  christos 		      struct cmd_list_element *c,
    215  1.1  christos 		      const char *value)
    216  1.1  christos {
    217  1.1  christos   fprintf_filtered (file, _("The kind of border for TUI windows is \"%s\".\n"),
    218  1.1  christos 		    value);
    219  1.1  christos }
    220  1.1  christos 
    221  1.1  christos 
    222  1.1  christos /* Tui internal configuration variables.  These variables are updated
    223  1.1  christos    by tui_update_variables to reflect the tui configuration
    224  1.1  christos    variables.  */
    225  1.1  christos chtype tui_border_vline;
    226  1.1  christos chtype tui_border_hline;
    227  1.1  christos chtype tui_border_ulcorner;
    228  1.1  christos chtype tui_border_urcorner;
    229  1.1  christos chtype tui_border_llcorner;
    230  1.1  christos chtype tui_border_lrcorner;
    231  1.1  christos 
    232  1.1  christos int tui_border_attrs;
    233  1.1  christos int tui_active_border_attrs;
    234  1.1  christos 
    235  1.1  christos /* Identify the item in the translation table.
    236  1.1  christos    When the item is not recognized, use the default entry.  */
    237  1.1  christos static struct tui_translate *
    238  1.1  christos translate (const char *name, struct tui_translate *table)
    239  1.1  christos {
    240  1.1  christos   while (table->name)
    241  1.1  christos     {
    242  1.1  christos       if (name && strcmp (table->name, name) == 0)
    243  1.1  christos         return table;
    244  1.1  christos       table++;
    245  1.1  christos     }
    246  1.1  christos 
    247  1.1  christos   /* Not found, return default entry.  */
    248  1.1  christos   table++;
    249  1.1  christos   return table;
    250  1.1  christos }
    251  1.1  christos 
    252  1.1  christos /* Update the tui internal configuration according to gdb settings.
    253  1.1  christos    Returns 1 if the configuration has changed and the screen should
    254  1.1  christos    be redrawn.  */
    255  1.9  christos bool
    256  1.9  christos tui_update_variables ()
    257  1.1  christos {
    258  1.9  christos   bool need_redraw = false;
    259  1.1  christos   struct tui_translate *entry;
    260  1.1  christos 
    261  1.1  christos   entry = translate (tui_border_mode, tui_border_mode_translate);
    262  1.1  christos   if (tui_border_attrs != entry->value)
    263  1.1  christos     {
    264  1.1  christos       tui_border_attrs = entry->value;
    265  1.9  christos       need_redraw = true;
    266  1.1  christos     }
    267  1.1  christos   entry = translate (tui_active_border_mode, tui_border_mode_translate);
    268  1.1  christos   if (tui_active_border_attrs != entry->value)
    269  1.1  christos     {
    270  1.1  christos       tui_active_border_attrs = entry->value;
    271  1.9  christos       need_redraw = true;
    272  1.1  christos     }
    273  1.1  christos 
    274  1.1  christos   /* If one corner changes, all characters are changed.
    275  1.1  christos      Only check the first one.  The ACS characters are determined at
    276  1.1  christos      run time by curses terminal management.  */
    277  1.1  christos   entry = translate (tui_border_kind, tui_border_kind_translate_lrcorner);
    278  1.1  christos   if (tui_border_lrcorner != (chtype) entry->value)
    279  1.1  christos     {
    280  1.1  christos       tui_border_lrcorner = (entry->value < 0) ? ACS_LRCORNER : entry->value;
    281  1.9  christos       need_redraw = true;
    282  1.1  christos     }
    283  1.1  christos   entry = translate (tui_border_kind, tui_border_kind_translate_llcorner);
    284  1.1  christos   tui_border_llcorner = (entry->value < 0) ? ACS_LLCORNER : entry->value;
    285  1.1  christos 
    286  1.1  christos   entry = translate (tui_border_kind, tui_border_kind_translate_ulcorner);
    287  1.1  christos   tui_border_ulcorner = (entry->value < 0) ? ACS_ULCORNER : entry->value;
    288  1.1  christos 
    289  1.1  christos   entry = translate (tui_border_kind, tui_border_kind_translate_urcorner);
    290  1.1  christos   tui_border_urcorner = (entry->value < 0) ? ACS_URCORNER : entry->value;
    291  1.1  christos 
    292  1.1  christos   entry = translate (tui_border_kind, tui_border_kind_translate_hline);
    293  1.1  christos   tui_border_hline = (entry->value < 0) ? ACS_HLINE : entry->value;
    294  1.1  christos 
    295  1.1  christos   entry = translate (tui_border_kind, tui_border_kind_translate_vline);
    296  1.1  christos   tui_border_vline = (entry->value < 0) ? ACS_VLINE : entry->value;
    297  1.1  christos 
    298  1.1  christos   return need_redraw;
    299  1.1  christos }
    300  1.1  christos 
    301  1.1  christos static struct cmd_list_element *tuilist;
    302  1.1  christos 
    303  1.1  christos struct cmd_list_element **
    304  1.1  christos tui_get_cmd_list (void)
    305  1.1  christos {
    306  1.1  christos   if (tuilist == 0)
    307  1.9  christos     add_basic_prefix_cmd ("tui", class_tui,
    308  1.9  christos 			  _("Text User Interface commands."),
    309  1.9  christos 			  &tuilist, "tui ", 0, &cmdlist);
    310  1.1  christos   return &tuilist;
    311  1.1  christos }
    312  1.1  christos 
    313  1.3  christos /* The set_func hook of "set tui ..." commands that affect the window
    314  1.3  christos    borders on the TUI display.  */
    315  1.9  christos 
    316  1.9  christos static void
    317  1.8  christos tui_set_var_cmd (const char *null_args,
    318  1.8  christos 		 int from_tty, struct cmd_list_element *c)
    319  1.3  christos {
    320  1.3  christos   if (tui_update_variables () && tui_active)
    321  1.3  christos     tui_rehighlight_all ();
    322  1.3  christos }
    323  1.3  christos 
    324  1.9  christos 
    325  1.9  christos 
    327  1.9  christos /* True if TUI resizes should print a message.  This is used by the
    328  1.9  christos    test suite.  */
    329  1.9  christos 
    330  1.9  christos static bool resize_message;
    331  1.9  christos 
    332  1.9  christos static void
    333  1.9  christos show_tui_resize_message (struct ui_file *file, int from_tty,
    334  1.9  christos 			 struct cmd_list_element *c, const char *value)
    335  1.9  christos {
    336  1.9  christos   fprintf_filtered (file, _("TUI resize messaging is %s.\n"), value);
    337  1.9  christos }
    338  1.9  christos 
    339  1.9  christos 
    340  1.6  christos 
    342  1.6  christos /* Generic window name completion function.  Complete window name pointed
    343  1.6  christos    to by TEXT and WORD.  If INCLUDE_NEXT_PREV_P is true then the special
    344  1.5  christos    window names 'next' and 'prev' will also be considered as possible
    345  1.8  christos    completions of the window name.  */
    346  1.8  christos 
    347  1.8  christos static void
    348  1.6  christos window_name_completer (completion_tracker &tracker,
    349  1.5  christos 		       int include_next_prev_p,
    350  1.8  christos 		       const char *text, const char *word)
    351  1.5  christos {
    352  1.9  christos   std::vector<const char *> completion_name_vec;
    353  1.5  christos 
    354  1.5  christos   for (tui_win_info *win_info : all_tui_windows ())
    355  1.5  christos     {
    356  1.5  christos       const char *completion_name = NULL;
    357  1.9  christos 
    358  1.5  christos       /* We can't focus on an invisible window.  */
    359  1.5  christos       if (!win_info->is_visible ())
    360  1.9  christos 	continue;
    361  1.6  christos 
    362  1.8  christos       completion_name = win_info->name ();
    363  1.5  christos       gdb_assert (completion_name != NULL);
    364  1.5  christos       completion_name_vec.push_back (completion_name);
    365  1.5  christos     }
    366  1.5  christos 
    367  1.5  christos   /* If no windows are considered visible then the TUI has not yet been
    368  1.9  christos      initialized.  But still "focus src" and "focus cmd" will work because
    369  1.8  christos      invoking the focus command will entail initializing the TUI which sets the
    370  1.5  christos      default layout to "src".  */
    371  1.8  christos   if (completion_name_vec.empty ())
    372  1.8  christos     {
    373  1.6  christos       completion_name_vec.push_back (SRC_NAME);
    374  1.6  christos       completion_name_vec.push_back (CMD_NAME);
    375  1.6  christos     }
    376  1.6  christos 
    377  1.8  christos   if (include_next_prev_p)
    378  1.8  christos     {
    379  1.5  christos       completion_name_vec.push_back ("next");
    380  1.5  christos       completion_name_vec.push_back ("prev");
    381  1.5  christos     }
    382  1.8  christos 
    383  1.8  christos 
    384  1.5  christos   completion_name_vec.push_back (NULL);
    385  1.5  christos   complete_on_enum (tracker, completion_name_vec.data (), text, word);
    386  1.6  christos }
    387  1.6  christos 
    388  1.6  christos /* Complete possible window names to focus on.  TEXT is the complete text
    389  1.8  christos    entered so far, WORD is the word currently being completed.  */
    390  1.6  christos 
    391  1.8  christos static void
    392  1.8  christos focus_completer (struct cmd_list_element *ignore,
    393  1.6  christos 		 completion_tracker &tracker,
    394  1.8  christos 		 const char *text, const char *word)
    395  1.6  christos {
    396  1.6  christos   window_name_completer (tracker, 1, text, word);
    397  1.6  christos }
    398  1.6  christos 
    399  1.6  christos /* Complete possible window names for winheight command.  TEXT is the
    400  1.6  christos    complete text entered so far, WORD is the word currently being
    401  1.8  christos    completed.  */
    402  1.6  christos 
    403  1.8  christos static void
    404  1.6  christos winheight_completer (struct cmd_list_element *ignore,
    405  1.6  christos 		     completion_tracker &tracker,
    406  1.6  christos 		     const char *text, const char *word)
    407  1.6  christos {
    408  1.6  christos   /* The first word is the window name.  That we can complete.  Subsequent
    409  1.8  christos      words can't be completed.  */
    410  1.6  christos   if (word != text)
    411  1.8  christos     return;
    412  1.1  christos 
    413  1.1  christos   window_name_completer (tracker, 0, text, word);
    414  1.1  christos }
    415  1.1  christos 
    416  1.1  christos /* Update gdb's knowledge of the terminal size.  */
    417  1.1  christos void
    418  1.5  christos tui_update_gdb_sizes (void)
    419  1.1  christos {
    420  1.5  christos   int width, height;
    421  1.5  christos 
    422  1.9  christos   if (tui_active)
    423  1.9  christos     {
    424  1.5  christos       width = TUI_CMD_WIN->width;
    425  1.5  christos       height = TUI_CMD_WIN->height;
    426  1.5  christos     }
    427  1.5  christos   else
    428  1.5  christos     {
    429  1.5  christos       width = tui_term_width ();
    430  1.5  christos       height = tui_term_height ();
    431  1.5  christos     }
    432  1.1  christos 
    433  1.1  christos   set_screen_width_and_height (width, height);
    434  1.1  christos }
    435  1.1  christos 
    436  1.9  christos 
    437  1.1  christos void
    438  1.9  christos tui_win_info::forward_scroll (int num_to_scroll)
    439  1.9  christos {
    440  1.1  christos   if (num_to_scroll == 0)
    441  1.9  christos     num_to_scroll = height - 3;
    442  1.1  christos 
    443  1.1  christos   do_scroll_vertical (num_to_scroll);
    444  1.1  christos }
    445  1.9  christos 
    446  1.1  christos void
    447  1.9  christos tui_win_info::backward_scroll (int num_to_scroll)
    448  1.9  christos {
    449  1.1  christos   if (num_to_scroll == 0)
    450  1.9  christos     num_to_scroll = height - 3;
    451  1.1  christos 
    452  1.1  christos   do_scroll_vertical (-num_to_scroll);
    453  1.1  christos }
    454  1.1  christos 
    455  1.9  christos 
    456  1.1  christos void
    457  1.9  christos tui_win_info::left_scroll (int num_to_scroll)
    458  1.9  christos {
    459  1.1  christos   if (num_to_scroll == 0)
    460  1.9  christos     num_to_scroll = 1;
    461  1.1  christos 
    462  1.1  christos   do_scroll_horizontal (num_to_scroll);
    463  1.1  christos }
    464  1.1  christos 
    465  1.9  christos 
    466  1.1  christos void
    467  1.9  christos tui_win_info::right_scroll (int num_to_scroll)
    468  1.9  christos {
    469  1.1  christos   if (num_to_scroll == 0)
    470  1.9  christos     num_to_scroll = 1;
    471  1.1  christos 
    472  1.1  christos   do_scroll_horizontal (-num_to_scroll);
    473  1.1  christos }
    474  1.1  christos 
    475  1.1  christos 
    476  1.1  christos void
    477  1.1  christos tui_refresh_all_win (void)
    478  1.9  christos {
    479  1.1  christos   clearok (curscr, TRUE);
    480  1.1  christos   tui_refresh_all ();
    481  1.3  christos }
    482  1.3  christos 
    483  1.3  christos void
    484  1.9  christos tui_rehighlight_all (void)
    485  1.9  christos {
    486  1.3  christos   for (tui_win_info *win_info : all_tui_windows ())
    487  1.1  christos     win_info->check_and_display_highlight_if_needed ();
    488  1.1  christos }
    489  1.9  christos 
    490  1.1  christos /* Resize all the windows based on the terminal size.  This function
    491  1.1  christos    gets called from within the readline SIGWINCH handler.  */
    492  1.1  christos void
    493  1.1  christos tui_resize_all (void)
    494  1.1  christos {
    495  1.1  christos   int height_diff, width_diff;
    496  1.1  christos   int screenheight, screenwidth;
    497  1.1  christos 
    498  1.1  christos   rl_get_screen_size (&screenheight, &screenwidth);
    499  1.1  christos   width_diff = screenwidth - tui_term_width ();
    500  1.1  christos   height_diff = screenheight - tui_term_height ();
    501  1.1  christos   if (height_diff || width_diff)
    502  1.1  christos     {
    503  1.1  christos       struct tui_win_info *win_with_focus = tui_win_with_focus ();
    504  1.1  christos 
    505  1.1  christos #ifdef HAVE_RESIZE_TERM
    506  1.1  christos       resize_term (screenheight, screenwidth);
    507  1.1  christos #endif
    508  1.9  christos       /* Turn keypad off while we resize.  */
    509  1.1  christos       if (win_with_focus != TUI_CMD_WIN)
    510  1.1  christos 	keypad (TUI_CMD_WIN->handle.get (), FALSE);
    511  1.1  christos       tui_update_gdb_sizes ();
    512  1.9  christos       tui_set_term_height_to (screenheight);
    513  1.1  christos       tui_set_term_width_to (screenwidth);
    514  1.1  christos 
    515  1.1  christos       /* erase + clearok are used instead of a straightforward clear as
    516  1.1  christos          AIX 5.3 does not define clear.  */
    517  1.9  christos       erase ();
    518  1.1  christos       clearok (curscr, TRUE);
    519  1.1  christos       tui_apply_current_layout ();
    520  1.1  christos       /* Turn keypad back on, unless focus is in the command
    521  1.9  christos 	 window.  */
    522  1.1  christos       if (win_with_focus != TUI_CMD_WIN)
    523  1.1  christos 	keypad (TUI_CMD_WIN->handle.get (), TRUE);
    524  1.1  christos     }
    525  1.1  christos }
    526  1.5  christos 
    527  1.5  christos #ifdef SIGWINCH
    528  1.5  christos /* Token for use by TUI's asynchronous SIGWINCH handler.  */
    529  1.5  christos static struct async_signal_handler *tui_sigwinch_token;
    530  1.1  christos 
    531  1.1  christos /* TUI's SIGWINCH signal handler.  */
    532  1.1  christos static void
    533  1.5  christos tui_sigwinch_handler (int signal)
    534  1.9  christos {
    535  1.1  christos   mark_async_signal_handler (tui_sigwinch_token);
    536  1.5  christos   tui_set_win_resized_to (true);
    537  1.5  christos }
    538  1.5  christos 
    539  1.5  christos /* Callback for asynchronously resizing TUI following a SIGWINCH signal.  */
    540  1.5  christos static void
    541  1.5  christos tui_async_resize_screen (gdb_client_data arg)
    542  1.5  christos {
    543  1.5  christos   rl_resize_terminal ();
    544  1.5  christos 
    545  1.5  christos   if (!tui_active)
    546  1.5  christos     {
    547  1.5  christos       int screen_height, screen_width;
    548  1.5  christos 
    549  1.5  christos       rl_get_screen_size (&screen_height, &screen_width);
    550  1.5  christos       set_screen_width_and_height (screen_width, screen_height);
    551  1.5  christos 
    552  1.5  christos       /* win_resized is left set so that the next call to tui_enable()
    553  1.5  christos 	 resizes the TUI windows.  */
    554  1.5  christos     }
    555  1.9  christos   else
    556  1.5  christos     {
    557  1.5  christos       tui_set_win_resized_to (false);
    558  1.5  christos       tui_resize_all ();
    559  1.9  christos       tui_refresh_all_win ();
    560  1.9  christos       tui_update_gdb_sizes ();
    561  1.9  christos       if (resize_message)
    562  1.9  christos 	{
    563  1.9  christos 	  static int count;
    564  1.9  christos 	  printf_unfiltered ("@@ resize done %d, size = %dx%d\n", count,
    565  1.9  christos 			     tui_term_width (), tui_term_height ());
    566  1.5  christos 	  ++count;
    567  1.5  christos 	}
    568  1.5  christos       tui_redisplay_readline ();
    569  1.1  christos     }
    570  1.1  christos }
    571  1.5  christos #endif
    572  1.5  christos 
    573  1.5  christos /* Initialize TUI's SIGWINCH signal handler.  Note that the handler is not
    574  1.1  christos    uninstalled when we exit TUI, so the handler should not assume that TUI is
    575  1.1  christos    always active.  */
    576  1.1  christos void
    577  1.1  christos tui_initialize_win (void)
    578  1.5  christos {
    579  1.5  christos #ifdef SIGWINCH
    580  1.5  christos   tui_sigwinch_token
    581  1.5  christos     = create_async_signal_handler (tui_async_resize_screen, NULL);
    582  1.1  christos 
    583  1.5  christos   {
    584  1.1  christos #ifdef HAVE_SIGACTION
    585  1.5  christos     struct sigaction old_winch;
    586  1.5  christos 
    587  1.3  christos     memset (&old_winch, 0, sizeof (old_winch));
    588  1.5  christos     old_winch.sa_handler = &tui_sigwinch_handler;
    589  1.3  christos #ifdef SA_RESTART
    590  1.5  christos     old_winch.sa_flags = SA_RESTART;
    591  1.1  christos #endif
    592  1.5  christos     sigaction (SIGWINCH, &old_winch, NULL);
    593  1.1  christos #else
    594  1.5  christos     signal (SIGWINCH, &tui_sigwinch_handler);
    595  1.1  christos #endif
    596  1.1  christos   }
    597  1.1  christos #endif
    598  1.1  christos }
    599  1.1  christos 
    600  1.8  christos 
    601  1.1  christos static void
    602  1.1  christos tui_scroll_forward_command (const char *arg, int from_tty)
    603  1.1  christos {
    604  1.1  christos   int num_to_scroll = 1;
    605  1.1  christos   struct tui_win_info *win_to_scroll;
    606  1.1  christos 
    607  1.8  christos   /* Make sure the curses mode is enabled.  */
    608  1.9  christos   tui_enable ();
    609  1.1  christos   if (arg == NULL)
    610  1.1  christos     parse_scrolling_args (arg, &win_to_scroll, NULL);
    611  1.9  christos   else
    612  1.1  christos     parse_scrolling_args (arg, &win_to_scroll, &num_to_scroll);
    613  1.1  christos   win_to_scroll->forward_scroll (num_to_scroll);
    614  1.1  christos }
    615  1.1  christos 
    616  1.8  christos 
    617  1.1  christos static void
    618  1.1  christos tui_scroll_backward_command (const char *arg, int from_tty)
    619  1.1  christos {
    620  1.1  christos   int num_to_scroll = 1;
    621  1.1  christos   struct tui_win_info *win_to_scroll;
    622  1.1  christos 
    623  1.8  christos   /* Make sure the curses mode is enabled.  */
    624  1.9  christos   tui_enable ();
    625  1.1  christos   if (arg == NULL)
    626  1.1  christos     parse_scrolling_args (arg, &win_to_scroll, NULL);
    627  1.9  christos   else
    628  1.1  christos     parse_scrolling_args (arg, &win_to_scroll, &num_to_scroll);
    629  1.1  christos   win_to_scroll->backward_scroll (num_to_scroll);
    630  1.1  christos }
    631  1.1  christos 
    632  1.8  christos 
    633  1.1  christos static void
    634  1.1  christos tui_scroll_left_command (const char *arg, int from_tty)
    635  1.1  christos {
    636  1.1  christos   int num_to_scroll;
    637  1.1  christos   struct tui_win_info *win_to_scroll;
    638  1.1  christos 
    639  1.1  christos   /* Make sure the curses mode is enabled.  */
    640  1.9  christos   tui_enable ();
    641  1.1  christos   parse_scrolling_args (arg, &win_to_scroll, &num_to_scroll);
    642  1.1  christos   win_to_scroll->left_scroll (num_to_scroll);
    643  1.1  christos }
    644  1.1  christos 
    645  1.8  christos 
    646  1.1  christos static void
    647  1.1  christos tui_scroll_right_command (const char *arg, int from_tty)
    648  1.1  christos {
    649  1.1  christos   int num_to_scroll;
    650  1.1  christos   struct tui_win_info *win_to_scroll;
    651  1.1  christos 
    652  1.1  christos   /* Make sure the curses mode is enabled.  */
    653  1.9  christos   tui_enable ();
    654  1.1  christos   parse_scrolling_args (arg, &win_to_scroll, &num_to_scroll);
    655  1.1  christos   win_to_scroll->right_scroll (num_to_scroll);
    656  1.1  christos }
    657  1.9  christos 
    658  1.9  christos 
    659  1.9  christos /* Answer the window represented by name.  */
    660  1.1  christos static struct tui_win_info *
    661  1.9  christos tui_partial_win_by_name (gdb::string_view name)
    662  1.9  christos {
    663  1.9  christos   struct tui_win_info *best = nullptr;
    664  1.1  christos 
    665  1.9  christos   for (tui_win_info *item : all_tui_windows ())
    666  1.1  christos     {
    667  1.9  christos       const char *cur_name = item->name ();
    668  1.9  christos 
    669  1.9  christos       if (name == cur_name)
    670  1.1  christos 	return item;
    671  1.9  christos       if (startswith (cur_name, name))
    672  1.9  christos 	{
    673  1.9  christos 	  if (best != nullptr)
    674  1.9  christos 	    error (_("Window name \"%*s\" is ambiguous"),
    675  1.1  christos 		   (int) name.size (), name.data ());
    676  1.9  christos 	  best = item;
    677  1.1  christos 	}
    678  1.9  christos     }
    679  1.1  christos 
    680  1.1  christos   return best;
    681  1.9  christos }
    682  1.1  christos 
    683  1.8  christos /* Set focus to the window named by 'arg'.  */
    684  1.1  christos static void
    685  1.1  christos tui_set_focus_command (const char *arg, int from_tty)
    686  1.9  christos {
    687  1.9  christos   tui_enable ();
    688  1.9  christos 
    689  1.9  christos   if (arg == NULL)
    690  1.9  christos     error_no_arg (_("name of window to focus"));
    691  1.9  christos 
    692  1.9  christos   struct tui_win_info *win_info = NULL;
    693  1.9  christos 
    694  1.9  christos   if (subset_compare (arg, "next"))
    695  1.9  christos     win_info = tui_next_win (tui_win_with_focus ());
    696  1.9  christos   else if (subset_compare (arg, "prev"))
    697  1.9  christos     win_info = tui_prev_win (tui_win_with_focus ());
    698  1.9  christos   else
    699  1.9  christos     win_info = tui_partial_win_by_name (arg);
    700  1.9  christos 
    701  1.9  christos   if (win_info == NULL)
    702  1.9  christos     error (_("Unrecognized window name \"%s\""), arg);
    703  1.9  christos   if (!win_info->is_visible ())
    704  1.9  christos     error (_("Window \"%s\" is not visible"), arg);
    705  1.9  christos 
    706  1.9  christos   tui_set_win_focus_to (win_info);
    707  1.9  christos   keypad (TUI_CMD_WIN->handle.get (), win_info != TUI_CMD_WIN);
    708  1.1  christos   printf_filtered (_("Focus set to %s window.\n"),
    709  1.1  christos 		   tui_win_with_focus ()->name ());
    710  1.1  christos }
    711  1.8  christos 
    712  1.1  christos static void
    713  1.9  christos tui_all_windows_info (const char *arg, int from_tty)
    714  1.9  christos {
    715  1.9  christos   if (!tui_active)
    716  1.9  christos     {
    717  1.9  christos       printf_filtered (_("The TUI is not active.\n"));
    718  1.9  christos       return;
    719  1.1  christos     }
    720  1.9  christos 
    721  1.9  christos   struct tui_win_info *win_with_focus = tui_win_with_focus ();
    722  1.9  christos   struct ui_out *uiout = current_uiout;
    723  1.9  christos 
    724  1.9  christos   ui_out_emit_table table_emitter (uiout, 3, -1, "tui-windows");
    725  1.9  christos   uiout->table_header (10, ui_left, "name", "Name");
    726  1.9  christos   uiout->table_header (5, ui_right, "lines", "Lines");
    727  1.1  christos   uiout->table_header (10, ui_left, "focus", "Focus");
    728  1.9  christos   uiout->table_body ();
    729  1.9  christos 
    730  1.1  christos   for (tui_win_info *win_info : all_tui_windows ())
    731  1.9  christos     if (win_info->is_visible ())
    732  1.9  christos       {
    733  1.9  christos 	ui_out_emit_tuple tuple_emitter (uiout, nullptr);
    734  1.9  christos 
    735  1.9  christos 	uiout->field_string ("name", win_info->name ());
    736  1.9  christos 	uiout->field_signed ("lines", win_info->height);
    737  1.1  christos 	if (win_with_focus == win_info)
    738  1.9  christos 	  uiout->field_string ("focus", _("(has focus)"));
    739  1.9  christos 	else
    740  1.1  christos 	  uiout->field_skip ("focus");
    741  1.1  christos 	uiout->text ("\n");
    742  1.1  christos       }
    743  1.1  christos }
    744  1.1  christos 
    745  1.8  christos 
    746  1.1  christos static void
    747  1.1  christos tui_refresh_all_command (const char *arg, int from_tty)
    748  1.1  christos {
    749  1.1  christos   /* Make sure the curses mode is enabled.  */
    750  1.1  christos   tui_enable ();
    751  1.1  christos 
    752  1.1  christos   tui_refresh_all_win ();
    753  1.9  christos }
    754  1.9  christos 
    755  1.8  christos #define DEFAULT_TAB_LEN         8
    756  1.8  christos 
    757  1.8  christos /* The tab width that should be used by the TUI.  */
    758  1.8  christos 
    759  1.8  christos unsigned int tui_tab_width = DEFAULT_TAB_LEN;
    760  1.8  christos 
    761  1.8  christos /* The tab width as set by the user.  */
    762  1.8  christos 
    763  1.8  christos static unsigned int internal_tab_width = DEFAULT_TAB_LEN;
    764  1.8  christos 
    765  1.8  christos /* After the tab width is set, call this to update the relevant
    766  1.8  christos    windows.  */
    767  1.8  christos 
    768  1.8  christos static void
    769  1.9  christos update_tab_width ()
    770  1.8  christos {
    771  1.9  christos   for (tui_win_info *win_info : all_tui_windows ())
    772  1.9  christos     {
    773  1.8  christos       if (win_info->is_visible ())
    774  1.8  christos 	win_info->update_tab_width ();
    775  1.8  christos     }
    776  1.8  christos }
    777  1.8  christos 
    778  1.8  christos /* Callback for "set tui tab-width".  */
    779  1.8  christos 
    780  1.8  christos static void
    781  1.8  christos tui_set_tab_width (const char *ignore,
    782  1.8  christos 		   int from_tty, struct cmd_list_element *c)
    783  1.8  christos {
    784  1.8  christos   if (internal_tab_width == 0)
    785  1.8  christos     {
    786  1.8  christos       internal_tab_width = tui_tab_width;
    787  1.8  christos       error (_("Tab width must not be 0"));
    788  1.8  christos     }
    789  1.8  christos 
    790  1.8  christos   tui_tab_width = internal_tab_width;
    791  1.8  christos   update_tab_width ();
    792  1.8  christos }
    793  1.8  christos 
    794  1.8  christos /* Callback for "show tui tab-width".  */
    795  1.8  christos 
    796  1.8  christos static void
    797  1.8  christos tui_show_tab_width (struct ui_file *file, int from_tty,
    798  1.8  christos 		    struct cmd_list_element *c, const char *value)
    799  1.8  christos {
    800  1.8  christos   fprintf_filtered (gdb_stdout, _("TUI tab width is %s spaces.\n"), value);
    801  1.1  christos 
    802  1.9  christos }
    803  1.9  christos 
    804  1.9  christos /* See tui-win.h.  */
    805  1.9  christos 
    806  1.9  christos bool compact_source = false;
    807  1.9  christos 
    808  1.9  christos /* Callback for "set tui compact-source".  */
    809  1.9  christos 
    810  1.9  christos static void
    811  1.9  christos tui_set_compact_source (const char *ignore, int from_tty,
    812  1.9  christos 			struct cmd_list_element *c)
    813  1.9  christos {
    814  1.9  christos   if (TUI_SRC_WIN != nullptr)
    815  1.9  christos     TUI_SRC_WIN->refill ();
    816  1.9  christos }
    817  1.9  christos 
    818  1.9  christos /* Callback for "show tui compact-source".  */
    819  1.9  christos 
    820  1.9  christos static void
    821  1.9  christos tui_show_compact_source (struct ui_file *file, int from_tty,
    822  1.9  christos 			 struct cmd_list_element *c, const char *value)
    823  1.9  christos {
    824  1.9  christos   printf_filtered (_("TUI source window compactness is %s.\n"), value);
    825  1.5  christos }
    826  1.1  christos 
    827  1.8  christos /* Set the tab width of the specified window.  */
    828  1.1  christos static void
    829  1.1  christos tui_set_tab_width_command (const char *arg, int from_tty)
    830  1.1  christos {
    831  1.8  christos   /* Make sure the curses mode is enabled.  */
    832  1.1  christos   tui_enable ();
    833  1.1  christos   if (arg != NULL)
    834  1.1  christos     {
    835  1.1  christos       int ts;
    836  1.8  christos 
    837  1.8  christos       ts = atoi (arg);
    838  1.8  christos       if (ts <= 0)
    839  1.3  christos 	warning (_("Tab widths greater than 0 must be specified."));
    840  1.8  christos       else
    841  1.8  christos 	{
    842  1.8  christos 	  internal_tab_width = ts;
    843  1.8  christos 	  tui_tab_width = ts;
    844  1.3  christos 
    845  1.1  christos 	  update_tab_width ();
    846  1.1  christos 	}
    847  1.1  christos     }
    848  1.1  christos }
    849  1.1  christos 
    850  1.1  christos 
    851  1.8  christos /* Set the height of the specified window.  */
    852  1.1  christos static void
    853  1.1  christos tui_set_win_height_command (const char *arg, int from_tty)
    854  1.1  christos {
    855  1.9  christos   /* Make sure the curses mode is enabled.  */
    856  1.9  christos   tui_enable ();
    857  1.1  christos   if (arg == NULL)
    858  1.9  christos     error_no_arg (_("name of window"));
    859  1.9  christos 
    860  1.9  christos   const char *buf = arg;
    861  1.9  christos   const char *buf_ptr = buf;
    862  1.1  christos   int new_height;
    863  1.9  christos   struct tui_win_info *win_info;
    864  1.1  christos 
    865  1.9  christos   buf_ptr = skip_to_space (buf_ptr);
    866  1.9  christos 
    867  1.9  christos   /* Validate the window name.  */
    868  1.1  christos   gdb::string_view wname (buf, buf_ptr - buf);
    869  1.9  christos   win_info = tui_partial_win_by_name (wname);
    870  1.9  christos 
    871  1.9  christos   if (win_info == NULL)
    872  1.9  christos     error (_("Unrecognized window name \"%s\""), arg);
    873  1.1  christos   if (!win_info->is_visible ())
    874  1.9  christos     error (_("Window \"%s\" is not visible"), arg);
    875  1.9  christos 
    876  1.1  christos   /* Process the size.  */
    877  1.9  christos   buf_ptr = skip_spaces (buf_ptr);
    878  1.1  christos 
    879  1.9  christos   if (*buf_ptr != '\0')
    880  1.9  christos     {
    881  1.9  christos       bool negate = false;
    882  1.1  christos       bool fixed_size = true;
    883  1.9  christos       int input_no;;
    884  1.1  christos 
    885  1.9  christos       if (*buf_ptr == '+' || *buf_ptr == '-')
    886  1.9  christos 	{
    887  1.9  christos 	  if (*buf_ptr == '-')
    888  1.9  christos 	    negate = true;
    889  1.1  christos 	  fixed_size = false;
    890  1.9  christos 	  buf_ptr++;
    891  1.9  christos 	}
    892  1.1  christos       input_no = atoi (buf_ptr);
    893  1.9  christos       if (input_no > 0)
    894  1.9  christos 	{
    895  1.9  christos 	  if (negate)
    896  1.9  christos 	    input_no *= (-1);
    897  1.9  christos 	  if (fixed_size)
    898  1.9  christos 	    new_height = input_no;
    899  1.9  christos 	  else
    900  1.9  christos 	    new_height = win_info->height + input_no;
    901  1.9  christos 
    902  1.9  christos 	  /* Now change the window's height, and adjust
    903  1.9  christos 	     all other windows around it.  */
    904  1.1  christos 	  tui_adjust_window_height (win_info, new_height);
    905  1.9  christos 	  tui_update_gdb_sizes ();
    906  1.9  christos 	}
    907  1.1  christos       else
    908  1.1  christos 	error (_("Invalid window height specified"));
    909  1.1  christos     }
    910  1.9  christos }
    911  1.1  christos 
    912  1.9  christos /* See tui-data.h.  */
    913  1.9  christos 
    914  1.1  christos int
    915  1.9  christos tui_win_info::max_height () const
    916  1.1  christos {
    917  1.1  christos   return tui_term_height () - 2;
    918  1.9  christos }
    919  1.1  christos 
    920  1.9  christos /* See tui-data.h.  */
    921  1.9  christos 
    922  1.1  christos int
    923  1.9  christos tui_win_info::max_width () const
    924  1.1  christos {
    925  1.1  christos   return tui_term_width () - 2;
    926  1.1  christos }
    927  1.8  christos 
    928  1.1  christos static void
    929  1.1  christos parse_scrolling_args (const char *arg,
    930  1.1  christos 		      struct tui_win_info **win_to_scroll,
    931  1.1  christos 		      int *num_to_scroll)
    932  1.1  christos {
    933  1.1  christos   if (num_to_scroll)
    934  1.1  christos     *num_to_scroll = 0;
    935  1.1  christos   *win_to_scroll = tui_win_with_focus ();
    936  1.1  christos 
    937  1.8  christos   /* First set up the default window to scroll, in case there is no
    938  1.1  christos      window name arg.  */
    939  1.8  christos   if (arg != NULL)
    940  1.1  christos     {
    941  1.1  christos       char *buf_ptr;
    942  1.8  christos 
    943  1.8  christos       /* Process the number of lines to scroll.  */
    944  1.1  christos       std::string copy = arg;
    945  1.1  christos       buf_ptr = &copy[0];
    946  1.1  christos       if (isdigit (*buf_ptr))
    947  1.1  christos 	{
    948  1.1  christos 	  char *num_str;
    949  1.1  christos 
    950  1.8  christos 	  num_str = buf_ptr;
    951  1.1  christos 	  buf_ptr = strchr (buf_ptr, ' ');
    952  1.9  christos 	  if (buf_ptr != NULL)
    953  1.1  christos 	    {
    954  1.1  christos 	      *buf_ptr = '\0';
    955  1.1  christos 	      if (num_to_scroll)
    956  1.1  christos 		*num_to_scroll = atoi (num_str);
    957  1.1  christos 	      buf_ptr++;
    958  1.1  christos 	    }
    959  1.1  christos 	  else if (num_to_scroll)
    960  1.1  christos 	    *num_to_scroll = atoi (num_str);
    961  1.1  christos 	}
    962  1.8  christos 
    963  1.1  christos       /* Process the window name if one is specified.  */
    964  1.7  christos       if (buf_ptr != NULL)
    965  1.1  christos 	{
    966  1.9  christos 	  const char *wname;
    967  1.1  christos 
    968  1.9  christos 	  wname = skip_spaces (buf_ptr);
    969  1.1  christos 
    970  1.9  christos 	  if (*wname != '\0')
    971  1.7  christos 	    {
    972  1.9  christos 	      *win_to_scroll = tui_partial_win_by_name (wname);
    973  1.9  christos 
    974  1.9  christos 	      if (*win_to_scroll == NULL)
    975  1.9  christos 		error (_("Unrecognized window `%s'"), wname);
    976  1.9  christos 	      if (!(*win_to_scroll)->is_visible ())
    977  1.9  christos 		error (_("Window is not visible"));
    978  1.1  christos 	      else if (*win_to_scroll == TUI_CMD_WIN)
    979  1.1  christos 		*win_to_scroll = *(tui_source_windows ().begin ());
    980  1.1  christos 	    }
    981  1.1  christos 	}
    982  1.8  christos     }
    983  1.8  christos }
    984  1.8  christos 
    985  1.8  christos /* Function to initialize gdb commands, for tui window
    986  1.9  christos    manipulation.  */
    987  1.8  christos 
    988  1.9  christos void _initialize_tui_win ();
    989  1.8  christos void
    990  1.8  christos _initialize_tui_win ()
    991  1.8  christos {
    992  1.8  christos   static struct cmd_list_element *tui_setlist;
    993  1.8  christos   static struct cmd_list_element *tui_showlist;
    994  1.8  christos   struct cmd_list_element *cmd;
    995  1.8  christos 
    996  1.9  christos   /* Define the classes of commands.
    997  1.9  christos      They will appear in the help list in the reverse of this order.  */
    998  1.9  christos   add_basic_prefix_cmd ("tui", class_tui,
    999  1.9  christos 			_("TUI configuration variables."),
   1000  1.9  christos 			&tui_setlist, "set tui ",
   1001  1.9  christos 			0 /* allow-unknown */, &setlist);
   1002  1.9  christos   add_show_prefix_cmd ("tui", class_tui,
   1003  1.9  christos 		       _("TUI configuration variables."),
   1004  1.8  christos 		       &tui_showlist, "show tui ",
   1005  1.8  christos 		       0 /* allow-unknown */, &showlist);
   1006  1.9  christos 
   1007  1.8  christos   add_com ("refresh", class_tui, tui_refresh_all_command,
   1008  1.8  christos            _("Refresh the terminal display."));
   1009  1.8  christos 
   1010  1.9  christos   cmd = add_com ("tabset", class_tui, tui_set_tab_width_command, _("\
   1011  1.8  christos Set the width (in characters) of tab stops.\n\
   1012  1.8  christos Usage: tabset N"));
   1013  1.8  christos   deprecate_cmd (cmd, "set tui tab-width");
   1014  1.9  christos 
   1015  1.9  christos   cmd = add_com ("winheight", class_tui, tui_set_win_height_command, _("\
   1016  1.9  christos Set or modify the height of a specified window.\n\
   1017  1.8  christos Usage: winheight WINDOW-NAME [+ | -] NUM-LINES\n\
   1018  1.8  christos Use \"info win\" to see the names of the windows currently being displayed."));
   1019  1.8  christos   add_com_alias ("wh", "winheight", class_tui, 0);
   1020  1.9  christos   set_cmd_completer (cmd, winheight_completer);
   1021  1.9  christos   add_info ("win", tui_all_windows_info,
   1022  1.8  christos 	    _("List of all displayed windows.\n\
   1023  1.9  christos Usage: info win"));
   1024  1.9  christos   cmd = add_com ("focus", class_tui, tui_set_focus_command, _("\
   1025  1.9  christos Set focus to named window or next/prev window.\n\
   1026  1.8  christos Usage: focus [WINDOW-NAME | next | prev]\n\
   1027  1.8  christos Use \"info win\" to see the names of the windows currently being displayed."));
   1028  1.8  christos   add_com_alias ("fs", "focus", class_tui, 0);
   1029  1.8  christos   set_cmd_completer (cmd, focus_completer);
   1030  1.9  christos   add_com ("+", class_tui, tui_scroll_forward_command, _("\
   1031  1.9  christos Scroll window forward.\n\
   1032  1.9  christos Usage: + [N] [WIN]\n\
   1033  1.8  christos Scroll window WIN N lines forwards.  Both WIN and N are optional, N\n\
   1034  1.8  christos defaults to 1, and WIN defaults to the currently focused window."));
   1035  1.9  christos   add_com ("-", class_tui, tui_scroll_backward_command, _("\
   1036  1.9  christos Scroll window backward.\n\
   1037  1.9  christos Usage: - [N] [WIN]\n\
   1038  1.8  christos Scroll window WIN N lines backwards.  Both WIN and N are optional, N\n\
   1039  1.8  christos defaults to 1, and WIN defaults to the currently focused window."));
   1040  1.9  christos   add_com ("<", class_tui, tui_scroll_left_command, _("\
   1041  1.9  christos Scroll window text to the left.\n\
   1042  1.9  christos Usage: < [N] [WIN]\n\
   1043  1.8  christos Scroll window WIN N characters left.  Both WIN and N are optional, N\n\
   1044  1.8  christos defaults to 1, and WIN defaults to the currently focused window."));
   1045  1.9  christos   add_com (">", class_tui, tui_scroll_right_command, _("\
   1046  1.9  christos Scroll window text to the right.\n\
   1047  1.9  christos Usage: > [N] [WIN]\n\
   1048  1.8  christos Scroll window WIN N characters right.  Both WIN and N are optional, N\n\
   1049  1.8  christos defaults to 1, and WIN defaults to the currently focused window."));
   1050  1.8  christos 
   1051  1.8  christos   /* Define the tui control variables.  */
   1052  1.8  christos   add_setshow_enum_cmd ("border-kind", no_class, tui_border_kind_enums,
   1053  1.8  christos 			&tui_border_kind, _("\
   1054  1.8  christos Set the kind of border for TUI windows."), _("\
   1055  1.9  christos Show the kind of border for TUI windows."), _("\
   1056  1.9  christos This variable controls the border of TUI windows:\n\
   1057  1.9  christos    space           use a white space\n\
   1058  1.8  christos    ascii           use ascii characters + - | for the border\n\
   1059  1.8  christos    acs             use the Alternate Character Set"),
   1060  1.8  christos 			tui_set_var_cmd,
   1061  1.8  christos 			show_tui_border_kind,
   1062  1.8  christos 			&tui_setlist, &tui_showlist);
   1063  1.8  christos 
   1064  1.8  christos   add_setshow_enum_cmd ("border-mode", no_class, tui_border_mode_enums,
   1065  1.8  christos 			&tui_border_mode, _("\
   1066  1.8  christos Set the attribute mode to use for the TUI window borders."), _("\
   1067  1.9  christos Show the attribute mode to use for the TUI window borders."), _("\
   1068  1.9  christos This variable controls the attributes to use for the window borders:\n\
   1069  1.9  christos    normal          normal display\n\
   1070  1.9  christos    standout        use highlight mode of terminal\n\
   1071  1.9  christos    reverse         use reverse video mode\n\
   1072  1.9  christos    half            use half bright\n\
   1073  1.9  christos    half-standout   use half bright and standout mode\n\
   1074  1.8  christos    bold            use extra bright or bold\n\
   1075  1.8  christos    bold-standout   use extra bright or bold with standout mode"),
   1076  1.8  christos 			tui_set_var_cmd,
   1077  1.8  christos 			show_tui_border_mode,
   1078  1.8  christos 			&tui_setlist, &tui_showlist);
   1079  1.8  christos 
   1080  1.8  christos   add_setshow_enum_cmd ("active-border-mode", no_class, tui_border_mode_enums,
   1081  1.8  christos 			&tui_active_border_mode, _("\
   1082  1.8  christos Set the attribute mode to use for the active TUI window border."), _("\
   1083  1.9  christos Show the attribute mode to use for the active TUI window border."), _("\
   1084  1.9  christos This variable controls the attributes to use for the active window border:\n\
   1085  1.9  christos    normal          normal display\n\
   1086  1.9  christos    standout        use highlight mode of terminal\n\
   1087  1.9  christos    reverse         use reverse video mode\n\
   1088  1.9  christos    half            use half bright\n\
   1089  1.9  christos    half-standout   use half bright and standout mode\n\
   1090  1.8  christos    bold            use extra bright or bold\n\
   1091  1.8  christos    bold-standout   use extra bright or bold with standout mode"),
   1092  1.8  christos 			tui_set_var_cmd,
   1093  1.8  christos 			show_tui_active_border_mode,
   1094  1.8  christos 			&tui_setlist, &tui_showlist);
   1095  1.8  christos 
   1096  1.8  christos   add_setshow_zuinteger_cmd ("tab-width", no_class,
   1097  1.9  christos 			     &internal_tab_width, _("\
   1098  1.8  christos Set the tab width, in characters, for the TUI."), _("\
   1099  1.8  christos Show the tab witdh, in characters, for the TUI."), _("\
   1100  1.8  christos This variable controls how many spaces are used to display a tab character."),
   1101  1.9  christos 			     tui_set_tab_width, tui_show_tab_width,
   1102  1.9  christos 			     &tui_setlist, &tui_showlist);
   1103  1.9  christos 
   1104  1.9  christos   add_setshow_boolean_cmd ("tui-resize-message", class_maintenance,
   1105  1.9  christos 			   &resize_message, _("\
   1106  1.9  christos Set TUI resize messaging."), _("\
   1107  1.9  christos Show TUI resize messaging."), _("\
   1108  1.9  christos When enabled GDB will print a message when the terminal is resized."),
   1109  1.9  christos 			   nullptr,
   1110  1.9  christos 			   show_tui_resize_message,
   1111  1.9  christos 			   &maintenance_set_cmdlist,
   1112  1.9  christos 			   &maintenance_show_cmdlist);
   1113  1.9  christos 
   1114  1.9  christos   add_setshow_boolean_cmd ("compact-source", class_tui,
   1115  1.9  christos 			   &compact_source, _("\
   1116  1.9  christos Set whether the TUI source window is compact."), _("\
   1117  1.9  christos Show whether the TUI source window is compact."), _("\
   1118  1.9  christos This variable controls whether the TUI source window is shown\n\
   1119  1.9  christos in a compact form.  The compact form puts the source closer to\n\
   1120  1.9  christos the line numbers and uses less horizontal space."),
   1121  1.9  christos 			   tui_set_compact_source, tui_show_compact_source,
   1122  1.9  christos 			   &tui_setlist, &tui_showlist);
   1123  1.9  christos 
   1124  1.8  christos   tui_border_style.changed.attach (tui_rehighlight_all);
   1125                  tui_active_border_style.changed.attach (tui_rehighlight_all);
   1126                }
   1127