]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Use command style in cmd_show_list
authorTom Tromey <tom@tromey.com>
Sat, 11 Jan 2025 21:36:54 +0000 (14:36 -0700)
committerTom Tromey <tom@tromey.com>
Wed, 29 Jan 2025 17:21:49 +0000 (10:21 -0700)
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.

gdb/auto-load.c
gdb/cli/cli-setshow.c
gdb/remote.c

index a8f3a8d5fdd474b190a2f419f93487594019a883..71bbae4fc1d436c7ee593a47122f1e5145eef43f 100644 (file)
@@ -1472,7 +1472,7 @@ info_auto_load_cmd (const char *args, int from_tty)
   struct ui_out *uiout = current_uiout;
 
   ui_out_emit_tuple tuple_emitter (uiout, "infolist");
-
+  const ui_file_style cmd_style = command_style.style ();
   for (list = *auto_load_info_cmdlist_get (); list != NULL; list = list->next)
     {
       ui_out_emit_tuple option_emitter (uiout, "option");
@@ -1480,7 +1480,7 @@ info_auto_load_cmd (const char *args, int from_tty)
       gdb_assert (!list->is_prefix ());
       gdb_assert (list->type == not_set_cmd);
 
-      uiout->field_string ("name", list->name);
+      uiout->field_string ("name", list->name, cmd_style);
       uiout->text (":  ");
       cmd_func (list, auto_load_info_scripts_pattern_nl, from_tty);
     }
index 73b52253f5a5cc1d09b70a987e00e065db8f9c09..b438e9807647b945fd18b31208b655aa2751dfaa 100644 (file)
@@ -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);
index f3687fbaa70c41f8261f4897d0a7e4f6512b1e2a..1318352e02c3b8db0126fd94a4b88b8a3e59af2b 100644 (file)
@@ -15583,6 +15583,7 @@ show_remote_cmd (const char *args, 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)
     if (strcmp (list->name, "Z-packet") == 0)
       continue;
@@ -15594,7 +15595,7 @@ show_remote_cmd (const char *args, int from_tty)
       {
        ui_out_emit_tuple option_emitter (uiout, "option");
 
-       uiout->field_string ("name", list->name);
+       uiout->field_string ("name", list->name, cmd_style);
        uiout->text (":  ");
        if (list->type == show_cmd)
          do_show_command (NULL, from_tty, list);