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