Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@adacore.com>, Eli Zaretskii <eliz@gnu.org>
Subject: [PATCH v2 2/2] Allow check-mark to be changed for CLI
Date: Wed, 11 Jun 2025 07:58:44 -0600	[thread overview]
Message-ID: <20250611-emoji-check-mark-v2-2-d299ec101650@adacore.com> (raw)
In-Reply-To: <20250611-emoji-check-mark-v2-0-d299ec101650@adacore.com>

In keeping with the emojification of gdb, this patch changes the
default "current" marker to be a check-mark.  It adds a knob to allow
the character to be changed, and, as always, reverts to the old output
when emojis are disabled.

Reviewed-By: Eli Zaretskii <eliz@gnu.org>
---
 gdb/NEWS                         |  6 ++++++
 gdb/cli-out.c                    |  8 ++++++++
 gdb/cli-out.h                    |  2 ++
 gdb/cli/cli-style.c              | 31 +++++++++++++++++++++++++++++++
 gdb/cli/cli-style.h              |  3 +++
 gdb/doc/gdb.texinfo              | 12 ++++++++++++
 gdb/testsuite/gdb.base/style.exp |  4 ++++
 7 files changed, 66 insertions(+)

diff --git a/gdb/NEWS b/gdb/NEWS
index 4dcc344b07278654b1d54ca71db6749d62890d01..fd2e909595132927ed0c2eb9e5739824f5d9942a 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -78,6 +78,12 @@ set style error-prefix STRING
   with emoji display, and so the prefixes are only displayed if emoji
   styling is enabled.
 
+set style check-mark STRING
+  Set the string that is used to indicate the "current" row when a
+  table is printed by the CLI.  This functionality is intended for use
+  with emoji display, and so the prefixes are only displayed if emoji
+  styling is enabled.
+
 info linker-namespaces
 info linker-namespaces [[N]]
   Print information about the given linker namespace (identified as N),
diff --git a/gdb/cli-out.c b/gdb/cli-out.c
index 27a82f607eb3d6abcd9867880e99f824a0392312..c619bb4243dbfe4bdc0fb442e7496aa066b52575 100644
--- a/gdb/cli-out.c
+++ b/gdb/cli-out.c
@@ -421,6 +421,14 @@ cli_ui_out::do_progress_end ()
   m_progress_info.pop_back ();
 }
 
+/* See ui-out.h.  */
+
+const char *
+cli_ui_out::get_check_mark ()
+{
+  return ::get_check_mark ();
+}
+
 /* local functions */
 
 void
diff --git a/gdb/cli-out.h b/gdb/cli-out.h
index c761dacc9a83cf5ffadfca2ee4751a37c2159402..342f2d0a15fb1d3823214d2f946f4ac10ca9346d 100644
--- a/gdb/cli-out.h
+++ b/gdb/cli-out.h
@@ -81,6 +81,8 @@ class cli_ui_out : public ui_out
 				   double, double) override;
   virtual void do_progress_end () override;
 
+  const char *get_check_mark () override;
+
   bool suppress_output ()
   { return m_suppress_output; }
 
diff --git a/gdb/cli/cli-style.c b/gdb/cli/cli-style.c
index e6441277d05f5215ecf3f04a8c82be65d9fd031d..831f5051ee03aa8eae7c1f23ca6faa496052d538 100644
--- a/gdb/cli/cli-style.c
+++ b/gdb/cli/cli-style.c
@@ -494,6 +494,29 @@ print_error_prefix (ui_file *file)
     gdb_puts (error_prefix.c_str (), file);
 }
 
+/* Emoji check-mark.  */
+static std::string check_mark = "✔️";
+
+/* Implement 'show style check-mark'.  */
+
+static void
+show_check_mark (struct ui_file *file, int from_tty,
+		 struct cmd_list_element *c, const char *value)
+{
+  gdb_printf (file, _("Check mark is \"%s\".\n"),
+	      check_mark.c_str ());
+}
+
+/* See cli-style.h.  */
+
+const char *
+get_check_mark ()
+{
+  if (emojis_ok ())
+    return check_mark.c_str ();
+  return "*";
+}
+
 void _initialize_cli_style ();
 void
 _initialize_cli_style ()
