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