public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH 2/3] [gdb/tui] Add tui_get_cmd_set/show_list
Date: Sat, 27 May 2023 20:28:08 +0200	[thread overview]
Message-ID: <20230527182809.20569-3-tdevries@suse.de> (raw)
In-Reply-To: <20230527182809.20569-1-tdevries@suse.de>

Add new functions:
- tui_get_cmd_set_list, and
- tui_get_cmd_show_list,
similar to tui_get_cmd_list that allow introducing "set/show tui" commands in
files other than tui/tui-win.c.

No functional changes.  No users in this patch.

Tested on x86_64-linux.
---
 gdb/tui/tui-win.c | 50 ++++++++++++++++++++++++++++++++++++++++-------
 gdb/tui/tui-win.h |  6 ++++++
 2 files changed, 49 insertions(+), 7 deletions(-)

diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index 7abd1e225b9..c187f7c33ad 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -336,6 +336,47 @@ tui_get_cmd_list (void)
   return &tuilist;
 }
 
+/* The "tui set" command list. */
+
+static struct cmd_list_element *tui_setlist;
+
+/* The "tui show" command list. */
+
+static struct cmd_list_element *tui_showlist;
+
+/* Initialize the tui_setlist and tui_showlist variables. */
+
+static void
+init_tui_set_show_lists ()
+{
+  if (tui_setlist != nullptr)
+    return;
+
+  add_setshow_prefix_cmd ("tui", class_tui,
+			  _("TUI configuration variables."),
+			  _("TUI configuration variables."),
+			  &tui_setlist, &tui_showlist,
+			  &setlist, &showlist);
+}
+
+/* See tui-win.h.  */
+
+struct cmd_list_element **
+tui_get_cmd_set_list ()
+{
+  init_tui_set_show_lists ();
+  return &tui_setlist;
+}
+
+/* See tui-win.h.  */
+
+struct cmd_list_element **
+tui_get_cmd_show_list ()
+{
+  init_tui_set_show_lists ();
+  return &tui_showlist;
+}
+
 /* The set_func hook of "set tui ..." commands that affect the window
    borders on the TUI display.  */
 
@@ -1127,16 +1168,11 @@ void _initialize_tui_win ();
 void
 _initialize_tui_win ()
 {
-  static struct cmd_list_element *tui_setlist;
-  static struct cmd_list_element *tui_showlist;
+  /* Initialize tui_setlist and tui_showlist.  */
+  init_tui_set_show_lists ();
 
   /* Define the classes of commands.
      They will appear in the help list in the reverse of this order.  */
-  add_setshow_prefix_cmd ("tui", class_tui,
-			  _("TUI configuration variables."),
-			  _("TUI configuration variables."),
-			  &tui_setlist, &tui_showlist,
-			  &setlist, &showlist);
 
   cmd_list_element *refresh_cmd
     = add_cmd ("refresh", class_tui, tui_refresh_all_command,
diff --git a/gdb/tui/tui-win.h b/gdb/tui/tui-win.h
index 3d35f1dfb7f..4de938fa280 100644
--- a/gdb/tui/tui-win.h
+++ b/gdb/tui/tui-win.h
@@ -48,6 +48,12 @@ extern void tui_update_gdb_sizes (void);
 /* Create or get the TUI command list.  */
 struct cmd_list_element **tui_get_cmd_list (void);
 
+/* Create or get the TUI set command list.  */
+extern struct cmd_list_element **tui_get_cmd_set_list ();
+
+/* Create or get the TUI show command list.  */
+extern struct cmd_list_element **tui_get_cmd_show_list ();
+
 /* Whether compact source display should be used.  */
 extern bool compact_source;
 
-- 
2.35.3


  parent reply	other threads:[~2023-05-27 18:27 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-27 18:28 [PATCH 0/3] [gdb/tui] Add setting for default focus window Tom de Vries
2023-05-27 18:28 ` [PATCH 1/3] [gdb/tui] Add tui_default_focus_window Tom de Vries
2023-05-30 13:39   ` Alexandra Petlanova Hajkova
2023-05-27 18:28 ` Tom de Vries [this message]
2023-05-30 13:41   ` [PATCH 2/3] [gdb/tui] Add tui_get_cmd_set/show_list Alexandra Petlanova Hajkova
2023-05-27 18:28 ` [PATCH 3/3] [gdb/tui] Add set tui default-focus first/cmd Tom de Vries
2023-05-28  5:15   ` Eli Zaretskii
2023-05-30 13:42   ` Alexandra Petlanova Hajkova
2023-05-28  5:15 ` [PATCH 0/3] [gdb/tui] Add setting for default focus window Eli Zaretskii

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=20230527182809.20569-3-tdevries@suse.de \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.com \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).