@@ -737,4 +760,12 @@ The error prefix text is displayed before any error, when\n\
 emoji output is enabled."),
 			  nullptr, show_error_prefix,
 			  &style_set_list, &style_show_list);
+  add_setshow_string_cmd ("check-mark", no_class,
+			  &check_mark,
+			  _("Set the check mark string."),
+			  _("Show the check mark string."),
+			  _("\
+The check mark is the string used to indicate the current line in a table."),
+			  nullptr, show_check_mark,
+			  &style_set_list, &style_show_list);
 }
diff --git a/gdb/cli/cli-style.h b/gdb/cli/cli-style.h
index b1a950a539cb8eaf5381f3ea546ee9fa3e87500b..7b88424d972303b592149499985e7d868494be03 100644
--- a/gdb/cli/cli-style.h
+++ b/gdb/cli/cli-style.h
@@ -204,4 +204,7 @@ extern void print_warning_prefix (ui_file *file);
 /* Print the error prefix, if desired.  */
 extern void print_error_prefix (ui_file *file);
 
+/* Return the current check mark string.  */
+extern const char *get_check_mark ();
+
 #endif /* GDB_CLI_CLI_STYLE_H */
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 7d06e1f5fa4eb1fc348f8b22a90f79f019ae5e6b..916caced26cb86b14fa9fed9c03f0fd70a78ad5b 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -28022,6 +28022,18 @@ emoji display, and so the prefixes are only displayed if emoji styling
 is enabled.  The defaults are the warning sign emoji for warnings, and
 and the cross mark emoji for errors.
 
+@item set style check-mark @var{string}
+@itemx show style check-mark
+These commands control the string that the CLI uses to indicate which
+line in a table indicates the current state of @value{GDBN}.  For
+example, this would be used to indicate the current thread in the
+output of @samp{info threads}.  This functionality is intended for use
+with emoji display, and so the chosen string is only displayed if
+emoji styling is enabled.  The default is a check mark character; with
+the non-emoji fallback being an asterisk.  Note that @value{GDBN} will
+not adjust the column widths of the table, so normally this should
+only be set to a single character.
+
 @item set style tui-current-position @samp{on|off}
 Enable or disable styling of the source and assembly code highlighted
 by the TUI's current position indicator.  The default is @samp{off}.
diff --git a/gdb/testsuite/gdb.base/style.exp b/gdb/testsuite/gdb.base/style.exp
index c10be3bc12aa10f5a13856cb14f7fad86f32ff90..9f2a288e953f0711d698673e723d6192c3862d79 100644
--- a/gdb/testsuite/gdb.base/style.exp
+++ b/gdb/testsuite/gdb.base/style.exp
@@ -341,6 +341,10 @@ proc run_style_tests { } {
 	gdb_test "maint translate-address" \
 	    "abcd:requires argument.*" \
 	    "error prefix"
+
+	gdb_test_no_output "set style check-mark @"
+	gdb_test "info inferior" "\r\n@ 1 .*"
+	gdb_test "show style check-mark" "Check mark is \"@\"\\."
     }
 }
 

-- 
2.49.0


  parent reply	other threads:[~2025-06-11 14:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-11 13:58 [PATCH v2 0/2] Use check-mark for current row of CLI table Tom Tromey
2025-06-11 13:58 ` [PATCH v2 1/2] Introduce ui_out::field_check_mark Tom Tromey
2025-06-11 17:39   ` Kevin Buettner
2025-06-11 13:58 ` Tom Tromey [this message]
2025-06-11 14:33   ` [PATCH v2 2/2] Allow check-mark to be changed for CLI Simon Marchi
2025-06-11 14:57     ` Simon Marchi
2025-06-11 15:01     ` Eli Zaretskii
2025-06-11 15:18       ` Simon Marchi
2025-06-11 15:40         ` Eli Zaretskii
2025-06-11 17:37     ` Kevin Buettner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250611-emoji-check-mark-v2-2-d299ec101650@adacore.com \
    --to=tromey@adacore.com \
    --cc=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox