[v2,2/3] Replace uses of "title" style with "command"

Message ID 20241127-cli-command-style-v2-2-6dc216226169@tromey.com
State New
Headers
Series Add "command" styling |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Test passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Test passed

Commit Message

Tom Tromey Nov. 28, 2024, 12:20 a.m. UTC
  Currently the "title" style is only used when printing command names.
The "title" name itself is probably a misnomer, but meanwhile this
patch changes the existing uses to instead use the new "command" style
for consistency.

The "title" style is not removed; see the next patch.

Reviewed-By: Keith Seitz <keiths@redhat.com>
---
 gdb/cli/cli-decode.c             | 16 ++++++++--------
 gdb/cli/cli-script.c             |  2 +-
 gdb/testsuite/gdb.base/style.exp | 14 +++++++-------
 gdb/testsuite/lib/gdb-utils.exp  |  1 +
 4 files changed, 17 insertions(+), 16 deletions(-)
  

Patch

diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c
index 295119494ce4e48d047a88ca7b63e4aa26c61c66..4fbbfcb6aeb9fd8709d6c235d103d7d23c30af8e 100644
--- a/gdb/cli/cli-decode.c
+++ b/gdb/cli/cli-decode.c
@@ -1530,7 +1530,7 @@  add_com_suppress_notification (const char *name, enum command_class theclass,
 					&cmdlist, suppress_notification);
 }
 
-/* Print the prefix of C followed by name of C in title style.  */
+/* Print the prefix of C followed by name of C in command style.  */
 
 static void
 fput_command_name_styled (const cmd_list_element &c, struct ui_file *stream)
@@ -1538,7 +1538,7 @@  fput_command_name_styled (const cmd_list_element &c, struct ui_file *stream)
   std::string prefixname
     = c.prefix == nullptr ? "" : c.prefix->prefixname ();
 
-  fprintf_styled (stream, title_style.style (), "%s%s",
+  fprintf_styled (stream, command_style.style (), "%s%s",
 		  prefixname.c_str (), c.name);
 }
 
@@ -2509,21 +2509,21 @@  deprecated_cmd_warning (const char *text, struct cmd_list_element *list)
 
       if (cmd->cmd_deprecated)
 	gdb_printf (_("Warning: command '%ps' (%ps) is deprecated.\n"),
-		    styled_string (title_style.style (),
+		    styled_string (command_style.style (),
 				   tmp_cmd_str.c_str ()),
-		    styled_string (title_style.style (),
+		    styled_string (command_style.style (),
 				   tmp_alias_str.c_str ()));
       else
 	gdb_printf (_("Warning: '%ps', an alias for the command '%ps', "
 		      "is deprecated.\n"),
-		    styled_string (title_style.style (),
+		    styled_string (command_style.style (),
 				   tmp_alias_str.c_str ()),
-		    styled_string (title_style.style (),
+		    styled_string (command_style.style (),
 				   tmp_cmd_str.c_str ()));
     }
   else
     gdb_printf (_("Warning: command '%ps' is deprecated.\n"),
-		styled_string (title_style.style (),
+		styled_string (command_style.style (),
 			       tmp_cmd_str.c_str ()));
 
   /* Now display a second line indicating what the user should use instead.
@@ -2536,7 +2536,7 @@  deprecated_cmd_warning (const char *text, struct cmd_list_element *list)
     replacement = cmd->replacement;
   if (replacement != nullptr)
     gdb_printf (_("Use '%ps'.\n\n"),
-		styled_string (title_style.style (),
+		styled_string (command_style.style (),
 			       replacement));
   else
     gdb_printf (_("No alternative known.\n\n"));
diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c
index 329f780f9160d7a2cba450085e6b8811bc859b4e..9131768e27ca79e9a6d56ea2ed0b54a5e93fada1 100644
--- a/gdb/cli/cli-script.c
+++ b/gdb/cli/cli-script.c
@@ -1667,7 +1667,7 @@  show_user_1 (struct cmd_list_element *c, const char *prefix, const char *name,
 
       gdb_printf (stream, "User %scommand \"",
 		  c->is_prefix () ? "prefix" : "");
-      fprintf_styled (stream, title_style.style (), "%s%s",
+      fprintf_styled (stream, command_style.style (), "%s%s",
 		      prefix, name);
       gdb_printf (stream, "\":\n");
       if (cmdlines)
diff --git a/gdb/testsuite/gdb.base/style.exp b/gdb/testsuite/gdb.base/style.exp
index d29b2381923dec76646226792212778f30a7aa52..83e0faeebd07428b08ea311b4b6193547dd350a1 100644
--- a/gdb/testsuite/gdb.base/style.exp
+++ b/gdb/testsuite/gdb.base/style.exp
@@ -238,8 +238,8 @@  proc run_style_tests { } {
 	    "The ${address_style_expr} foreground color is: ${color}" \
 	    "style name and style word styled using its own style in show style"
 
-	set aliases_expr [limited_style ".*aliases.*" title]
-	set breakpoints_expr [limited_style ".*breakpoints.*" title]
+	set aliases_expr [limited_style ".*aliases.*" command]
+	set breakpoints_expr [limited_style ".*breakpoints.*" command]
 	gdb_test "help" \
 	    [multi_line \
 		 "List of classes of commands:" \
@@ -248,10 +248,10 @@  proc run_style_tests { } {
 		 "${breakpoints_expr} -- Making program stop at certain points\." \
 		 ".*" \
 		] \
-	    "help classes of commands styled with title"
+	    "help classes of commands styled with command"
 
-	set taas_expr  [limited_style ".*taas.*" title]
-	set tfaas_expr  [limited_style ".*tfaas.*" title]
+	set taas_expr  [limited_style ".*taas.*" command]
+	set tfaas_expr  [limited_style ".*tfaas.*" command]
 	set cut_for_thre_expr [limited_style "cut for 'thre" highlight]
 	gdb_test "apropos -v cut for 'thre" \
 	    [multi_line \
@@ -301,7 +301,7 @@  proc run_style_tests { } {
 	gdb_test_no_output "maintenance deprecate p \"new_p\"" \
 	    "maintenance deprecate p \"new_p\" /1/"
 	gdb_test "p 5" \
-	    "Warning: '[limited_style p title]', an alias for the command '[limited_style print title]', is deprecated.*Use '[limited_style new_p title]'.*" \
+	    "Warning: '[limited_style p command]', an alias for the command '[limited_style print command]', is deprecated.*Use '[limited_style new_p command]'.*" \
 	    "p deprecated warning, with replacement"
 
 	# Check that the version string is styled in the output of 'show
@@ -503,7 +503,7 @@  with_test_prefix "all styles enabled" {
 
 # Now, for each style in turn.  Disable that style only and run the
 # test again.  Things in that style should NOT now be styled.
-foreach style { title file function highlight variable \
+foreach style { command title file function highlight variable \
 		    address metadata } {
     set currently_disabled_style $style
     with_test_prefix "disable style $style" {
diff --git a/gdb/testsuite/lib/gdb-utils.exp b/gdb/testsuite/lib/gdb-utils.exp
index 33b56fb3f99dcf1ba02d492d358ebd509cd85f9d..34223e654edf87dbf4ecc3b94ab598f818088063 100644
--- a/gdb/testsuite/lib/gdb-utils.exp
+++ b/gdb/testsuite/lib/gdb-utils.exp
@@ -69,6 +69,7 @@  proc string_list_to_regexp { args } {
 proc style {str style} {
     switch -exact -- $style {
 	title { set style 1 }
+	command { set style 1 }
 	file { set style 32 }
 	function { set style 33 }
 	highlight { set style 31 }