1 /* TUI window generic functions.
3 Copyright (C) 1998-2023 Free Software Foundation, Inc.
5 Contributed by Hewlett-Packard Company.
7 This file is part of GDB.
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
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
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.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
22 /* This module contains procedures for handling tui window functions
23 like resize, scrolling, scrolling, changing focus, etc.
25 Author: Susan B. Macchia */
30 #include "breakpoint.h"
32 #include "cli/cli-cmds.h"
33 #include "cli/cli-style.h"
36 #include "gdbsupport/event-loop.h"
38 #include "async-event.h"
41 #include "tui/tui-io.h"
42 #include "tui/tui-command.h"
43 #include "tui/tui-data.h"
44 #include "tui/tui-layout.h"
45 #include "tui/tui-wingeneral.h"
46 #include "tui/tui-stack.h"
47 #include "tui/tui-regs.h"
48 #include "tui/tui-disasm.h"
49 #include "tui/tui-source.h"
50 #include "tui/tui-winsource.h"
51 #include "tui/tui-win.h"
53 #include "gdb_curses.h"
55 #include "readline/readline.h"
56 #include "gdbsupport/gdb_string_view.h"
60 static void tui_set_tab_width_command (const char *, int);
61 static void tui_refresh_all_command (const char *, int);
62 static void tui_all_windows_info (const char *, int);
63 static void tui_scroll_forward_command (const char *, int);
64 static void tui_scroll_backward_command (const char *, int);
65 static void tui_scroll_left_command (const char *, int);
66 static void tui_scroll_right_command (const char *, int);
67 static void parse_scrolling_args (const char *,
68 struct tui_win_info
**,
73 # define ACS_LRCORNER '+'
76 # define ACS_LLCORNER '+'
79 # define ACS_ULCORNER '+'
82 # define ACS_URCORNER '+'
85 # define ACS_HLINE '-'
88 # define ACS_VLINE '|'
91 /* Possible values for tui-border-kind variable. */
92 static const char *const tui_border_kind_enums
[] = {
99 /* Possible values for tui-border-mode and tui-active-border-mode. */
100 static const char *const tui_border_mode_enums
[] = {
117 /* Translation table for border-mode variables.
118 The list of values must be terminated by a NULL.
119 After the NULL value, an entry defines the default. */
120 static struct tui_translate tui_border_mode_translate
[] = {
121 { "normal", A_NORMAL
},
122 { "standout", A_STANDOUT
},
123 { "reverse", A_REVERSE
},
125 { "half-standout", A_DIM
| A_STANDOUT
},
127 { "bold-standout", A_BOLD
| A_STANDOUT
},
129 { "normal", A_NORMAL
}
132 /* Translation tables for border-kind, one for each border
133 character (see wborder, border curses operations).
134 -1 is used to indicate the ACS because ACS characters
135 are determined at run time by curses (depends on terminal). */
136 static struct tui_translate tui_border_kind_translate_vline
[] = {
144 static struct tui_translate tui_border_kind_translate_hline
[] = {
152 static struct tui_translate tui_border_kind_translate_ulcorner
[] = {
160 static struct tui_translate tui_border_kind_translate_urcorner
[] = {
168 static struct tui_translate tui_border_kind_translate_llcorner
[] = {
176 static struct tui_translate tui_border_kind_translate_lrcorner
[] = {
185 /* Tui configuration variables controlled with set/show command. */
186 static const char *tui_active_border_mode
= "bold-standout";
188 show_tui_active_border_mode (struct ui_file
*file
,
190 struct cmd_list_element
*c
,
193 gdb_printf (file
, _("\
194 The attribute mode to use for the active TUI window border is \"%s\".\n"),
198 static const char *tui_border_mode
= "normal";
200 show_tui_border_mode (struct ui_file
*file
,
202 struct cmd_list_element
*c
,
205 gdb_printf (file
, _("\
206 The attribute mode to use for the TUI window borders is \"%s\".\n"),
210 static const char *tui_border_kind
= "acs";
212 show_tui_border_kind (struct ui_file
*file
,
214 struct cmd_list_element
*c
,
217 gdb_printf (file
, _("The kind of border for TUI windows is \"%s\".\n"),
221 /* Implementation of the "set/show style tui-current-position" commands. */
223 bool style_tui_current_position
= false;
226 show_style_tui_current_position (ui_file
*file
,
231 gdb_printf (file
, _("\
232 Styling the text highlighted by the TUI's current position indicator is %s.\n"),
237 set_style_tui_current_position (const char *ignore
, int from_tty
,
240 if (TUI_SRC_WIN
!= nullptr)
241 TUI_SRC_WIN
->refill ();
242 if (TUI_DISASM_WIN
!= nullptr)
243 TUI_DISASM_WIN
->refill ();
246 /* Tui internal configuration variables. These variables are updated
247 by tui_update_variables to reflect the tui configuration
249 chtype tui_border_vline
;
250 chtype tui_border_hline
;
251 chtype tui_border_ulcorner
;
252 chtype tui_border_urcorner
;
253 chtype tui_border_llcorner
;
254 chtype tui_border_lrcorner
;
256 int tui_border_attrs
;
257 int tui_active_border_attrs
;
259 /* Identify the item in the translation table.
260 When the item is not recognized, use the default entry. */
261 static struct tui_translate
*
262 translate (const char *name
, struct tui_translate
*table
)
266 if (name
&& strcmp (table
->name
, name
) == 0)
271 /* Not found, return default entry. */
276 /* Update the tui internal configuration according to gdb settings.
277 Returns 1 if the configuration has changed and the screen should
280 tui_update_variables ()
282 bool need_redraw
= false;
283 struct tui_translate
*entry
;
285 entry
= translate (tui_border_mode
, tui_border_mode_translate
);
286 if (tui_border_attrs
!= entry
->value
)
288 tui_border_attrs
= entry
->value
;
291 entry
= translate (tui_active_border_mode
, tui_border_mode_translate
);
292 if (tui_active_border_attrs
!= entry
->value
)
294 tui_active_border_attrs
= entry
->value
;
298 /* If one corner changes, all characters are changed.
299 Only check the first one. The ACS characters are determined at
300 run time by curses terminal management. */
301 entry
= translate (tui_border_kind
, tui_border_kind_translate_lrcorner
);
302 if (tui_border_lrcorner
!= (chtype
) entry
->value
)
304 tui_border_lrcorner
= (entry
->value
< 0) ? ACS_LRCORNER
: entry
->value
;
307 entry
= translate (tui_border_kind
, tui_border_kind_translate_llcorner
);
308 tui_border_llcorner
= (entry
->value
< 0) ? ACS_LLCORNER
: entry
->value
;
310 entry
= translate (tui_border_kind
, tui_border_kind_translate_ulcorner
);
311 tui_border_ulcorner
= (entry
->value
< 0) ? ACS_ULCORNER
: entry
->value
;
313 entry
= translate (tui_border_kind
, tui_border_kind_translate_urcorner
);
314 tui_border_urcorner
= (entry
->value
< 0) ? ACS_URCORNER
: entry
->value
;
316 entry
= translate (tui_border_kind
, tui_border_kind_translate_hline
);
317 tui_border_hline
= (entry
->value
< 0) ? ACS_HLINE
: entry
->value
;
319 entry
= translate (tui_border_kind
, tui_border_kind_translate_vline
);
320 tui_border_vline
= (entry
->value
< 0) ? ACS_VLINE
: entry
->value
;
325 static struct cmd_list_element
*tuilist
;
327 struct cmd_list_element
**
328 tui_get_cmd_list (void)
331 add_basic_prefix_cmd ("tui", class_tui
,
332 _("Text User Interface commands."),
333 &tuilist
, 0, &cmdlist
);
337 /* The set_func hook of "set tui ..." commands that affect the window
338 borders on the TUI display. */
341 tui_set_var_cmd (const char *null_args
,
342 int from_tty
, struct cmd_list_element
*c
)
344 if (tui_update_variables () && tui_active
)
345 tui_rehighlight_all ();
350 /* True if TUI resizes should print a message. This is used by the
353 static bool resize_message
;
356 show_tui_resize_message (struct ui_file
*file
, int from_tty
,
357 struct cmd_list_element
*c
, const char *value
)
359 gdb_printf (file
, _("TUI resize messaging is %s.\n"), value
);
364 /* Generic window name completion function. Complete window name pointed
367 If EXCLUDE_CANNOT_FOCUS_P is true, then windows that can't take focus
368 will be excluded from the completions, otherwise they will be included.
370 If INCLUDE_NEXT_PREV_P is true then the special window names 'next' and
371 'prev' will also be considered as possible completions of the window
372 name. This is independent of EXCLUDE_CANNOT_FOCUS_P. */
375 window_name_completer (completion_tracker
&tracker
,
376 bool include_next_prev_p
,
377 bool exclude_cannot_focus_p
,
378 const char *text
, const char *word
)
380 std::vector
<const char *> completion_name_vec
;
382 for (tui_win_info
*win_info
: all_tui_windows ())
384 const char *completion_name
= NULL
;
386 /* Don't include an invisible window. */
387 if (!win_info
->is_visible ())
390 /* If requested, exclude windows that can't be focused. */
391 if (exclude_cannot_focus_p
&& !win_info
->can_focus ())
394 completion_name
= win_info
->name ();
395 gdb_assert (completion_name
!= NULL
);
396 completion_name_vec
.push_back (completion_name
);
399 /* If no windows are considered visible then the TUI has not yet been
400 initialized. But still "focus src" and "focus cmd" will work because
401 invoking the focus command will entail initializing the TUI which sets the
402 default layout to "src". */
403 if (completion_name_vec
.empty ())
405 completion_name_vec
.push_back (SRC_NAME
);
406 completion_name_vec
.push_back (CMD_NAME
);
409 if (include_next_prev_p
)
411 completion_name_vec
.push_back ("next");
412 completion_name_vec
.push_back ("prev");
416 completion_name_vec
.push_back (NULL
);
417 complete_on_enum (tracker
, completion_name_vec
.data (), text
, word
);
420 /* Complete possible window names to focus on. TEXT is the complete text
421 entered so far, WORD is the word currently being completed. */
424 focus_completer (struct cmd_list_element
*ignore
,
425 completion_tracker
&tracker
,
426 const char *text
, const char *word
)
428 window_name_completer (tracker
, true, true, text
, word
);
431 /* Complete possible window names for winheight command. TEXT is the
432 complete text entered so far, WORD is the word currently being
436 winheight_completer (struct cmd_list_element
*ignore
,
437 completion_tracker
&tracker
,
438 const char *text
, const char *word
)
440 /* The first word is the window name. That we can complete. Subsequent
441 words can't be completed. */
445 window_name_completer (tracker
, false, false, text
, word
);
448 /* Update gdb's knowledge of the terminal size. */
450 tui_update_gdb_sizes (void)
456 width
= TUI_CMD_WIN
->width
;
457 height
= TUI_CMD_WIN
->height
;
461 width
= tui_term_width ();
462 height
= tui_term_height ();
465 set_screen_width_and_height (width
, height
);
470 tui_win_info::forward_scroll (int num_to_scroll
)
472 if (num_to_scroll
== 0)
473 num_to_scroll
= height
- 3;
475 do_scroll_vertical (num_to_scroll
);
479 tui_win_info::backward_scroll (int num_to_scroll
)
481 if (num_to_scroll
== 0)
482 num_to_scroll
= height
- 3;
484 do_scroll_vertical (-num_to_scroll
);
489 tui_win_info::left_scroll (int num_to_scroll
)
491 if (num_to_scroll
== 0)
494 do_scroll_horizontal (num_to_scroll
);
499 tui_win_info::right_scroll (int num_to_scroll
)
501 if (num_to_scroll
== 0)
504 do_scroll_horizontal (-num_to_scroll
);
509 tui_refresh_all_win (void)
511 clearok (curscr
, TRUE
);
516 tui_rehighlight_all (void)
518 for (tui_win_info
*win_info
: all_tui_windows ())
519 win_info
->check_and_display_highlight_if_needed ();
522 /* Resize all the windows based on the terminal size. This function
523 gets called from within the readline SIGWINCH handler. */
525 tui_resize_all (void)
527 int height_diff
, width_diff
;
528 int screenheight
, screenwidth
;
530 rl_get_screen_size (&screenheight
, &screenwidth
);
531 width_diff
= screenwidth
- tui_term_width ();
532 height_diff
= screenheight
- tui_term_height ();
533 if (height_diff
|| width_diff
)
535 #ifdef HAVE_RESIZE_TERM
536 resize_term (screenheight
, screenwidth
);
538 /* Turn keypad off while we resize. */
539 keypad (TUI_CMD_WIN
->handle
.get (), FALSE
);
540 tui_update_gdb_sizes ();
541 tui_set_term_height_to (screenheight
);
542 tui_set_term_width_to (screenwidth
);
544 /* erase + clearok are used instead of a straightforward clear as
545 AIX 5.3 does not define clear. */
547 clearok (curscr
, TRUE
);
548 /* Apply the current layout. The 'false' here allows the command
549 window to resize proportionately with containing terminal, rather
550 than maintaining a fixed size. */
551 tui_apply_current_layout (false); /* Turn keypad back on. */
552 keypad (TUI_CMD_WIN
->handle
.get (), TRUE
);
557 /* Token for use by TUI's asynchronous SIGWINCH handler. */
558 static struct async_signal_handler
*tui_sigwinch_token
;
560 /* TUI's SIGWINCH signal handler. */
562 tui_sigwinch_handler (int signal
)
564 mark_async_signal_handler (tui_sigwinch_token
);
565 tui_set_win_resized_to (true);
568 /* Callback for asynchronously resizing TUI following a SIGWINCH signal. */
570 tui_async_resize_screen (gdb_client_data arg
)
572 rl_resize_terminal ();
576 int screen_height
, screen_width
;
578 rl_get_screen_size (&screen_height
, &screen_width
);
579 set_screen_width_and_height (screen_width
, screen_height
);
581 /* win_resized is left set so that the next call to tui_enable()
582 resizes the TUI windows. */
586 tui_set_win_resized_to (false);
588 tui_refresh_all_win ();
589 tui_update_gdb_sizes ();
593 printf_unfiltered ("@@ resize done %d, size = %dx%d\n", count
,
594 tui_term_width (), tui_term_height ());
597 tui_redisplay_readline ();
602 /* Initialize TUI's SIGWINCH signal handler. Note that the handler is not
603 uninstalled when we exit TUI, so the handler should not assume that TUI is
606 tui_initialize_win (void)
610 = create_async_signal_handler (tui_async_resize_screen
, NULL
,
614 #ifdef HAVE_SIGACTION
615 struct sigaction old_winch
;
617 memset (&old_winch
, 0, sizeof (old_winch
));
618 old_winch
.sa_handler
= &tui_sigwinch_handler
;
620 old_winch
.sa_flags
= SA_RESTART
;
622 sigaction (SIGWINCH
, &old_winch
, NULL
);
624 signal (SIGWINCH
, &tui_sigwinch_handler
);
632 tui_scroll_forward_command (const char *arg
, int from_tty
)
634 int num_to_scroll
= 1;
635 struct tui_win_info
*win_to_scroll
;
637 /* Make sure the curses mode is enabled. */
640 parse_scrolling_args (arg
, &win_to_scroll
, NULL
);
642 parse_scrolling_args (arg
, &win_to_scroll
, &num_to_scroll
);
643 win_to_scroll
->forward_scroll (num_to_scroll
);
648 tui_scroll_backward_command (const char *arg
, int from_tty
)
650 int num_to_scroll
= 1;
651 struct tui_win_info
*win_to_scroll
;
653 /* Make sure the curses mode is enabled. */
656 parse_scrolling_args (arg
, &win_to_scroll
, NULL
);
658 parse_scrolling_args (arg
, &win_to_scroll
, &num_to_scroll
);
659 win_to_scroll
->backward_scroll (num_to_scroll
);
664 tui_scroll_left_command (const char *arg
, int from_tty
)
667 struct tui_win_info
*win_to_scroll
;
669 /* Make sure the curses mode is enabled. */
671 parse_scrolling_args (arg
, &win_to_scroll
, &num_to_scroll
);
672 win_to_scroll
->left_scroll (num_to_scroll
);
677 tui_scroll_right_command (const char *arg
, int from_tty
)
680 struct tui_win_info
*win_to_scroll
;
682 /* Make sure the curses mode is enabled. */
684 parse_scrolling_args (arg
, &win_to_scroll
, &num_to_scroll
);
685 win_to_scroll
->right_scroll (num_to_scroll
);
689 /* Answer the window represented by name. */
690 static struct tui_win_info
*
691 tui_partial_win_by_name (gdb::string_view name
)
693 struct tui_win_info
*best
= nullptr;
695 for (tui_win_info
*item
: all_tui_windows ())
697 const char *cur_name
= item
->name ();
699 if (name
== cur_name
)
701 if (startswith (cur_name
, name
))
704 error (_("Window name \"%*s\" is ambiguous"),
705 (int) name
.size (), name
.data ());
713 /* Set focus to the window named by 'arg'. */
715 tui_set_focus_command (const char *arg
, int from_tty
)
720 error_no_arg (_("name of window to focus"));
722 struct tui_win_info
*win_info
= NULL
;
724 if (startswith ("next", arg
))
725 win_info
= tui_next_win (tui_win_with_focus ());
726 else if (startswith ("prev", arg
))
727 win_info
= tui_prev_win (tui_win_with_focus ());
729 win_info
= tui_partial_win_by_name (arg
);
731 if (win_info
== NULL
)
732 error (_("Unrecognized window name \"%s\""), arg
);
734 /* If a window is part of the current layout then it will have a
735 tui_win_info associated with it and be visible, otherwise, there will
736 be no tui_win_info and the above error will have been raised. */
737 gdb_assert (win_info
->is_visible ());
739 if (!win_info
->can_focus ())
740 error (_("Window \"%s\" cannot be focused"), arg
);
742 tui_set_win_focus_to (win_info
);
743 gdb_printf (_("Focus set to %s window.\n"),
744 tui_win_with_focus ()->name ());
748 tui_all_windows_info (const char *arg
, int from_tty
)
752 gdb_printf (_("The TUI is not active.\n"));
756 struct tui_win_info
*win_with_focus
= tui_win_with_focus ();
757 struct ui_out
*uiout
= current_uiout
;
759 ui_out_emit_table
table_emitter (uiout
, 4, -1, "tui-windows");
760 uiout
->table_header (10, ui_left
, "name", "Name");
761 uiout
->table_header (5, ui_right
, "lines", "Lines");
762 uiout
->table_header (7, ui_right
, "columns", "Columns");
763 uiout
->table_header (10, ui_left
, "focus", "Focus");
764 uiout
->table_body ();
766 for (tui_win_info
*win_info
: all_tui_windows ())
767 if (win_info
->is_visible ())
769 ui_out_emit_tuple
tuple_emitter (uiout
, nullptr);
771 uiout
->field_string ("name", win_info
->name ());
772 uiout
->field_signed ("lines", win_info
->height
);
773 uiout
->field_signed ("columns", win_info
->width
);
774 if (win_with_focus
== win_info
)
775 uiout
->field_string ("focus", _("(has focus)"));
777 uiout
->field_skip ("focus");
784 tui_refresh_all_command (const char *arg
, int from_tty
)
786 /* Make sure the curses mode is enabled. */
789 tui_refresh_all_win ();
792 #define DEFAULT_TAB_LEN 8
794 /* The tab width that should be used by the TUI. */
796 unsigned int tui_tab_width
= DEFAULT_TAB_LEN
;
798 /* The tab width as set by the user. */
800 static unsigned int internal_tab_width
= DEFAULT_TAB_LEN
;
802 /* After the tab width is set, call this to update the relevant
808 for (tui_win_info
*win_info
: all_tui_windows ())
810 if (win_info
->is_visible ())
811 win_info
->update_tab_width ();
815 /* Callback for "set tui tab-width". */
818 tui_set_tab_width (const char *ignore
,
819 int from_tty
, struct cmd_list_element
*c
)
821 if (internal_tab_width
== 0)
823 internal_tab_width
= tui_tab_width
;
824 error (_("Tab width must not be 0"));
827 tui_tab_width
= internal_tab_width
;
831 /* Callback for "show tui tab-width". */
834 tui_show_tab_width (struct ui_file
*file
, int from_tty
,
835 struct cmd_list_element
*c
, const char *value
)
837 gdb_printf (file
, _("TUI tab width is %s spaces.\n"), value
);
843 bool compact_source
= false;
845 /* Callback for "set tui compact-source". */
848 tui_set_compact_source (const char *ignore
, int from_tty
,
849 struct cmd_list_element
*c
)
851 if (TUI_SRC_WIN
!= nullptr)
852 TUI_SRC_WIN
->refill ();
855 /* Callback for "show tui compact-source". */
858 tui_show_compact_source (struct ui_file
*file
, int from_tty
,
859 struct cmd_list_element
*c
, const char *value
)
861 gdb_printf (file
, _("TUI source window compactness is %s.\n"), value
);
864 /* Set the tab width of the specified window. */
866 tui_set_tab_width_command (const char *arg
, int from_tty
)
868 /* Make sure the curses mode is enabled. */
876 warning (_("Tab widths greater than 0 must be specified."));
879 internal_tab_width
= ts
;
887 /* Helper function for the user commands to adjust a window's width or
888 height. The ARG string contains the command line arguments from the
889 user, which should give the name of a window, and how to adjust the
892 When SET_WIDTH_P is true the width of the window is adjusted based on
893 ARG, and when SET_WIDTH_P is false, the height of the window is adjusted
896 On invalid input, or if the size can't be adjusted as requested, then an
897 error is thrown, otherwise, the window sizes are adjusted, and the
901 tui_set_win_size (const char *arg
, bool set_width_p
)
903 /* Make sure the curses mode is enabled. */
906 error_no_arg (_("name of window"));
908 const char *buf
= arg
;
909 const char *buf_ptr
= buf
;
911 struct tui_win_info
*win_info
;
913 buf_ptr
= skip_to_space (buf_ptr
);
915 /* Validate the window name. */
916 gdb::string_view
wname (buf
, buf_ptr
- buf
);
917 win_info
= tui_partial_win_by_name (wname
);
919 if (win_info
== NULL
)
920 error (_("Unrecognized window name \"%s\""), arg
);
921 if (!win_info
->is_visible ())
922 error (_("Window \"%s\" is not visible"), arg
);
924 /* Process the size. */
925 buf_ptr
= skip_spaces (buf_ptr
);
927 if (*buf_ptr
!= '\0')
930 bool fixed_size
= true;
933 if (*buf_ptr
== '+' || *buf_ptr
== '-')
940 input_no
= atoi (buf_ptr
);
951 curr_size
= win_info
->width
;
953 curr_size
= win_info
->height
;
954 new_size
= curr_size
+ input_no
;
957 /* Now change the window's height, and adjust
958 all other windows around it. */
960 tui_adjust_window_width (win_info
, new_size
);
962 tui_adjust_window_height (win_info
, new_size
);
963 tui_update_gdb_sizes ();
968 error (_("Invalid window width specified"));
970 error (_("Invalid window height specified"));
975 /* Implement the 'tui window height' command (alias 'winheight'). */
978 tui_set_win_height_command (const char *arg
, int from_tty
)
980 /* Pass false as the final argument to set the height. */
981 tui_set_win_size (arg
, false);
984 /* Implement the 'tui window width' command (alias 'winwidth'). */
987 tui_set_win_width_command (const char *arg
, int from_tty
)
989 /* Pass true as the final argument to set the width. */
990 tui_set_win_size (arg
, true);
993 /* See tui-data.h. */
996 tui_win_info::max_height () const
998 return tui_term_height ();
1001 /* See tui-data.h. */
1004 tui_win_info::max_width () const
1006 return tui_term_width ();
1010 parse_scrolling_args (const char *arg
,
1011 struct tui_win_info
**win_to_scroll
,
1016 *win_to_scroll
= tui_win_with_focus ();
1018 /* First set up the default window to scroll, in case there is no
1024 /* Process the number of lines to scroll. */
1025 std::string copy
= arg
;
1027 if (isdigit (*buf_ptr
))
1032 buf_ptr
= strchr (buf_ptr
, ' ');
1033 if (buf_ptr
!= NULL
)
1037 *num_to_scroll
= atoi (num_str
);
1040 else if (num_to_scroll
)
1041 *num_to_scroll
= atoi (num_str
);
1044 /* Process the window name if one is specified. */
1045 if (buf_ptr
!= NULL
)
1049 wname
= skip_spaces (buf_ptr
);
1053 *win_to_scroll
= tui_partial_win_by_name (wname
);
1055 if (*win_to_scroll
== NULL
)
1056 error (_("Unrecognized window `%s'"), wname
);
1057 if (!(*win_to_scroll
)->is_visible ())
1058 error (_("Window is not visible"));
1059 else if (*win_to_scroll
== TUI_CMD_WIN
)
1060 *win_to_scroll
= *(tui_source_windows ().begin ());
1066 /* The list of 'tui window' sub-commands. */
1068 static cmd_list_element
*tui_window_cmds
= nullptr;
1070 /* Called to implement 'tui window'. */
1073 tui_window_command (const char *args
, int from_tty
)
1075 help_list (tui_window_cmds
, "tui window ", all_commands
, gdb_stdout
);
1078 /* Function to initialize gdb commands, for tui window
1081 void _initialize_tui_win ();
1083 _initialize_tui_win ()
1085 static struct cmd_list_element
*tui_setlist
;
1086 static struct cmd_list_element
*tui_showlist
;
1088 /* Define the classes of commands.
1089 They will appear in the help list in the reverse of this order. */
1090 add_setshow_prefix_cmd ("tui", class_tui
,
1091 _("TUI configuration variables."),
1092 _("TUI configuration variables."),
1093 &tui_setlist
, &tui_showlist
,
1094 &setlist
, &showlist
);
1096 cmd_list_element
*refresh_cmd
1097 = add_cmd ("refresh", class_tui
, tui_refresh_all_command
,
1098 _("Refresh the terminal display."),
1099 tui_get_cmd_list ());
1100 add_com_alias ("refresh", refresh_cmd
, class_tui
, 0);
1102 cmd_list_element
*tabset_cmd
1103 = add_com ("tabset", class_tui
, tui_set_tab_width_command
, _("\
1104 Set the width (in characters) of tab stops.\n\
1106 deprecate_cmd (tabset_cmd
, "set tui tab-width");
1108 /* Setup the 'tui window' list of command. */
1109 add_prefix_cmd ("window", class_tui
, tui_window_command
,
1110 _("Text User Interface window commands."),
1111 &tui_window_cmds
, 1, tui_get_cmd_list ());
1113 cmd_list_element
*winheight_cmd
1114 = add_cmd ("height", class_tui
, tui_set_win_height_command
, _("\
1115 Set or modify the height of a specified window.\n\
1116 Usage: tui window height WINDOW-NAME [+ | -] NUM-LINES\n\
1117 Use \"info win\" to see the names of the windows currently being displayed."),
1119 add_com_alias ("winheight", winheight_cmd
, class_tui
, 0);
1120 add_com_alias ("wh", winheight_cmd
, class_tui
, 0);
1121 set_cmd_completer (winheight_cmd
, winheight_completer
);
1123 cmd_list_element
*winwidth_cmd
1124 = add_cmd ("width", class_tui
, tui_set_win_width_command
, _("\
1125 Set or modify the width of a specified window.\n\
1126 Usage: tui window width WINDOW-NAME [+ | -] NUM-LINES\n\
1127 Use \"info win\" to see the names of the windows currently being displayed."),
1129 add_com_alias ("winwidth", winwidth_cmd
, class_tui
, 0);
1130 set_cmd_completer (winwidth_cmd
, winheight_completer
);
1132 add_info ("win", tui_all_windows_info
,
1133 _("List of all displayed windows.\n\
1135 cmd_list_element
*focus_cmd
1136 = add_cmd ("focus", class_tui
, tui_set_focus_command
, _("\
1137 Set focus to named window or next/prev window.\n\
1138 Usage: tui focus [WINDOW-NAME | next | prev]\n\
1139 Use \"info win\" to see the names of the windows currently being displayed."),
1140 tui_get_cmd_list ());
1141 add_com_alias ("focus", focus_cmd
, class_tui
, 0);
1142 add_com_alias ("fs", focus_cmd
, class_tui
, 0);
1143 set_cmd_completer (focus_cmd
, focus_completer
);
1144 add_com ("+", class_tui
, tui_scroll_forward_command
, _("\
1145 Scroll window forward.\n\
1146 Usage: + [N] [WIN]\n\
1147 Scroll window WIN N lines forwards. Both WIN and N are optional, N\n\
1148 defaults to 1, and WIN defaults to the currently focused window."));
1149 add_com ("-", class_tui
, tui_scroll_backward_command
, _("\
1150 Scroll window backward.\n\
1151 Usage: - [N] [WIN]\n\
1152 Scroll window WIN N lines backwards. Both WIN and N are optional, N\n\
1153 defaults to 1, and WIN defaults to the currently focused window."));
1154 add_com ("<", class_tui
, tui_scroll_left_command
, _("\
1155 Scroll window text to the left.\n\
1156 Usage: < [N] [WIN]\n\
1157 Scroll window WIN N characters left. Both WIN and N are optional, N\n\
1158 defaults to 1, and WIN defaults to the currently focused window."));
1159 add_com (">", class_tui
, tui_scroll_right_command
, _("\
1160 Scroll window text to the right.\n\
1161 Usage: > [N] [WIN]\n\
1162 Scroll window WIN N characters right. Both WIN and N are optional, N\n\
1163 defaults to 1, and WIN defaults to the currently focused window."));
1165 /* Define the tui control variables. */
1166 add_setshow_enum_cmd ("border-kind", no_class
, tui_border_kind_enums
,
1167 &tui_border_kind
, _("\
1168 Set the kind of border for TUI windows."), _("\
1169 Show the kind of border for TUI windows."), _("\
1170 This variable controls the border of TUI windows:\n\
1171 space use a white space\n\
1172 ascii use ascii characters + - | for the border\n\
1173 acs use the Alternate Character Set"),
1175 show_tui_border_kind
,
1176 &tui_setlist
, &tui_showlist
);
1178 add_setshow_enum_cmd ("border-mode", no_class
, tui_border_mode_enums
,
1179 &tui_border_mode
, _("\
1180 Set the attribute mode to use for the TUI window borders."), _("\
1181 Show the attribute mode to use for the TUI window borders."), _("\
1182 This variable controls the attributes to use for the window borders:\n\
1183 normal normal display\n\
1184 standout use highlight mode of terminal\n\
1185 reverse use reverse video mode\n\
1186 half use half bright\n\
1187 half-standout use half bright and standout mode\n\
1188 bold use extra bright or bold\n\
1189 bold-standout use extra bright or bold with standout mode"),
1191 show_tui_border_mode
,
1192 &tui_setlist
, &tui_showlist
);
1194 add_setshow_enum_cmd ("active-border-mode", no_class
, tui_border_mode_enums
,
1195 &tui_active_border_mode
, _("\
1196 Set the attribute mode to use for the active TUI window border."), _("\
1197 Show the attribute mode to use for the active TUI window border."), _("\
1198 This variable controls the attributes to use for the active window border:\n\
1199 normal normal display\n\
1200 standout use highlight mode of terminal\n\
1201 reverse use reverse video mode\n\
1202 half use half bright\n\
1203 half-standout use half bright and standout mode\n\
1204 bold use extra bright or bold\n\
1205 bold-standout use extra bright or bold with standout mode"),
1207 show_tui_active_border_mode
,
1208 &tui_setlist
, &tui_showlist
);
1210 add_setshow_zuinteger_cmd ("tab-width", no_class
,
1211 &internal_tab_width
, _("\
1212 Set the tab width, in characters, for the TUI."), _("\
1213 Show the tab witdh, in characters, for the TUI."), _("\
1214 This variable controls how many spaces are used to display a tab character."),
1215 tui_set_tab_width
, tui_show_tab_width
,
1216 &tui_setlist
, &tui_showlist
);
1218 add_setshow_boolean_cmd ("tui-resize-message", class_maintenance
,
1219 &resize_message
, _("\
1220 Set TUI resize messaging."), _("\
1221 Show TUI resize messaging."), _("\
1222 When enabled GDB will print a message when the terminal is resized."),
1224 show_tui_resize_message
,
1225 &maintenance_set_cmdlist
,
1226 &maintenance_show_cmdlist
);
1228 add_setshow_boolean_cmd ("compact-source", class_tui
,
1229 &compact_source
, _("\
1230 Set whether the TUI source window is compact."), _("\
1231 Show whether the TUI source window is compact."), _("\
1232 This variable controls whether the TUI source window is shown\n\
1233 in a compact form. The compact form puts the source closer to\n\
1234 the line numbers and uses less horizontal space."),
1235 tui_set_compact_source
, tui_show_compact_source
,
1236 &tui_setlist
, &tui_showlist
);
1238 add_setshow_boolean_cmd ("tui-current-position", class_maintenance
,
1239 &style_tui_current_position
, _("\
1240 Set whether to style text highlighted by the TUI's current position indicator."),
1242 Show whether to style text highlighted by the TUI's current position indicator."),
1244 When enabled, the source and assembly code highlighted by the TUI's current\n\
1245 position indicator is styled."),
1246 set_style_tui_current_position
,
1247 show_style_tui_current_position
,
1251 tui_border_style
.changed
.attach (tui_rehighlight_all
, "tui-win");
1252 tui_active_border_style
.changed
.attach (tui_rehighlight_all
, "tui-win");