]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/tui/tui-win.c
[gdb/tui] Introduce translate_acs
[thirdparty/binutils-gdb.git] / gdb / tui / tui-win.c
CommitLineData
f377b406 1/* TUI window generic functions.
f33c6cbf 2
213516ef 3 Copyright (C) 1998-2023 Free Software Foundation, Inc.
f33c6cbf 4
f377b406 5 Contributed by Hewlett-Packard Company.
c906108c 6
f377b406
SC
7 This file is part of GDB.
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
a9762ec7 11 the Free Software Foundation; either version 3 of the License, or
f377b406
SC
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
a9762ec7 20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
f377b406
SC
21
22/* This module contains procedures for handling tui window functions
23 like resize, scrolling, scrolling, changing focus, etc.
24
25 Author: Susan B. Macchia */
c906108c 26
c906108c
SS
27#include "defs.h"
28#include "command.h"
29#include "symtab.h"
30#include "breakpoint.h"
31#include "frame.h"
41783295 32#include "cli/cli-cmds.h"
a2a7af0c 33#include "cli/cli-style.h"
3e752b04 34#include "top.h"
52575520 35#include "source.h"
400b5eca 36#include "gdbsupport/event-loop.h"
45e42163 37#include "gdbcmd.h"
93b54c8e 38#include "async-event.h"
deb1ba4e 39#include "utils.h"
c906108c 40
d7b2e967 41#include "tui/tui.h"
c4ef48c6 42#include "tui/tui-io.h"
ce38393b 43#include "tui/tui-command.h"
d7b2e967 44#include "tui/tui-data.h"
3df505f6 45#include "tui/tui-layout.h"
d7b2e967
AC
46#include "tui/tui-wingeneral.h"
47#include "tui/tui-stack.h"
48#include "tui/tui-regs.h"
49#include "tui/tui-disasm.h"
50#include "tui/tui-source.h"
51#include "tui/tui-winsource.h"
2c0b251b 52#include "tui/tui-win.h"
c906108c 53
6a83354a 54#include "gdb_curses.h"
96ec9981 55#include <ctype.h>
dbda9972 56#include "readline/readline.h"
9f6ad286 57#include "gdbsupport/gdb_string_view.h"
96ec9981 58
9612b5ec
UW
59#include <signal.h>
60
0b39b52e
TT
61static void tui_set_tab_width_command (const char *, int);
62static void tui_refresh_all_command (const char *, int);
1d12d88f 63static void tui_all_windows_info (const char *, int);
0b39b52e
TT
64static void tui_scroll_forward_command (const char *, int);
65static void tui_scroll_backward_command (const char *, int);
66static void tui_scroll_left_command (const char *, int);
67static void tui_scroll_right_command (const char *, int);
68static void parse_scrolling_args (const char *,
08ef48c5
MS
69 struct tui_win_info **,
70 int *);
c906108c
SS
71
72
17aae570
SC
73#ifndef ACS_LRCORNER
74# define ACS_LRCORNER '+'
75#endif
76#ifndef ACS_LLCORNER
77# define ACS_LLCORNER '+'
78#endif
79#ifndef ACS_ULCORNER
80# define ACS_ULCORNER '+'
81#endif
82#ifndef ACS_URCORNER
83# define ACS_URCORNER '+'
84#endif
85#ifndef ACS_HLINE
86# define ACS_HLINE '-'
87#endif
88#ifndef ACS_VLINE
89# define ACS_VLINE '|'
90#endif
91
af101512 92/* Possible values for tui-border-kind variable. */
40478521 93static const char *const tui_border_kind_enums[] = {
af101512
SC
94 "space",
95 "ascii",
96 "acs",
97 NULL
98};
99
100/* Possible values for tui-border-mode and tui-active-border-mode. */
40478521 101static const char *const tui_border_mode_enums[] = {
af101512
SC
102 "normal",
103 "standout",
104 "reverse",
105 "half",
106 "half-standout",
107 "bold",
108 "bold-standout",
109 NULL
110};
111
112struct tui_translate
113{
114 const char *name;
115 int value;
116};
117
118/* Translation table for border-mode variables.
ec1115b3 119 The list of values must be terminated by a NULL. */
3d34df0a 120static struct tui_translate tui_border_mode_translate[] = {
af101512
SC
121 { "normal", A_NORMAL },
122 { "standout", A_STANDOUT },
123 { "reverse", A_REVERSE },
124 { "half", A_DIM },
125 { "half-standout", A_DIM | A_STANDOUT },
126 { "bold", A_BOLD },
127 { "bold-standout", A_BOLD | A_STANDOUT },
ec1115b3 128 { 0, 0 }
af101512
SC
129};
130
0bad8af9
TV
131/* Translation tables for border-kind (acs excluded), one for each border
132 character (see wborder, border curses operations). */
3d34df0a 133static struct tui_translate tui_border_kind_translate_vline[] = {
af101512
SC
134 { "space", ' ' },
135 { "ascii", '|' },
ec1115b3 136 { 0, 0 }
af101512
SC
137};
138
3d34df0a 139static struct tui_translate tui_border_kind_translate_hline[] = {
af101512
SC
140 { "space", ' ' },
141 { "ascii", '-' },
ec1115b3 142 { 0, 0 }
af101512
SC
143};
144
3d34df0a 145static struct tui_translate tui_border_kind_translate_ulcorner[] = {
af101512
SC
146 { "space", ' ' },
147 { "ascii", '+' },
ec1115b3 148 { 0, 0 }
af101512
SC
149};
150
3d34df0a 151static struct tui_translate tui_border_kind_translate_urcorner[] = {
af101512
SC
152 { "space", ' ' },
153 { "ascii", '+' },
ec1115b3 154 { 0, 0 }
af101512
SC
155};
156
3d34df0a 157static struct tui_translate tui_border_kind_translate_llcorner[] = {
af101512
SC
158 { "space", ' ' },
159 { "ascii", '+' },
ec1115b3 160 { 0, 0 }
af101512
SC
161};
162
3d34df0a 163static struct tui_translate tui_border_kind_translate_lrcorner[] = {
af101512
SC
164 { "space", ' ' },
165 { "ascii", '+' },
ec1115b3 166 { 0, 0 }
af101512
SC
167};
168
169
170/* Tui configuration variables controlled with set/show command. */
3d34df0a 171static const char *tui_active_border_mode = "bold-standout";
920d2a44 172static void
08ef48c5
MS
173show_tui_active_border_mode (struct ui_file *file,
174 int from_tty,
175 struct cmd_list_element *c,
176 const char *value)
920d2a44 177{
6cb06a8c 178 gdb_printf (file, _("\
920d2a44 179The attribute mode to use for the active TUI window border is \"%s\".\n"),
6cb06a8c 180 value);
920d2a44
AC
181}
182
3d34df0a 183static const char *tui_border_mode = "normal";
920d2a44 184static void
08ef48c5
MS
185show_tui_border_mode (struct ui_file *file,
186 int from_tty,
187 struct cmd_list_element *c,
188 const char *value)
920d2a44 189{
6cb06a8c 190 gdb_printf (file, _("\
920d2a44 191The attribute mode to use for the TUI window borders is \"%s\".\n"),
6cb06a8c 192 value);
920d2a44
AC
193}
194
3d34df0a 195static const char *tui_border_kind = "acs";
920d2a44 196static void
08ef48c5
MS
197show_tui_border_kind (struct ui_file *file,
198 int from_tty,
199 struct cmd_list_element *c,
200 const char *value)
920d2a44 201{
6cb06a8c
TT
202 gdb_printf (file, _("The kind of border for TUI windows is \"%s\".\n"),
203 value);
920d2a44
AC
204}
205
92c1d07d
PA
206/* Implementation of the "set/show style tui-current-position" commands. */
207
208bool style_tui_current_position = false;
209
210static void
211show_style_tui_current_position (ui_file *file,
212 int from_tty,
213 cmd_list_element *c,
214 const char *value)
215{
216 gdb_printf (file, _("\
217Styling the text highlighted by the TUI's current position indicator is %s.\n"),
218 value);
219}
220
221static void
222set_style_tui_current_position (const char *ignore, int from_tty,
223 cmd_list_element *c)
224{
225 if (TUI_SRC_WIN != nullptr)
226 TUI_SRC_WIN->refill ();
227 if (TUI_DISASM_WIN != nullptr)
228 TUI_DISASM_WIN->refill ();
229}
af101512 230
1cc6d956
MS
231/* Tui internal configuration variables. These variables are updated
232 by tui_update_variables to reflect the tui configuration
af101512
SC
233 variables. */
234chtype tui_border_vline;
235chtype tui_border_hline;
236chtype tui_border_ulcorner;
237chtype tui_border_urcorner;
238chtype tui_border_llcorner;
239chtype tui_border_lrcorner;
240
241int tui_border_attrs;
242int tui_active_border_attrs;
243
ec1115b3 244/* Identify the item in the translation table. */
af101512
SC
245static struct tui_translate *
246translate (const char *name, struct tui_translate *table)
247{
248 while (table->name)
249 {
250 if (name && strcmp (table->name, name) == 0)
dda83cd7 251 return table;
af101512
SC
252 table++;
253 }
254
ec1115b3 255 gdb_assert_not_reached ("");
af101512
SC
256}
257
0bad8af9
TV
258/* Translate NAME to a value. If NAME is "acs", use ACS_CHAR. Otherwise, use
259 translation table TABLE. */
260static int
261translate_acs (const char *name, struct tui_translate *table, int acs_char)
262{
263 /* The ACS characters are determined at run time by curses terminal
264 management. */
265 if (strcmp (name, "acs") == 0)
266 return acs_char;
267
268 return translate (name, table)->value;
269}
270
af101512
SC
271/* Update the tui internal configuration according to gdb settings.
272 Returns 1 if the configuration has changed and the screen should
273 be redrawn. */
87d557ae
TT
274bool
275tui_update_variables ()
af101512 276{
87d557ae 277 bool need_redraw = false;
af101512
SC
278 struct tui_translate *entry;
279
280 entry = translate (tui_border_mode, tui_border_mode_translate);
ba769bb0
TV
281 need_redraw
282 |= assign_return_if_changed<int> (tui_border_attrs, entry->value);
283
af101512 284 entry = translate (tui_active_border_mode, tui_border_mode_translate);
ba769bb0
TV
285 need_redraw
286 |= assign_return_if_changed<int> (tui_active_border_attrs, entry->value);
af101512 287
0bad8af9
TV
288 /* If one corner changes, all characters are changed. Only check the first
289 one. */
290 int val = translate_acs (tui_border_kind, tui_border_kind_translate_lrcorner,
291 ACS_LRCORNER);
ba769bb0
TV
292 need_redraw |= assign_return_if_changed<chtype> (tui_border_lrcorner, val);
293
0bad8af9
TV
294 tui_border_llcorner
295 = translate_acs (tui_border_kind, tui_border_kind_translate_llcorner,
296 ACS_LLCORNER);
af101512 297
0bad8af9
TV
298 tui_border_ulcorner
299 = translate_acs (tui_border_kind, tui_border_kind_translate_ulcorner,
300 ACS_ULCORNER);
af101512 301
0bad8af9
TV
302 tui_border_urcorner =
303 translate_acs (tui_border_kind, tui_border_kind_translate_urcorner,
304 ACS_URCORNER);
af101512 305
0bad8af9
TV
306 tui_border_hline
307 = translate_acs (tui_border_kind, tui_border_kind_translate_hline,
308 ACS_HLINE);
af101512 309
0bad8af9
TV
310 tui_border_vline
311 = translate_acs (tui_border_kind, tui_border_kind_translate_vline,
312 ACS_VLINE);
af101512
SC
313
314 return need_redraw;
315}
316
10f59415
SC
317static struct cmd_list_element *tuilist;
318
10f59415 319struct cmd_list_element **
da745b36 320tui_get_cmd_list (void)
10f59415
SC
321{
322 if (tuilist == 0)
0743fc83
TT
323 add_basic_prefix_cmd ("tui", class_tui,
324 _("Text User Interface commands."),
2f822da5 325 &tuilist, 0, &cmdlist);
10f59415
SC
326 return &tuilist;
327}
328
6cdb25f4
EZ
329/* The set_func hook of "set tui ..." commands that affect the window
330 borders on the TUI display. */
3b5c1d49
SM
331
332static void
eb4c3f4a
TT
333tui_set_var_cmd (const char *null_args,
334 int from_tty, struct cmd_list_element *c)
6cdb25f4
EZ
335{
336 if (tui_update_variables () && tui_active)
337 tui_rehighlight_all ();
338}
339
45e42163
TT
340\f
341
342/* True if TUI resizes should print a message. This is used by the
343 test suite. */
344
345static bool resize_message;
346
347static void
348show_tui_resize_message (struct ui_file *file, int from_tty,
349 struct cmd_list_element *c, const char *value)
350{
6cb06a8c 351 gdb_printf (file, _("TUI resize messaging is %s.\n"), value);
45e42163
TT
352}
353
354\f
355
97605e61 356/* Generic window name completion function. Complete window name pointed
6db98f02
AB
357 to by TEXT and WORD.
358
359 If EXCLUDE_CANNOT_FOCUS_P is true, then windows that can't take focus
360 will be excluded from the completions, otherwise they will be included.
361
362 If INCLUDE_NEXT_PREV_P is true then the special window names 'next' and
363 'prev' will also be considered as possible completions of the window
364 name. This is independent of EXCLUDE_CANNOT_FOCUS_P. */
2e52ae68 365
eb3ff9a5
PA
366static void
367window_name_completer (completion_tracker &tracker,
6db98f02
AB
368 bool include_next_prev_p,
369 bool exclude_cannot_focus_p,
97605e61 370 const char *text, const char *word)
2e52ae68 371{
625ad440 372 std::vector<const char *> completion_name_vec;
2e52ae68 373
1ce3e844 374 for (tui_win_info *win_info : all_tui_windows ())
2e52ae68
PP
375 {
376 const char *completion_name = NULL;
377
6db98f02 378 /* Don't include an invisible window. */
2d83e710 379 if (!win_info->is_visible ())
2e52ae68
PP
380 continue;
381
6db98f02
AB
382 /* If requested, exclude windows that can't be focused. */
383 if (exclude_cannot_focus_p && !win_info->can_focus ())
384 continue;
385
1ce3e844 386 completion_name = win_info->name ();
150375dc 387 gdb_assert (completion_name != NULL);
625ad440 388 completion_name_vec.push_back (completion_name);
2e52ae68
PP
389 }
390
391 /* If no windows are considered visible then the TUI has not yet been
392 initialized. But still "focus src" and "focus cmd" will work because
393 invoking the focus command will entail initializing the TUI which sets the
416eb92d 394 default layout to "src". */
625ad440 395 if (completion_name_vec.empty ())
2e52ae68 396 {
625ad440
SM
397 completion_name_vec.push_back (SRC_NAME);
398 completion_name_vec.push_back (CMD_NAME);
2e52ae68
PP
399 }
400
97605e61
AB
401 if (include_next_prev_p)
402 {
625ad440
SM
403 completion_name_vec.push_back ("next");
404 completion_name_vec.push_back ("prev");
97605e61 405 }
2e52ae68 406
2e52ae68 407
625ad440
SM
408 completion_name_vec.push_back (NULL);
409 complete_on_enum (tracker, completion_name_vec.data (), text, word);
2e52ae68
PP
410}
411
97605e61
AB
412/* Complete possible window names to focus on. TEXT is the complete text
413 entered so far, WORD is the word currently being completed. */
414
eb3ff9a5 415static void
97605e61 416focus_completer (struct cmd_list_element *ignore,
eb3ff9a5
PA
417 completion_tracker &tracker,
418 const char *text, const char *word)
97605e61 419{
6db98f02 420 window_name_completer (tracker, true, true, text, word);
97605e61
AB
421}
422
423/* Complete possible window names for winheight command. TEXT is the
424 complete text entered so far, WORD is the word currently being
425 completed. */
426
eb3ff9a5 427static void
97605e61 428winheight_completer (struct cmd_list_element *ignore,
eb3ff9a5 429 completion_tracker &tracker,
97605e61
AB
430 const char *text, const char *word)
431{
432 /* The first word is the window name. That we can complete. Subsequent
433 words can't be completed. */
434 if (word != text)
eb3ff9a5 435 return;
97605e61 436
6db98f02 437 window_name_completer (tracker, false, false, text, word);
97605e61
AB
438}
439
3e752b04
SC
440/* Update gdb's knowledge of the terminal size. */
441void
d02c80cd 442tui_update_gdb_sizes (void)
3e752b04 443{
d6e5e7f7
PP
444 int width, height;
445
446 if (tui_active)
447 {
cb2ce893
TT
448 width = TUI_CMD_WIN->width;
449 height = TUI_CMD_WIN->height;
d6e5e7f7
PP
450 }
451 else
452 {
453 width = tui_term_width ();
454 height = tui_term_height ();
455 }
456
457 set_screen_width_and_height (width, height);
3e752b04
SC
458}
459
c906108c 460
c906108c 461void
13446e05 462tui_win_info::forward_scroll (int num_to_scroll)
c906108c 463{
13446e05 464 if (num_to_scroll == 0)
cb2ce893 465 num_to_scroll = height - 3;
c906108c 466
c3bd716f 467 do_scroll_vertical (num_to_scroll);
a21fcd8f 468}
c906108c 469
c906108c 470void
13446e05 471tui_win_info::backward_scroll (int num_to_scroll)
c906108c 472{
13446e05 473 if (num_to_scroll == 0)
cb2ce893 474 num_to_scroll = height - 3;
13446e05 475
c3bd716f 476 do_scroll_vertical (-num_to_scroll);
a21fcd8f 477}
c906108c
SS
478
479
c906108c 480void
13446e05 481tui_win_info::left_scroll (int num_to_scroll)
c906108c 482{
13446e05
TT
483 if (num_to_scroll == 0)
484 num_to_scroll = 1;
485
c3bd716f 486 do_scroll_horizontal (num_to_scroll);
a21fcd8f 487}
c906108c
SS
488
489
c906108c 490void
13446e05 491tui_win_info::right_scroll (int num_to_scroll)
c906108c 492{
13446e05
TT
493 if (num_to_scroll == 0)
494 num_to_scroll = 1;
495
c3bd716f 496 do_scroll_horizontal (-num_to_scroll);
e8b915dc 497}
c906108c
SS
498
499
c906108c 500void
a21fcd8f 501tui_refresh_all_win (void)
c906108c 502{
3e266828 503 clearok (curscr, TRUE);
1ce3e844 504 tui_refresh_all ();
bc712bbf 505}
c906108c 506
6cdb25f4
EZ
507void
508tui_rehighlight_all (void)
509{
1ce3e844 510 for (tui_win_info *win_info : all_tui_windows ())
b4ef5aeb 511 win_info->check_and_display_highlight_if_needed ();
6cdb25f4 512}
c906108c 513
b021a221 514/* Resize all the windows based on the terminal size. This function
ae2b5380 515 gets called from within the readline SIGWINCH handler. */
c906108c 516void
6ba8e26f 517tui_resize_all (void)
c906108c 518{
6ba8e26f 519 int height_diff, width_diff;
9255ee31 520 int screenheight, screenwidth;
c906108c 521
9255ee31 522 rl_get_screen_size (&screenheight, &screenwidth);
deb1ba4e
TV
523 screenwidth += readline_hidden_cols;
524
6ba8e26f
AC
525 width_diff = screenwidth - tui_term_width ();
526 height_diff = screenheight - tui_term_height ();
527 if (height_diff || width_diff)
c906108c 528 {
10f59415
SC
529#ifdef HAVE_RESIZE_TERM
530 resize_term (screenheight, screenwidth);
531#endif
1cc6d956 532 /* Turn keypad off while we resize. */
82a5082e 533 keypad (TUI_CMD_WIN->handle.get (), FALSE);
3e752b04 534 tui_update_gdb_sizes ();
dd1abb8c
AC
535 tui_set_term_height_to (screenheight);
536 tui_set_term_width_to (screenwidth);
3d979945 537
c366c1f0 538 /* erase + clearok are used instead of a straightforward clear as
dda83cd7 539 AIX 5.3 does not define clear. */
c366c1f0
TT
540 erase ();
541 clearok (curscr, TRUE);
51b72f73
AB
542 /* Apply the current layout. The 'false' here allows the command
543 window to resize proportionately with containing terminal, rather
544 than maintaining a fixed size. */
545 tui_apply_current_layout (false); /* Turn keypad back on. */
82a5082e 546 keypad (TUI_CMD_WIN->handle.get (), TRUE);
c906108c 547 }
6ba8e26f 548}
c906108c 549
2c0b251b 550#ifdef SIGWINCH
c4ef48c6
PP
551/* Token for use by TUI's asynchronous SIGWINCH handler. */
552static struct async_signal_handler *tui_sigwinch_token;
553
554/* TUI's SIGWINCH signal handler. */
2c0b251b 555static void
6ba8e26f 556tui_sigwinch_handler (int signal)
c906108c 557{
c4ef48c6 558 mark_async_signal_handler (tui_sigwinch_token);
9abd8a65 559 tui_set_win_resized_to (true);
6ba8e26f 560}
c4ef48c6
PP
561
562/* Callback for asynchronously resizing TUI following a SIGWINCH signal. */
563static void
564tui_async_resize_screen (gdb_client_data arg)
565{
a88d0bb3
PP
566 rl_resize_terminal ();
567
c4ef48c6 568 if (!tui_active)
a88d0bb3
PP
569 {
570 int screen_height, screen_width;
c4ef48c6 571
a88d0bb3 572 rl_get_screen_size (&screen_height, &screen_width);
deb1ba4e 573 screen_width += readline_hidden_cols;
a88d0bb3
PP
574 set_screen_width_and_height (screen_width, screen_height);
575
576 /* win_resized is left set so that the next call to tui_enable()
577 resizes the TUI windows. */
578 }
579 else
580 {
9abd8a65 581 tui_set_win_resized_to (false);
a88d0bb3
PP
582 tui_resize_all ();
583 tui_refresh_all_win ();
584 tui_update_gdb_sizes ();
45e42163
TT
585 if (resize_message)
586 {
587 static int count;
588 printf_unfiltered ("@@ resize done %d, size = %dx%d\n", count,
589 tui_term_width (), tui_term_height ());
590 ++count;
591 }
a88d0bb3
PP
592 tui_redisplay_readline ();
593 }
c4ef48c6 594}
2c0b251b 595#endif
c906108c 596
c4ef48c6
PP
597/* Initialize TUI's SIGWINCH signal handler. Note that the handler is not
598 uninstalled when we exit TUI, so the handler should not assume that TUI is
599 always active. */
9612b5ec
UW
600void
601tui_initialize_win (void)
602{
603#ifdef SIGWINCH
c4ef48c6 604 tui_sigwinch_token
db20ebdf
SM
605 = create_async_signal_handler (tui_async_resize_screen, NULL,
606 "tui-sigwinch");
c4ef48c6
PP
607
608 {
9612b5ec 609#ifdef HAVE_SIGACTION
c4ef48c6 610 struct sigaction old_winch;
1c5313c5 611
c4ef48c6
PP
612 memset (&old_winch, 0, sizeof (old_winch));
613 old_winch.sa_handler = &tui_sigwinch_handler;
a344fc09 614#ifdef SA_RESTART
c4ef48c6 615 old_winch.sa_flags = SA_RESTART;
a344fc09 616#endif
c4ef48c6 617 sigaction (SIGWINCH, &old_winch, NULL);
9612b5ec 618#else
c4ef48c6 619 signal (SIGWINCH, &tui_sigwinch_handler);
9612b5ec 620#endif
c4ef48c6 621 }
9612b5ec
UW
622#endif
623}
c906108c
SS
624
625
c906108c 626static void
0b39b52e 627tui_scroll_forward_command (const char *arg, int from_tty)
c906108c 628{
6ba8e26f 629 int num_to_scroll = 1;
5b6fe301 630 struct tui_win_info *win_to_scroll;
c906108c 631
1854bb21
SC
632 /* Make sure the curses mode is enabled. */
633 tui_enable ();
63a33118 634 if (arg == NULL)
cafb3438 635 parse_scrolling_args (arg, &win_to_scroll, NULL);
c906108c 636 else
6ba8e26f 637 parse_scrolling_args (arg, &win_to_scroll, &num_to_scroll);
13446e05 638 win_to_scroll->forward_scroll (num_to_scroll);
e8b915dc 639}
c906108c
SS
640
641
c906108c 642static void
0b39b52e 643tui_scroll_backward_command (const char *arg, int from_tty)
c906108c 644{
6ba8e26f 645 int num_to_scroll = 1;
5b6fe301 646 struct tui_win_info *win_to_scroll;
c906108c 647
1854bb21
SC
648 /* Make sure the curses mode is enabled. */
649 tui_enable ();
63a33118 650 if (arg == NULL)
cafb3438 651 parse_scrolling_args (arg, &win_to_scroll, NULL);
c906108c 652 else
6ba8e26f 653 parse_scrolling_args (arg, &win_to_scroll, &num_to_scroll);
13446e05 654 win_to_scroll->backward_scroll (num_to_scroll);
e8b915dc 655}
c906108c
SS
656
657
c906108c 658static void
0b39b52e 659tui_scroll_left_command (const char *arg, int from_tty)
c906108c 660{
6ba8e26f 661 int num_to_scroll;
5b6fe301 662 struct tui_win_info *win_to_scroll;
c906108c 663
1854bb21
SC
664 /* Make sure the curses mode is enabled. */
665 tui_enable ();
6ba8e26f 666 parse_scrolling_args (arg, &win_to_scroll, &num_to_scroll);
13446e05 667 win_to_scroll->left_scroll (num_to_scroll);
e8b915dc 668}
c906108c
SS
669
670
c906108c 671static void
0b39b52e 672tui_scroll_right_command (const char *arg, int from_tty)
c906108c 673{
6ba8e26f 674 int num_to_scroll;
5b6fe301 675 struct tui_win_info *win_to_scroll;
c906108c 676
1854bb21
SC
677 /* Make sure the curses mode is enabled. */
678 tui_enable ();
6ba8e26f 679 parse_scrolling_args (arg, &win_to_scroll, &num_to_scroll);
13446e05 680 win_to_scroll->right_scroll (num_to_scroll);
e8b915dc 681}
c906108c
SS
682
683
9f6ad286
TT
684/* Answer the window represented by name. */
685static struct tui_win_info *
686tui_partial_win_by_name (gdb::string_view name)
687{
e098d18c
TT
688 struct tui_win_info *best = nullptr;
689
947f7597 690 for (tui_win_info *item : all_tui_windows ())
9f6ad286 691 {
947f7597
TV
692 const char *cur_name = item->name ();
693
694 if (name == cur_name)
695 return item;
696 if (startswith (cur_name, name))
9f6ad286 697 {
947f7597
TV
698 if (best != nullptr)
699 error (_("Window name \"%*s\" is ambiguous"),
700 (int) name.size (), name.data ());
701 best = item;
9f6ad286
TT
702 }
703 }
704
e098d18c 705 return best;
9f6ad286
TT
706}
707
6ba8e26f 708/* Set focus to the window named by 'arg'. */
c906108c 709static void
01aeb396 710tui_set_focus_command (const char *arg, int from_tty)
c906108c 711{
01aeb396
TT
712 tui_enable ();
713
ca793b96
TT
714 if (arg == NULL)
715 error_no_arg (_("name of window to focus"));
c906108c 716
ca793b96 717 struct tui_win_info *win_info = NULL;
c906108c 718
c5739418 719 if (startswith ("next", arg))
ca793b96 720 win_info = tui_next_win (tui_win_with_focus ());
c5739418 721 else if (startswith ("prev", arg))
ca793b96 722 win_info = tui_prev_win (tui_win_with_focus ());
c906108c 723 else
ca793b96
TT
724 win_info = tui_partial_win_by_name (arg);
725
58c6d2ac
AB
726 if (win_info == nullptr)
727 {
728 /* When WIN_INFO is nullptr this can either mean that the window name
729 is unknown to GDB, or that the window is not in the current
730 layout. To try and help the user, give a different error
731 depending on which of these is the case. */
732 std::string matching_window_name;
733 bool is_ambiguous = false;
734
735 for (const std::string &name : all_known_window_names ())
736 {
737 /* Look through all windows in the current layout, if the window
738 is in the current layout then we're not interested is it. */
739 for (tui_win_info *item : all_tui_windows ())
740 if (item->name () == name)
741 continue;
742
743 if (startswith (name, arg))
744 {
745 if (matching_window_name.empty ())
746 matching_window_name = name;
747 else
748 is_ambiguous = true;
749 }
750 };
751
752 if (!matching_window_name.empty ())
753 {
754 if (is_ambiguous)
755 error (_("No windows matching \"%s\" in the current layout"),
756 arg);
757 else
758 error (_("Window \"%s\" is not in the current layout"),
759 matching_window_name.c_str ());
760 }
761 else
762 error (_("Unrecognized window name \"%s\""), arg);
763 }
6789344a
AB
764
765 /* If a window is part of the current layout then it will have a
766 tui_win_info associated with it and be visible, otherwise, there will
767 be no tui_win_info and the above error will have been raised. */
768 gdb_assert (win_info->is_visible ());
ca793b96 769
24f3aded
AB
770 if (!win_info->can_focus ())
771 error (_("Window \"%s\" cannot be focused"), arg);
772
ca793b96 773 tui_set_win_focus_to (win_info);
6cb06a8c
TT
774 gdb_printf (_("Focus set to %s window.\n"),
775 tui_win_with_focus ()->name ());
6ba8e26f 776}
c906108c 777
c906108c 778static void
1d12d88f 779tui_all_windows_info (const char *arg, int from_tty)
c906108c 780{
82e3b564
TT
781 if (!tui_active)
782 {
6cb06a8c 783 gdb_printf (_("The TUI is not active.\n"));
82e3b564
TT
784 return;
785 }
786
5b6fe301 787 struct tui_win_info *win_with_focus = tui_win_with_focus ();
25a2915e
TT
788 struct ui_out *uiout = current_uiout;
789
f62843d7 790 ui_out_emit_table table_emitter (uiout, 4, -1, "tui-windows");
25a2915e
TT
791 uiout->table_header (10, ui_left, "name", "Name");
792 uiout->table_header (5, ui_right, "lines", "Lines");
f62843d7 793 uiout->table_header (7, ui_right, "columns", "Columns");
25a2915e
TT
794 uiout->table_header (10, ui_left, "focus", "Focus");
795 uiout->table_body ();
c906108c 796
1ce3e844 797 for (tui_win_info *win_info : all_tui_windows ())
2d83e710 798 if (win_info->is_visible ())
c906108c 799 {
25a2915e
TT
800 ui_out_emit_tuple tuple_emitter (uiout, nullptr);
801
802 uiout->field_string ("name", win_info->name ());
803 uiout->field_signed ("lines", win_info->height);
f62843d7 804 uiout->field_signed ("columns", win_info->width);
1ce3e844 805 if (win_with_focus == win_info)
25a2915e 806 uiout->field_string ("focus", _("(has focus)"));
c906108c 807 else
25a2915e
TT
808 uiout->field_skip ("focus");
809 uiout->text ("\n");
c906108c 810 }
6ba8e26f 811}
c906108c
SS
812
813
c906108c 814static void
0b39b52e 815tui_refresh_all_command (const char *arg, int from_tty)
c906108c 816{
1854bb21
SC
817 /* Make sure the curses mode is enabled. */
818 tui_enable ();
819
a21fcd8f 820 tui_refresh_all_win ();
c906108c
SS
821}
822
e555083f
TT
823#define DEFAULT_TAB_LEN 8
824
7806cea7
TT
825/* The tab width that should be used by the TUI. */
826
827unsigned int tui_tab_width = DEFAULT_TAB_LEN;
828
829/* The tab width as set by the user. */
830
831static unsigned int internal_tab_width = DEFAULT_TAB_LEN;
832
d83f1fe6
TT
833/* After the tab width is set, call this to update the relevant
834 windows. */
835
836static void
837update_tab_width ()
838{
1ce3e844 839 for (tui_win_info *win_info : all_tui_windows ())
7806cea7 840 {
2d83e710 841 if (win_info->is_visible ())
1ce3e844 842 win_info->update_tab_width ();
7806cea7
TT
843 }
844}
845
846/* Callback for "set tui tab-width". */
847
848static void
849tui_set_tab_width (const char *ignore,
850 int from_tty, struct cmd_list_element *c)
851{
852 if (internal_tab_width == 0)
853 {
854 internal_tab_width = tui_tab_width;
855 error (_("Tab width must not be 0"));
856 }
857
858 tui_tab_width = internal_tab_width;
859 update_tab_width ();
860}
861
862/* Callback for "show tui tab-width". */
863
864static void
865tui_show_tab_width (struct ui_file *file, int from_tty,
866 struct cmd_list_element *c, const char *value)
867{
6cb06a8c 868 gdb_printf (file, _("TUI tab width is %s spaces.\n"), value);
7806cea7
TT
869
870}
c906108c 871
d1da6b01
TT
872/* See tui-win.h. */
873
874bool compact_source = false;
875
876/* Callback for "set tui compact-source". */
877
878static void
879tui_set_compact_source (const char *ignore, int from_tty,
880 struct cmd_list_element *c)
881{
882 if (TUI_SRC_WIN != nullptr)
883 TUI_SRC_WIN->refill ();
884}
885
886/* Callback for "show tui compact-source". */
887
888static void
889tui_show_compact_source (struct ui_file *file, int from_tty,
890 struct cmd_list_element *c, const char *value)
891{
6cb06a8c 892 gdb_printf (file, _("TUI source window compactness is %s.\n"), value);
d1da6b01
TT
893}
894
c54da50d 895/* Set the tab width of the specified window. */
c906108c 896static void
0b39b52e 897tui_set_tab_width_command (const char *arg, int from_tty)
c906108c 898{
1854bb21
SC
899 /* Make sure the curses mode is enabled. */
900 tui_enable ();
63a33118 901 if (arg != NULL)
c906108c
SS
902 {
903 int ts;
904
905 ts = atoi (arg);
7806cea7
TT
906 if (ts <= 0)
907 warning (_("Tab widths greater than 0 must be specified."));
908 else
cb86fcc1 909 {
7806cea7
TT
910 internal_tab_width = ts;
911 tui_tab_width = ts;
912
913 update_tab_width ();
cb86fcc1 914 }
c906108c 915 }
6ba8e26f 916}
c906108c 917
160444ec
AB
918/* Helper function for the user commands to adjust a window's width or
919 height. The ARG string contains the command line arguments from the
920 user, which should give the name of a window, and how to adjust the
921 size.
922
923 When SET_WIDTH_P is true the width of the window is adjusted based on
924 ARG, and when SET_WIDTH_P is false, the height of the window is adjusted
925 based on ARG.
926
927 On invalid input, or if the size can't be adjusted as requested, then an
928 error is thrown, otherwise, the window sizes are adjusted, and the
929 windows redrawn. */
c906108c 930
c906108c 931static void
160444ec 932tui_set_win_size (const char *arg, bool set_width_p)
c906108c 933{
1854bb21
SC
934 /* Make sure the curses mode is enabled. */
935 tui_enable ();
ca793b96
TT
936 if (arg == NULL)
937 error_no_arg (_("name of window"));
c906108c 938
ca793b96
TT
939 const char *buf = arg;
940 const char *buf_ptr = buf;
160444ec 941 int new_size;
ca793b96 942 struct tui_win_info *win_info;
c906108c 943
ca793b96 944 buf_ptr = skip_to_space (buf_ptr);
78e8cb91 945
ca793b96
TT
946 /* Validate the window name. */
947 gdb::string_view wname (buf, buf_ptr - buf);
948 win_info = tui_partial_win_by_name (wname);
78e8cb91 949
ca793b96
TT
950 if (win_info == NULL)
951 error (_("Unrecognized window name \"%s\""), arg);
952 if (!win_info->is_visible ())
953 error (_("Window \"%s\" is not visible"), arg);
954
955 /* Process the size. */
956 buf_ptr = skip_spaces (buf_ptr);
957
958 if (*buf_ptr != '\0')
959 {
960 bool negate = false;
961 bool fixed_size = true;
962 int input_no;;
963
964 if (*buf_ptr == '+' || *buf_ptr == '-')
965 {
966 if (*buf_ptr == '-')
967 negate = true;
968 fixed_size = false;
969 buf_ptr++;
970 }
971 input_no = atoi (buf_ptr);
972 if (input_no > 0)
973 {
974 if (negate)
975 input_no *= (-1);
976 if (fixed_size)
160444ec 977 new_size = input_no;
ca793b96 978 else
160444ec
AB
979 {
980 int curr_size;
981 if (set_width_p)
982 curr_size = win_info->width;
983 else
984 curr_size = win_info->height;
985 new_size = curr_size + input_no;
986 }
ca793b96
TT
987
988 /* Now change the window's height, and adjust
989 all other windows around it. */
160444ec
AB
990 if (set_width_p)
991 tui_adjust_window_width (win_info, new_size);
992 else
993 tui_adjust_window_height (win_info, new_size);
ca793b96 994 tui_update_gdb_sizes ();
c906108c
SS
995 }
996 else
160444ec
AB
997 {
998 if (set_width_p)
999 error (_("Invalid window width specified"));
1000 else
1001 error (_("Invalid window height specified"));
1002 }
c906108c 1003 }
6ba8e26f 1004}
c906108c 1005
160444ec
AB
1006/* Implement the 'tui window height' command (alias 'winheight'). */
1007
1008static void
1009tui_set_win_height_command (const char *arg, int from_tty)
1010{
1011 /* Pass false as the final argument to set the height. */
1012 tui_set_win_size (arg, false);
1013}
1014
1015/* Implement the 'tui window width' command (alias 'winwidth'). */
1016
1017static void
1018tui_set_win_width_command (const char *arg, int from_tty)
1019{
1020 /* Pass true as the final argument to set the width. */
1021 tui_set_win_size (arg, true);
1022}
1023
5fcee43a 1024/* See tui-data.h. */
c906108c 1025
8903bd8a
TT
1026int
1027tui_win_info::max_height () const
1028{
b45b7407 1029 return tui_term_height ();
8903bd8a
TT
1030}
1031
7c043ba6
TT
1032/* See tui-data.h. */
1033
1034int
32c1e210 1035tui_win_info::max_width () const
7c043ba6 1036{
b45b7407 1037 return tui_term_width ();
7c043ba6
TT
1038}
1039
c906108c 1040static void
0b39b52e 1041parse_scrolling_args (const char *arg,
08ef48c5 1042 struct tui_win_info **win_to_scroll,
6ba8e26f 1043 int *num_to_scroll)
c906108c 1044{
6ba8e26f
AC
1045 if (num_to_scroll)
1046 *num_to_scroll = 0;
1047 *win_to_scroll = tui_win_with_focus ();
c906108c 1048
ef5eab5a
MS
1049 /* First set up the default window to scroll, in case there is no
1050 window name arg. */
63a33118 1051 if (arg != NULL)
c906108c 1052 {
f71c8822 1053 char *buf_ptr;
c906108c 1054
1cc6d956 1055 /* Process the number of lines to scroll. */
f71c8822
TT
1056 std::string copy = arg;
1057 buf_ptr = &copy[0];
6ba8e26f 1058 if (isdigit (*buf_ptr))
c906108c 1059 {
6ba8e26f 1060 char *num_str;
c906108c 1061
6ba8e26f
AC
1062 num_str = buf_ptr;
1063 buf_ptr = strchr (buf_ptr, ' ');
63a33118 1064 if (buf_ptr != NULL)
c906108c 1065 {
78e8cb91 1066 *buf_ptr = '\0';
6ba8e26f
AC
1067 if (num_to_scroll)
1068 *num_to_scroll = atoi (num_str);
1069 buf_ptr++;
c906108c 1070 }
6ba8e26f
AC
1071 else if (num_to_scroll)
1072 *num_to_scroll = atoi (num_str);
c906108c
SS
1073 }
1074
1cc6d956 1075 /* Process the window name if one is specified. */
63a33118 1076 if (buf_ptr != NULL)
c906108c 1077 {
a121b7c1 1078 const char *wname;
c906108c 1079
78e8cb91 1080 wname = skip_spaces (buf_ptr);
c906108c 1081
78e8cb91 1082 if (*wname != '\0')
c709a7c2 1083 {
78e8cb91
TT
1084 *win_to_scroll = tui_partial_win_by_name (wname);
1085
1086 if (*win_to_scroll == NULL)
1087 error (_("Unrecognized window `%s'"), wname);
1088 if (!(*win_to_scroll)->is_visible ())
1089 error (_("Window is not visible"));
1090 else if (*win_to_scroll == TUI_CMD_WIN)
1091 *win_to_scroll = *(tui_source_windows ().begin ());
c709a7c2 1092 }
c906108c 1093 }
c906108c 1094 }
6ba8e26f 1095}
7806cea7 1096
51c2a9e2
AB
1097/* The list of 'tui window' sub-commands. */
1098
1099static cmd_list_element *tui_window_cmds = nullptr;
1100
1101/* Called to implement 'tui window'. */
1102
1103static void
1104tui_window_command (const char *args, int from_tty)
1105{
1106 help_list (tui_window_cmds, "tui window ", all_commands, gdb_stdout);
1107}
1108
58b77c6a
TV
1109/* See tui-win.h. */
1110
1111bool tui_left_margin_verbose = false;
1112
7806cea7
TT
1113/* Function to initialize gdb commands, for tui window
1114 manipulation. */
1115
6c265988 1116void _initialize_tui_win ();
7806cea7 1117void
6c265988 1118_initialize_tui_win ()
7806cea7
TT
1119{
1120 static struct cmd_list_element *tui_setlist;
1121 static struct cmd_list_element *tui_showlist;
7806cea7
TT
1122
1123 /* Define the classes of commands.
1124 They will appear in the help list in the reverse of this order. */
f54bdb6d
SM
1125 add_setshow_prefix_cmd ("tui", class_tui,
1126 _("TUI configuration variables."),
1127 _("TUI configuration variables."),
1128 &tui_setlist, &tui_showlist,
1129 &setlist, &showlist);
7806cea7 1130
51c2a9e2
AB
1131 cmd_list_element *refresh_cmd
1132 = add_cmd ("refresh", class_tui, tui_refresh_all_command,
1133 _("Refresh the terminal display."),
1134 tui_get_cmd_list ());
1135 add_com_alias ("refresh", refresh_cmd, class_tui, 0);
7806cea7 1136
3947f654
SM
1137 cmd_list_element *tabset_cmd
1138 = add_com ("tabset", class_tui, tui_set_tab_width_command, _("\
7806cea7 1139Set the width (in characters) of tab stops.\n\
89549d7f 1140Usage: tabset N"));
3947f654 1141 deprecate_cmd (tabset_cmd, "set tui tab-width");
7806cea7 1142
51c2a9e2
AB
1143 /* Setup the 'tui window' list of command. */
1144 add_prefix_cmd ("window", class_tui, tui_window_command,
1145 _("Text User Interface window commands."),
1146 &tui_window_cmds, 1, tui_get_cmd_list ());
1147
3947f654 1148 cmd_list_element *winheight_cmd
51c2a9e2 1149 = add_cmd ("height", class_tui, tui_set_win_height_command, _("\
ca793b96 1150Set or modify the height of a specified window.\n\
51c2a9e2
AB
1151Usage: tui window height WINDOW-NAME [+ | -] NUM-LINES\n\
1152Use \"info win\" to see the names of the windows currently being displayed."),
1153 &tui_window_cmds);
1154 add_com_alias ("winheight", winheight_cmd, class_tui, 0);
3947f654
SM
1155 add_com_alias ("wh", winheight_cmd, class_tui, 0);
1156 set_cmd_completer (winheight_cmd, winheight_completer);
160444ec
AB
1157
1158 cmd_list_element *winwidth_cmd
1159 = add_cmd ("width", class_tui, tui_set_win_width_command, _("\
1160Set or modify the width of a specified window.\n\
1161Usage: tui window width WINDOW-NAME [+ | -] NUM-LINES\n\
1162Use \"info win\" to see the names of the windows currently being displayed."),
1163 &tui_window_cmds);
1164 add_com_alias ("winwidth", winwidth_cmd, class_tui, 0);
1165 set_cmd_completer (winwidth_cmd, winheight_completer);
1166
7806cea7 1167 add_info ("win", tui_all_windows_info,
283be8bf
TT
1168 _("List of all displayed windows.\n\
1169Usage: info win"));
3947f654 1170 cmd_list_element *focus_cmd
51c2a9e2 1171 = add_cmd ("focus", class_tui, tui_set_focus_command, _("\
ca793b96 1172Set focus to named window or next/prev window.\n\
51c2a9e2
AB
1173Usage: tui focus [WINDOW-NAME | next | prev]\n\
1174Use \"info win\" to see the names of the windows currently being displayed."),
1175 tui_get_cmd_list ());
1176 add_com_alias ("focus", focus_cmd, class_tui, 0);
3947f654
SM
1177 add_com_alias ("fs", focus_cmd, class_tui, 0);
1178 set_cmd_completer (focus_cmd, focus_completer);
7806cea7
TT
1179 add_com ("+", class_tui, tui_scroll_forward_command, _("\
1180Scroll window forward.\n\
7a27a45b
AB
1181Usage: + [N] [WIN]\n\
1182Scroll window WIN N lines forwards. Both WIN and N are optional, N\n\
1183defaults to 1, and WIN defaults to the currently focused window."));
7806cea7
TT
1184 add_com ("-", class_tui, tui_scroll_backward_command, _("\
1185Scroll window backward.\n\
7a27a45b
AB
1186Usage: - [N] [WIN]\n\
1187Scroll window WIN N lines backwards. Both WIN and N are optional, N\n\
1188defaults to 1, and WIN defaults to the currently focused window."));
7806cea7
TT
1189 add_com ("<", class_tui, tui_scroll_left_command, _("\
1190Scroll window text to the left.\n\
7a27a45b
AB
1191Usage: < [N] [WIN]\n\
1192Scroll window WIN N characters left. Both WIN and N are optional, N\n\
1193defaults to 1, and WIN defaults to the currently focused window."));
7806cea7
TT
1194 add_com (">", class_tui, tui_scroll_right_command, _("\
1195Scroll window text to the right.\n\
7a27a45b
AB
1196Usage: > [N] [WIN]\n\
1197Scroll window WIN N characters right. Both WIN and N are optional, N\n\
1198defaults to 1, and WIN defaults to the currently focused window."));
7806cea7
TT
1199
1200 /* Define the tui control variables. */
1201 add_setshow_enum_cmd ("border-kind", no_class, tui_border_kind_enums,
1202 &tui_border_kind, _("\
1203Set the kind of border for TUI windows."), _("\
1204Show the kind of border for TUI windows."), _("\
1205This variable controls the border of TUI windows:\n\
89549d7f
TT
1206 space use a white space\n\
1207 ascii use ascii characters + - | for the border\n\
1208 acs use the Alternate Character Set"),
7806cea7
TT
1209 tui_set_var_cmd,
1210 show_tui_border_kind,
1211 &tui_setlist, &tui_showlist);
1212
45601fb8 1213 const std::string help_attribute_mode (_("\
89549d7f
TT
1214 normal normal display\n\
1215 standout use highlight mode of terminal\n\
1216 reverse use reverse video mode\n\
1217 half use half bright\n\
1218 half-standout use half bright and standout mode\n\
1219 bold use extra bright or bold\n\
45601fb8
TV
1220 bold-standout use extra bright or bold with standout mode"));
1221
1222 const std::string help_tui_border_mode
1223 = (_("\
1224This variable controls the attributes to use for the window borders:\n")
1225 + help_attribute_mode);
dcb16346
TV
1226
1227 add_setshow_enum_cmd ("border-mode", no_class, tui_border_mode_enums,
1228 &tui_border_mode, _("\
1229Set the attribute mode to use for the TUI window borders."), _("\
1230Show the attribute mode to use for the TUI window borders."),
45601fb8 1231 help_tui_border_mode.c_str (),
7806cea7
TT
1232 tui_set_var_cmd,
1233 show_tui_border_mode,
1234 &tui_setlist, &tui_showlist);
1235
45601fb8
TV
1236 const std::string help_tui_active_border_mode
1237 = (_("\
1238This variable controls the attributes to use for the active window borders:\n")
1239 + help_attribute_mode);
1240
7806cea7
TT
1241 add_setshow_enum_cmd ("active-border-mode", no_class, tui_border_mode_enums,
1242 &tui_active_border_mode, _("\
1243Set the attribute mode to use for the active TUI window border."), _("\
dcb16346 1244Show the attribute mode to use for the active TUI window border."),
45601fb8 1245 help_tui_active_border_mode.c_str (),
7806cea7
TT
1246 tui_set_var_cmd,
1247 show_tui_active_border_mode,
1248 &tui_setlist, &tui_showlist);
1249
1250 add_setshow_zuinteger_cmd ("tab-width", no_class,
1251 &internal_tab_width, _("\
1252Set the tab width, in characters, for the TUI."), _("\
2829d6da 1253Show the tab width, in characters, for the TUI."), _("\
7806cea7
TT
1254This variable controls how many spaces are used to display a tab character."),
1255 tui_set_tab_width, tui_show_tab_width,
1256 &tui_setlist, &tui_showlist);
45e42163
TT
1257
1258 add_setshow_boolean_cmd ("tui-resize-message", class_maintenance,
1259 &resize_message, _("\
1260Set TUI resize messaging."), _("\
1261Show TUI resize messaging."), _("\
1262When enabled GDB will print a message when the terminal is resized."),
1263 nullptr,
1264 show_tui_resize_message,
1265 &maintenance_set_cmdlist,
1266 &maintenance_show_cmdlist);
d1da6b01
TT
1267
1268 add_setshow_boolean_cmd ("compact-source", class_tui,
1269 &compact_source, _("\
1270Set whether the TUI source window is compact."), _("\
1271Show whether the TUI source window is compact."), _("\
1272This variable controls whether the TUI source window is shown\n\
2093c2af 1273in a compact form. The compact form uses less horizontal space."),
d1da6b01
TT
1274 tui_set_compact_source, tui_show_compact_source,
1275 &tui_setlist, &tui_showlist);
a2a7af0c 1276
92c1d07d
PA
1277 add_setshow_boolean_cmd ("tui-current-position", class_maintenance,
1278 &style_tui_current_position, _("\
1279Set whether to style text highlighted by the TUI's current position indicator."),
1280 _("\
1281Show whether to style text highlighted by the TUI's current position indicator."),
1282 _("\
1283When enabled, the source and assembly code highlighted by the TUI's current\n\
1284position indicator is styled."),
1285 set_style_tui_current_position,
1286 show_style_tui_current_position,
1287 &style_set_list,
1288 &style_show_list);
1289
58b77c6a
TV
1290 add_setshow_boolean_cmd ("tui-left-margin-verbose", class_maintenance,
1291 &tui_left_margin_verbose, _("\
1292Set whether the left margin should use '_' and '0' instead of spaces."),
1293 _("\
1294Show whether the left margin should use '_' and '0' instead of spaces."),
1295 _("\
1296When enabled, the left margin will use '_' and '0' instead of spaces."),
1297 nullptr,
1298 nullptr,
1299 &maintenance_set_cmdlist,
1300 &maintenance_show_cmdlist);
1301
c90e7d63
SM
1302 tui_border_style.changed.attach (tui_rehighlight_all, "tui-win");
1303 tui_active_border_style.changed.attach (tui_rehighlight_all, "tui-win");
7806cea7 1304}