diff options
author | Andrew Burgess <aburgess@redhat.com> | 2022-01-24 17:23:20 +0000 |
---|---|---|
committer | Andrew Burgess <aburgess@redhat.com> | 2022-04-03 15:15:08 +0100 |
commit | 51c2a9e24396f69c1e7eba6cef042fad7c07880e (patch) | |
tree | a0cef4c1156927ff88198a41237682f7440e31f4 /gdb/tui | |
parent | 6e348286d89738a7093602faba74ffe7e16eb926 (diff) | |
download | gdb-51c2a9e24396f69c1e7eba6cef042fad7c07880e.zip gdb-51c2a9e24396f69c1e7eba6cef042fad7c07880e.tar.gz gdb-51c2a9e24396f69c1e7eba6cef042fad7c07880e.tar.bz2 |
gdb: move some commands into the tui namespace
There are a lot of tui related commands that live in the top-level
command name space, e.g. layout, focus, refresh, winheight.
Having them at the top level means less typing for the user, which is
good, but, I think, makes command discovery harder.
In this commit, I propose moving all of the above mentioned commands
into the tui namespace, so 'layout' becomes 'tui layout', etc. But I
will then add aliases so that the old commands will still work,
e.g. I'll make 'layout' an alias for 'tui layout'.
The benefit I see in this work is that tui related commands can be
more easily discovered by typing 'tui ' and then tab-completing. Also
the "official" command is now a tui-sub-command, this is visible in,
for example, the help output, e.g.:
(gdb) help layout
tui layout, layout
Change the layout of windows.
Usage: tui layout prev | next | LAYOUT-NAME
List of tui layout subcommands:
tui layout asm -- Apply the "asm" layout.
tui layout next -- Apply the next TUI layout.
tui layout prev -- Apply the previous TUI layout.
tui layout regs -- Apply the TUI register layout.
tui layout split -- Apply the "split" layout.
tui layout src -- Apply the "src" layout.
Which I think is a good thing, it makes it clearer that this is a tui
command.
I've added a NEWS entry and updated the docs to mention the new and
old command names, with the new name being mentioned first.
Diffstat (limited to 'gdb/tui')
-rw-r--r-- | gdb/tui/tui-layout.c | 16 | ||||
-rw-r--r-- | gdb/tui/tui-win.c | 40 |
2 files changed, 45 insertions, 11 deletions
diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c index 6195ca1..04e5ac2 100644 --- a/gdb/tui/tui-layout.c +++ b/gdb/tui/tui-layout.c @@ -839,6 +839,14 @@ destroy_layout (struct cmd_list_element *self, void *context) static struct cmd_list_element *layout_list; +/* Called to implement 'tui layout'. */ + +static void +tui_layout_command (const char *args, int from_tty) +{ + help_list (layout_list, "tui layout ", all_commands, gdb_stdout); +} + /* Add a "layout" command with name NAME that switches to LAYOUT. */ static struct cmd_list_element * @@ -1017,10 +1025,12 @@ void _initialize_tui_layout (); void _initialize_tui_layout () { - add_basic_prefix_cmd ("layout", class_tui, _("\ + struct cmd_list_element *layout_cmd + = add_prefix_cmd ("layout", class_tui, tui_layout_command, _("\ Change the layout of windows.\n\ -Usage: layout prev | next | LAYOUT-NAME"), - &layout_list, 0, &cmdlist); +Usage: tui layout prev | next | LAYOUT-NAME"), + &layout_list, 0, tui_get_cmd_list ()); + add_com_alias ("layout", layout_cmd, class_tui, 0); add_cmd ("next", class_tui, tui_next_layout_command, _("Apply the next TUI layout."), diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c index b95d72d..1371861 100644 --- a/gdb/tui/tui-win.c +++ b/gdb/tui/tui-win.c @@ -977,6 +977,18 @@ parse_scrolling_args (const char *arg, } } +/* The list of 'tui window' sub-commands. */ + +static cmd_list_element *tui_window_cmds = nullptr; + +/* Called to implement 'tui window'. */ + +static void +tui_window_command (const char *args, int from_tty) +{ + help_list (tui_window_cmds, "tui window ", all_commands, gdb_stdout); +} + /* Function to initialize gdb commands, for tui window manipulation. */ @@ -995,8 +1007,11 @@ _initialize_tui_win () &tui_setlist, &tui_showlist, &setlist, &showlist); - add_com ("refresh", class_tui, tui_refresh_all_command, - _("Refresh the terminal display.")); + cmd_list_element *refresh_cmd + = add_cmd ("refresh", class_tui, tui_refresh_all_command, + _("Refresh the terminal display."), + tui_get_cmd_list ()); + add_com_alias ("refresh", refresh_cmd, class_tui, 0); cmd_list_element *tabset_cmd = add_com ("tabset", class_tui, tui_set_tab_width_command, _("\ @@ -1004,21 +1019,30 @@ Set the width (in characters) of tab stops.\n\ Usage: tabset N")); deprecate_cmd (tabset_cmd, "set tui tab-width"); + /* Setup the 'tui window' list of command. */ + add_prefix_cmd ("window", class_tui, tui_window_command, + _("Text User Interface window commands."), + &tui_window_cmds, 1, tui_get_cmd_list ()); + cmd_list_element *winheight_cmd - = add_com ("winheight", class_tui, tui_set_win_height_command, _("\ + = add_cmd ("height", class_tui, tui_set_win_height_command, _("\ Set or modify the height of a specified window.\n\ -Usage: winheight WINDOW-NAME [+ | -] NUM-LINES\n\ -Use \"info win\" to see the names of the windows currently being displayed.")); +Usage: tui window height WINDOW-NAME [+ | -] NUM-LINES\n\ +Use \"info win\" to see the names of the windows currently being displayed."), + &tui_window_cmds); + add_com_alias ("winheight", winheight_cmd, class_tui, 0); add_com_alias ("wh", winheight_cmd, class_tui, 0); set_cmd_completer (winheight_cmd, winheight_completer); add_info ("win", tui_all_windows_info, _("List of all displayed windows.\n\ Usage: info win")); cmd_list_element *focus_cmd - = add_com ("focus", class_tui, tui_set_focus_command, _("\ + = add_cmd ("focus", class_tui, tui_set_focus_command, _("\ Set focus to named window or next/prev window.\n\ -Usage: focus [WINDOW-NAME | next | prev]\n\ -Use \"info win\" to see the names of the windows currently being displayed.")); +Usage: tui focus [WINDOW-NAME | next | prev]\n\ +Use \"info win\" to see the names of the windows currently being displayed."), + tui_get_cmd_list ()); + add_com_alias ("focus", focus_cmd, class_tui, 0); add_com_alias ("fs", focus_cmd, class_tui, 0); set_cmd_completer (focus_cmd, focus_completer); add_com ("+", class_tui, tui_scroll_forward_command, _("\ |