aboutsummaryrefslogtreecommitdiff
path: root/gdb/cli
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2025-01-11 14:36:54 -0700
committerTom Tromey <tom@tromey.com>2025-01-29 10:21:49 -0700
commit7627b430434117181323985ada05abde8a474fe7 (patch)
tree597a403481c8ecd2f78bc9f31845a3661ca00395 /gdb/cli
parent59d2fac1004a9d6b75ebb52b8faacffed1704021 (diff)
downloadbinutils-7627b430434117181323985ada05abde8a474fe7.zip
binutils-7627b430434117181323985ada05abde8a474fe7.tar.gz
binutils-7627b430434117181323985ada05abde8a474fe7.tar.bz2
Use command style in cmd_show_list
cmd_show_list is a bit funny because it shows partial command names -- for a command like "show abc xyz", it will only show "abc xyz". Nevertheless, I think it makes some sense to highlight these with the command style. That is what this patch does.
Diffstat (limited to 'gdb/cli')
-rw-r--r--gdb/cli/cli-setshow.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/gdb/cli/cli-setshow.c b/gdb/cli/cli-setshow.c
index 73b5225..b438e98 100644
--- a/gdb/cli/cli-setshow.c
+++ b/gdb/cli/cli-setshow.c
@@ -707,6 +707,7 @@ cmd_show_list (struct cmd_list_element *list, int from_tty)
struct ui_out *uiout = current_uiout;
ui_out_emit_tuple tuple_emitter (uiout, "showlist");
+ const ui_file_style cmd_style = command_style.style ();
for (; list != NULL; list = list->next)
{
/* We skip show command aliases to avoid showing duplicated values. */
@@ -727,15 +728,18 @@ cmd_show_list (struct cmd_list_element *list, int from_tty)
{
ui_out_emit_tuple option_emitter (uiout, "option");
- if (list->prefix != nullptr)
+ if (!uiout->is_mi_like_p () && list->prefix != nullptr)
{
/* If we find a prefix, output it (with "show " skipped). */
std::string prefixname = list->prefix->prefixname ();
- prefixname = (!list->prefix->is_prefix () ? ""
- : strstr (prefixname.c_str (), "show ") + 5);
- uiout->text (prefixname);
+ if (startswith (prefixname, "show "))
+ prefixname = prefixname.substr (5);
+ /* In non-MI mode, we include the full name here. */
+ prefixname += list->name;
+ uiout->field_string ("name", prefixname, cmd_style);
}
- uiout->field_string ("name", list->name);
+ else
+ uiout->field_string ("name", list->name, cmd_style);
uiout->text (": ");
if (list->type == show_cmd)
do_show_command (NULL, from_tty, list);