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 | 4 ++--
gdb/cli/cli-setshow.c | 15 ++++++++++-----
gdb/remote.c | 3 ++-
3 files changed, 14 insertions(+), 8 deletions(-)
@@ -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);
}
@@ -27,6 +27,7 @@
#include "cli/cli-decode.h"
#include "cli/cli-cmds.h"
#include "cli/cli-setshow.h"
+#include "cli/cli-style.h"
#include "cli/cli-utils.h"
/* Return true if the change of command parameter should be notified. */
@@ -681,6 +682,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. */
@@ -701,15 +703,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);
@@ -15582,6 +15582,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;
@@ -15593,7 +15594,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);