From patchwork Sat May 27 18:28:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 70186 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 17002385B534 for ; Sat, 27 May 2023 18:28:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 17002385B534 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1685212132; bh=t7G/cqq1TIxXUi6M3YyQw21JF8PzPLzCrWH8Yvjn/MI=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=fDzrxwyO720ZU6TsaHZ644u/PbF6pUUSmJiVaOIsFIWbcLPxRehEGNsH4yMEnDn+z u3xxCjYtCswCEh+TM9hBGIBsW/JBRa0n8u4jvHMAu51QNIo3JqA1EDPcQf3uPNtOVY fuRv7C5oV9cPhtigihftGxcwJ/+KXYbdAOyjp6Ww= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id 426023858C50 for ; Sat, 27 May 2023 18:27:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 426023858C50 Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id DD49421AF0; Sat, 27 May 2023 18:27:55 +0000 (UTC) Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap1.suse-dmz.suse.de (Postfix) with ESMTPS id C872413532; Sat, 27 May 2023 18:27:55 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap1.suse-dmz.suse.de with ESMTPSA id WHn0L6tLcmSeCwAAGKfGzw (envelope-from ); Sat, 27 May 2023 18:27:55 +0000 To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 3/3] [gdb/tui] Add set tui default-focus first/cmd Date: Sat, 27 May 2023 20:28:09 +0200 Message-Id: <20230527182809.20569-4-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230527182809.20569-1-tdevries@suse.de> References: <20230527182809.20569-1-tdevries@suse.de> MIME-Version: 1.0 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Tom de Vries via Gdb-patches From: Tom de Vries Reply-To: Tom de Vries Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" Add a new command "set tui default-focus first/cmd" that set the default focus window. If set to first, it's the first window in the window list. If set to cmd, it's the command window. The default value is first, so the default behaviour is unchanged. Tested on x86_64-linux. PR tui/24137 https://sourceware.org/bugzilla/show_bug.cgi?id=24137 Reported-By: Martin Liška Reviewed-By: Eli Zaretskii --- gdb/doc/gdb.texinfo | 6 ++++++ gdb/tui/tui-layout.c | 31 ++++++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index d1059e0cb7f..de8b42e99c7 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -30318,6 +30318,12 @@ The default display uses more space for line numbers; the compact display uses only as much space as is needed for the line numbers in the current file. +@item set tui default-focus @r{[}first@r{|}cmd@r{]} +@kindex set tui default-focus +The default TUI window to focus on. If set to first, it's the first +window in the window list. If set to cmd, it's the command window. +The default value is first. + @kindex set debug tui @item set debug tui @r{[}on|off@r{]} Turn on or off display of @value{GDBN} internal debug messages relating diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c index ea8b4378d1e..92609e63190 100644 --- a/gdb/tui/tui-layout.c +++ b/gdb/tui/tui-layout.c @@ -46,6 +46,7 @@ #include "gdbsupport/gdb-safe-ctype.h" static void extract_display_start_addr (struct gdbarch **, CORE_ADDR *); +static tui_win_info *tui_get_window_by_name (const std::string &name); /* The layouts. */ static std::vector> layouts; @@ -64,12 +65,28 @@ static tui_layout_split *asm_regs_layout; /* See tui-data.h. */ std::vector tui_windows; +/* Choices for "tui default-focus". */ +static const char *const tui_default_focus_enums[] = { + "first", + "cmd", + NULL +}; + +/* Value of "tui default-focus". */ +static const char *tui_default_focus = "first"; + /* See tui-layout.h. */ struct tui_win_info * tui_default_focus_window () { - return tui_windows[0]; + if (strcmp (tui_default_focus, "first") == 0) + return tui_windows[0]; + + if (strcmp (tui_default_focus, "cmd") == 0) + return tui_get_window_by_name ("cmd"); + + gdb_assert_not_reached (""); } /* See tui-layout.h. */ @@ -1347,6 +1364,18 @@ Each WEIGHT is an integer, which holds the relative size\n\ to be allocated to the window."), tui_get_cmd_list ()); + + add_setshow_enum_cmd ("default-focus", no_class, tui_default_focus_enums, + &tui_default_focus, _("\ +Set the default focus window"), _("\ +Show the default focus window"), _("\ +This variable controls which TUI window is focused by default:\n\ + first first window in the window list\n\ + cmd command window"), + nullptr, + nullptr, + tui_get_cmd_set_list (), tui_get_cmd_show_list ()); + initialize_layouts (); initialize_known_windows (); }