36#include "gdbsupport/event-loop.h"
56#include "readline/readline.h"
57#include "gdbsupport/gdb_string_view.h"
74# define ACS_LRCORNER '+'
77# define ACS_LLCORNER '+'
80# define ACS_ULCORNER '+'
83# define ACS_URCORNER '+'
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 },
161The attribute mode to use for the active TUI window border is \"%s\".\n"),
173The attribute mode to use for the TUI window borders is \"%s\".\n"),
184 gdb_printf (file, _(
"The kind of border for TUI windows is \"%s\".\n"),
199Styling the text highlighted by the TUI's current position indicator is %s.\n"),
237 gdb_assert_not_reached (
"");
247 if (strcmp (
name,
"acs") == 0)
259 bool need_redraw =
false;
304 _(
"Text User Interface commands."),
348 bool include_next_prev_p,
349 bool exclude_cannot_focus_p,
350 const char *text,
const char *word)
352 std::vector<const char *> completion_name_vec;
356 const char *completion_name = NULL;
359 if (!win_info->is_visible ())
363 if (exclude_cannot_focus_p && !win_info->can_focus ())
366 completion_name = win_info->name ();
367 gdb_assert (completion_name != NULL);
368 completion_name_vec.push_back (completion_name);
375 if (completion_name_vec.empty ())
377 completion_name_vec.push_back (
SRC_NAME);
378 completion_name_vec.push_back (
CMD_NAME);
381 if (include_next_prev_p)
383 completion_name_vec.push_back (
"next");
384 completion_name_vec.push_back (
"prev");
388 completion_name_vec.push_back (NULL);
398 const char *text,
const char *word)
410 const char *text,
const char *word)
444 if (num_to_scroll == 0)
445 num_to_scroll =
height - 3;
453 if (num_to_scroll == 0)
454 num_to_scroll =
height - 3;
463 if (num_to_scroll == 0)
473 if (num_to_scroll == 0)
483 clearok (curscr, TRUE);
491 win_info->check_and_display_highlight_if_needed ();
499 int height_diff, width_diff;
500 int screenheight, screenwidth;
502 rl_get_screen_size (&screenheight, &screenwidth);
507 if (height_diff || width_diff)
509#ifdef HAVE_RESIZE_TERM
510 resize_term (screenheight, screenwidth);
521 clearok (curscr, TRUE);
536tui_sigwinch_handler (
int signal)
544tui_async_resize_screen (gdb_client_data arg)
546 rl_resize_terminal ();
550 int screen_height, screen_width;
552 rl_get_screen_size (&screen_height, &screen_width);
590 struct sigaction old_winch;
592 memset (&old_winch, 0,
sizeof (old_winch));
593 old_winch.sa_handler = &tui_sigwinch_handler;
595 old_winch.sa_flags = SA_RESTART;
597 sigaction (SIGWINCH, &old_winch, NULL);
599 signal (SIGWINCH, &tui_sigwinch_handler);
609 int num_to_scroll = 1;
625 int num_to_scroll = 1;
672 const char *cur_name = item->
name ();
674 if (
name == cur_name)
676 if (startswith (cur_name,
name))
679 error (_(
"Window name \"%*s\" is ambiguous"),
699 if (startswith (
"next", arg))
701 else if (startswith (
"prev", arg))
706 if (win_info ==
nullptr)
712 std::string matching_window_name;
713 bool is_ambiguous =
false;
720 if (item->name () ==
name)
723 if (startswith (
name, arg))
725 if (matching_window_name.empty ())
726 matching_window_name =
name;
732 if (!matching_window_name.empty ())
735 error (_(
"No windows matching \"%s\" in the current layout"),
738 error (_(
"Window \"%s\" is not in the current layout"),
739 matching_window_name.c_str ());
742 error (_(
"Unrecognized window name \"%s\""), arg);
751 error (_(
"Window \"%s\" cannot be focused"), arg);
778 if (win_info->is_visible ())
803#define DEFAULT_TAB_LEN 8
821 if (win_info->is_visible ())
822 win_info->update_tab_width ();
835 error (_(
"Tab width must not be 0"));
898 warning (_(
"Tab widths greater than 0 must be specified."));
930 const char *buf = arg;
931 const char *buf_ptr = buf;
935 buf_ptr = skip_to_space (buf_ptr);
938 gdb::string_view wname (buf, buf_ptr - buf);
941 if (win_info == NULL)
942 error (_(
"Unrecognized window name \"%s\""), arg);
944 error (_(
"Window \"%s\" is not visible"), arg);
947 buf_ptr = skip_spaces (buf_ptr);
949 if (*buf_ptr !=
'\0')
952 bool fixed_size =
true;
955 if (*buf_ptr ==
'+' || *buf_ptr ==
'-')
962 input_no = atoi (buf_ptr);
973 curr_size = win_info->
width;
975 curr_size = win_info->
height;
976 new_size = curr_size + input_no;
990 error (_(
"Invalid window width specified"));
992 error (_(
"Invalid window height specified"));
1047 std::string copy = arg;
1049 if (isdigit (*buf_ptr))
1054 buf_ptr = strchr (buf_ptr,
' ');
1055 if (buf_ptr != NULL)
1059 *num_to_scroll = atoi (num_str);
1062 else if (num_to_scroll)
1063 *num_to_scroll = atoi (num_str);
1067 if (buf_ptr != NULL)
1071 wname = skip_spaces (buf_ptr);
1077 if (*win_to_scroll == NULL)
1078 error (_(
"Unrecognized window `%s'"), wname);
1079 if (!(*win_to_scroll)->is_visible ())
1080 error (_(
"Window is not visible"));
1117 _(
"TUI configuration variables."),
1118 _(
"TUI configuration variables."),
1119 &tui_setlist, &tui_showlist,
1124 _(
"Refresh the terminal display."),
1130Set the width (in characters) of tab stops.\n\
1136 _(
"Text User Interface window commands."),
1141Set or modify the height of a specified window.\n\
1142Usage: tui window height WINDOW-NAME [+ | -] NUM-LINES\n\
1143Use \"info win\" to see the names of the windows currently being displayed."),
1151Set or modify the width of a specified window.\n\
1152Usage: tui window width WINDOW-NAME [+ | -] NUM-LINES\n\
1153Use \"info win\" to see the names of the windows currently being displayed."),
1159 _(
"List of all displayed windows.\n\
1163Set focus to named window or next/prev window.\n\
1164Usage: tui focus [WINDOW-NAME | next | prev]\n\
1165Use \"info win\" to see the names of the windows currently being displayed."),
1171Scroll window forward.\n\
1172Usage: + [N] [WIN]\n\
1173Scroll window WIN N lines forwards. Both WIN and N are optional, N\n\
1174defaults to 1, and WIN defaults to the currently focused window."));
1176Scroll window backward.\n\
1177Usage: - [N] [WIN]\n\
1178Scroll window WIN N lines backwards. Both WIN and N are optional, N\n\
1179defaults to 1, and WIN defaults to the currently focused window."));
1181Scroll window text to the left.\n\
1182Usage: < [N] [WIN]\n\
1183Scroll window WIN N characters left. Both WIN and N are optional, N\n\
1184defaults to 1, and WIN defaults to the currently focused window."));
1186Scroll window text to the right.\n\
1187Usage: > [N] [WIN]\n\
1188Scroll window WIN N characters right. Both WIN and N are optional, N\n\
1189defaults to 1, and WIN defaults to the currently focused window."));
1194Set the kind of border for TUI windows."), _(
"\
1195Show the kind of border for TUI windows."), _(
"\
1196This variable controls the border of TUI windows:\n\
1197 space use a white space\n\
1198 ascii use ascii characters + - | for the border\n\
1199 acs use the Alternate Character Set"),
1202 &tui_setlist, &tui_showlist);
1204 const std::string help_attribute_mode (_(
"\
1205 normal normal display\n\
1206 standout use highlight mode of terminal\n\
1207 reverse use reverse video mode\n\
1208 half use half bright\n\
1209 half-standout use half bright and standout mode\n\
1210 bold use extra bright or bold\n\
1211 bold-standout use extra bright or bold with standout mode"));
1213 const std::string help_tui_border_mode
1215This variable controls the attributes to use for the window borders:\n")
1216 + help_attribute_mode);
1220Set the attribute mode to use for the TUI window borders."), _(
"\
1221Show the attribute mode to use for the TUI window borders."),
1222 help_tui_border_mode.c_str (),
1225 &tui_setlist, &tui_showlist);
1227 const std::string help_tui_active_border_mode
1229This variable controls the attributes to use for the active window borders:\n")
1230 + help_attribute_mode);
1234Set the attribute mode to use for the active TUI window border."), _(
"\
1235Show the attribute mode to use for the active TUI window border."),
1236 help_tui_active_border_mode.c_str (),
1239 &tui_setlist, &tui_showlist);
1243Set the tab width, in characters, for the TUI."), _(
"\
1244Show the tab width, in characters, for the TUI."), _(
"\
1245This variable controls how many spaces are used to display a tab character."),
1247 &tui_setlist, &tui_showlist);
1251Set TUI resize messaging."), _(
"\
1252Show TUI resize messaging."), _(
"\
1253When enabled GDB will print a message when the terminal is resized."),
1261Set whether the TUI source window is compact."), _(
"\
1262Show whether the TUI source window is compact."), _(
"\
1263This variable controls whether the TUI source window is shown\n\
1264in a compact form. The compact form uses less horizontal space."),
1266 &tui_setlist, &tui_showlist);
1270Set whether TUI mode handles mouse clicks."), _(
"\
1271Show whether TUI mode handles mouse clicks."), _(
"\
1272When on (default), mouse clicks control the TUI and can be accessed by Python\n\
1273extensions. When off, mouse clicks are handled by the terminal, enabling\n\
1274terminal-native text selection."),
1277 &tui_setlist, &tui_showlist);
1281Set whether to style text highlighted by the TUI's current position indicator."),
1283Show whether to style text highlighted by the TUI's current position indicator."),
1285When enabled, the source and assembly code highlighted by the TUI's current\n\
1286position indicator is styled."),
1294Set whether the left margin should use '_' and '0' instead of spaces."),
1296Show whether the left margin should use '_' and '0' instead of spaces."),
1298When enabled, the left margin will use '_' and '0' instead of spaces."),
async_signal_handler * create_async_signal_handler(sig_handler_func *proc, gdb_client_data client_data, const char *name)
void mark_async_signal_handler(async_signal_handler *async_handler_ptr)
gdb::observers::observable changed
void field_string(const char *fldname, const char *string, const ui_file_style &style=ui_file_style())
void field_signed(const char *fldname, LONGEST value)
void field_skip(const char *fldname)
void text(const char *string)
void table_header(int width, ui_align align, const std::string &col_name, const std::string &col_hdr)
struct cmd_list_element * showlist
void error_no_arg(const char *why)
struct cmd_list_element * cmdlist
struct cmd_list_element * setlist
struct cmd_list_element * maintenance_show_cmdlist
struct cmd_list_element * maintenance_set_cmdlist
struct cmd_list_element * add_cmd(const char *name, enum command_class theclass, const char *doc, struct cmd_list_element **list)
cmd_list_element * add_com_alias(const char *name, cmd_list_element *target, command_class theclass, int abbrev_flag)
void help_list(struct cmd_list_element *list, const char *cmdtype, enum command_class theclass, struct ui_file *stream)
void set_cmd_completer(struct cmd_list_element *cmd, completer_ftype *completer)
struct cmd_list_element * add_com(const char *name, enum command_class theclass, cmd_simple_func_ftype *fun, const char *doc)
set_show_commands add_setshow_enum_cmd(const char *name, enum command_class theclass, const char *const *enumlist, const char **var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
struct cmd_list_element * deprecate_cmd(struct cmd_list_element *cmd, const char *replacement)
set_show_commands add_setshow_prefix_cmd(const char *name, command_class theclass, const char *set_doc, const char *show_doc, cmd_list_element **set_subcommands_list, cmd_list_element **show_subcommands_list, cmd_list_element **set_list, cmd_list_element **show_list)
struct cmd_list_element * add_prefix_cmd(const char *name, enum command_class theclass, cmd_simple_func_ftype *fun, const char *doc, struct cmd_list_element **subcommands, int allow_unknown, struct cmd_list_element **list)
set_show_commands add_setshow_boolean_cmd(const char *name, enum command_class theclass, bool *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
void complete_on_enum(completion_tracker &tracker, const char *const *enumlist, const char *text, const char *word)
struct cmd_list_element * add_basic_prefix_cmd(const char *name, enum command_class theclass, const char *doc, struct cmd_list_element **subcommands, int allow_unknown, struct cmd_list_element **list)
struct cmd_list_element * add_info(const char *name, cmd_simple_func_ftype *fun, const char *doc)
set_show_commands add_setshow_zuinteger_cmd(const char *name, enum command_class theclass, unsigned int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
cmd_list_element * style_show_list
cmd_list_element * style_set_list
cli_style_option tui_active_border_style
cli_style_option tui_border_style
tui_source_window_iterator begin() const
virtual bool can_focus() const
void right_scroll(int num_to_scroll)
void left_scroll(int num_to_scroll)
void backward_scroll(int num_to_scroll)
virtual void do_scroll_horizontal(int num_to_scroll)=0
virtual const char * name() const =0
void forward_scroll(int num_to_scroll)
virtual void do_scroll_vertical(int num_to_scroll)=0
virtual int max_height() const
void tui_set_win_focus_to(struct tui_win_info *win_info)
int tui_term_height(void)
void tui_set_term_width_to(int w)
struct tui_win_info * tui_prev_win(struct tui_win_info *cur_win)
void tui_set_win_resized_to(bool resized)
static struct tui_win_info * win_with_focus
struct tui_win_info * tui_next_win(struct tui_win_info *cur_win)
void tui_set_term_height_to(int h)
struct tui_win_info * tui_win_with_focus(void)
int tui_term_height(void)
static std::vector< tui_win_info * > & all_tui_windows()
void tui_redisplay_readline(void)
void tui_adjust_window_height(struct tui_win_info *win, int new_height)
void tui_apply_current_layout(bool preserve_cmd_win_size_p)
known_window_names_range all_known_window_names()
void tui_adjust_window_width(struct tui_win_info *win, int new_width)
static const char * tui_active_border_mode
void tui_rehighlight_all(void)
struct cmd_list_element ** tui_get_cmd_list(void)
void tui_resize_all(void)
static void set_style_tui_current_position(const char *ignore, int from_tty, cmd_list_element *c)
static const char * tui_border_kind
static void tui_set_tab_width(const char *ignore, int from_tty, struct cmd_list_element *c)
chtype tui_border_ulcorner
static struct tui_translate tui_border_kind_translate_vline[]
static void parse_scrolling_args(const char *, struct tui_win_info **, int *)
static const char *const tui_border_mode_enums[]
static void tui_set_win_width_command(const char *arg, int from_tty)
static void tui_scroll_right_command(const char *, int)
static void focus_completer(struct cmd_list_element *ignore, completion_tracker &tracker, const char *text, const char *word)
static void tui_scroll_left_command(const char *, int)
static void show_tui_border_mode(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
static void tui_show_tab_width(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
static void tui_scroll_backward_command(const char *, int)
static unsigned int internal_tab_width
bool style_tui_current_position
static const char *const tui_border_kind_enums[]
static void update_tab_width()
static const char * tui_border_mode
chtype tui_border_lrcorner
static struct tui_translate tui_border_kind_translate_hline[]
static bool resize_message
void tui_refresh_all_win(void)
static void tui_set_var_cmd(const char *null_args, int from_tty, struct cmd_list_element *c)
unsigned int tui_tab_width
static int translate_acs(const char *name, struct tui_translate *table, int acs_char)
bool tui_update_variables()
static void tui_all_windows_info(const char *, int)
chtype tui_border_llcorner
static void tui_set_compact_source(const char *ignore, int from_tty, struct cmd_list_element *c)
static struct cmd_list_element * tuilist
static void window_name_completer(completion_tracker &tracker, bool include_next_prev_p, bool exclude_cannot_focus_p, const char *text, const char *word)
int tui_active_border_attrs
static void tui_window_command(const char *args, int from_tty)
static void show_tui_resize_message(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
static void tui_set_win_height_command(const char *arg, int from_tty)
static cmd_list_element * tui_window_cmds
static void tui_scroll_forward_command(const char *, int)
static void show_tui_border_kind(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
static void tui_show_compact_source(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
static void show_tui_active_border_mode(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
static void show_style_tui_current_position(ui_file *file, int from_tty, cmd_list_element *c, const char *value)
void tui_initialize_win(void)
static void tui_set_tab_width_command(const char *, int)
void tui_update_gdb_sizes(void)
chtype tui_border_urcorner
static void tui_refresh_all_command(const char *, int)
static void show_tui_mouse_events(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
static int translate(const char *name, struct tui_translate *table)
static struct tui_translate tui_border_mode_translate[]
static void tui_set_win_size(const char *arg, bool set_width_p)
bool tui_left_margin_verbose
void _initialize_tui_win()
static void tui_set_focus_command(const char *arg, int from_tty)
static struct tui_win_info * tui_partial_win_by_name(gdb::string_view name)
static struct tui_translate tui_border_kind_translate_corner[]
static void winheight_completer(struct cmd_list_element *ignore, completion_tracker &tracker, const char *text, const char *word)
void set_screen_width_and_height(int width, int height)
void gdb_printf(struct ui_file *stream, const char *format,...)
void printf_unfiltered(const char *format,...)