From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id D5F493858296 for ; Fri, 6 Jan 2023 10:26:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D5F493858296 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673000766; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GtG+EvV46ItpSwvgzeUaRiUk0gyLCcZrg/i55WvIzAI=; b=Vx3XabfSBDCwMB6mtAG+b9amRrO42R/EaNnX6I429l8ItlqOIT3Uw0vQ1O36z1j6z5apII 0VoCYmB5KvlVH5TOzIR/G1hZgRJ6VCWvIXBjRtQfWZMVC4kS73jOaWxV2pDCvDAuiWfS7x pNlB9mgpmrm2o/Db0Hc5ETw4/ueSxE4= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-632-T6QBYnwFPCaPDqdAvnjyaw-1; Fri, 06 Jan 2023 05:26:03 -0500 X-MC-Unique: T6QBYnwFPCaPDqdAvnjyaw-1 Received: by mail-ed1-f72.google.com with SMTP id x13-20020a05640226cd00b0047ac11c9774so949555edd.17 for ; Fri, 06 Jan 2023 02:26:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QewMKpnl7bqL9aHbw2HAXfmxbcqIXXFAcaa4h0JOz68=; b=BK3jZlFfHPWm8g56m9rOWEtdi7Ma6KWhj3qG/RWyG4W93jdVHXK9WLArBUrrpQ//j8 UfpB2/nLMN/Rra8GPPbNU19EmY3CYxv0akfRMqNeGp9amZXwvpixdFjuHZ+H7rCvqvu3 GhT5cd9tNJuhxqkJaEyWCw5aH3biF+i57hKWH2qCdGiqGNsM43/SphopbQOdkqPMzvt8 gcZJ/8kd0ynhaPnc00s1JEUcEsQx8cf05i23PzRLQHw8eEOGlh0x8A7pbPLmQ3rhQ1EL Q7fL7iK+yJqBcVkvD92myimVT9XHH/hUa73a0rbxDafbzG6vc+hos01RNj8OVD+Fg015 o2/g== X-Gm-Message-State: AFqh2kocarKTIX4rG1d+q/QodhgJDwhO6jdaEH9xWTIDwmvX+7KEyJMy toB0cxZFx3RZNoU4ACcls1Zx1cV2FDcZkfi5reUzwPOsebFjzZzUZqfSDnH168fswix/oB6q4wf 2RtwmASgtU4jh+sYqU6g1W+1WIf4RKbIIy5n9CVOLayRc/X9yStA2uSUd1mNtS7NSAK3ESNhqOw == X-Received: by 2002:a17:907:2be8:b0:7e6:bae:fa0f with SMTP id gv40-20020a1709072be800b007e60baefa0fmr50652713ejc.58.1673000762092; Fri, 06 Jan 2023 02:26:02 -0800 (PST) X-Google-Smtp-Source: AMrXdXt89a/urUjiAWywXcrJ1lqV+NOUsPPPHqiLeCYz8mPcSlOCTvUZ1HbPUYaSuDt78CioRQaGIg== X-Received: by 2002:a17:907:2be8:b0:7e6:bae:fa0f with SMTP id gv40-20020a1709072be800b007e60baefa0fmr50652692ejc.58.1673000761751; Fri, 06 Jan 2023 02:26:01 -0800 (PST) Received: from localhost (95.72.115.87.dyn.plus.net. [87.115.72.95]) by smtp.gmail.com with ESMTPSA id e21-20020aa7d7d5000000b0048ca2b6c370sm357624eds.29.2023.01.06.02.26.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Jan 2023 02:26:01 -0800 (PST) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 06/15] gdb/tui: better filtering of tab completion results for focus command Date: Fri, 6 Jan 2023 10:25:33 +0000 Message-Id: X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00,DKIM_INVALID,DKIM_SIGNED,GIT_PATCH_0,KAM_DMARC_NONE,KAM_DMARC_STATUS,KAM_SHORT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: While working on the previous couple of commits, I noticed that the 'focus' command would happily suggest 'status' as a possible focus completion, even though the 'status' window is non-focusable, and, after the previous couple of commits, trying to focus the status window will result in an error. This commit improves the tab-completion results for the focus command so that the status window is not included. --- gdb/testsuite/gdb.tui/completion.exp | 18 ++++++++++++++++-- gdb/testsuite/gdb.tui/tui-focus.exp | 4 +--- gdb/tui/tui-win.c | 24 +++++++++++++++++------- 3 files changed, 34 insertions(+), 12 deletions(-) diff --git a/gdb/testsuite/gdb.tui/completion.exp b/gdb/testsuite/gdb.tui/completion.exp index 00956488c9f..1d7de65abb7 100644 --- a/gdb/testsuite/gdb.tui/completion.exp +++ b/gdb/testsuite/gdb.tui/completion.exp @@ -13,8 +13,9 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -gdb_exit -gdb_start +tuiterm_env + +clean_restart if {[skip_tui_tests] || [target_info exists gdb,nointerrupts]} { return @@ -54,3 +55,16 @@ with_test_prefix "completion of layout names" { with_test_prefix "completion of focus command" { test_tab_completion "focus" "cmd *next *prev *src *" } + +# Now run some completion tests when TUI mode is enabled. +Term::clean_restart 24 80 +if {![Term::prepare_for_tui]} { + unsupported "TUI not supported" + return +} + +Term::command "layout src" +Term::command "complete focus " +Term::dump_screen +Term::check_region_contents "check focus completions" 0 17 80 5 \ + "focus cmd\\s*focus next\\s*focus prev\\s*focus src\\s*$gdb_prompt" diff --git a/gdb/testsuite/gdb.tui/tui-focus.exp b/gdb/testsuite/gdb.tui/tui-focus.exp index 156ced44e05..0563aacd0a2 100644 --- a/gdb/testsuite/gdb.tui/tui-focus.exp +++ b/gdb/testsuite/gdb.tui/tui-focus.exp @@ -33,8 +33,7 @@ if {[skip_tui_tests]} { # Each test specification is a tuple where the first item is the name of a # window, and the second item is a boolean indicating if we expect that # window to be present in the default (src) layout. -##foreach spec {{src true} {cmd true} {status true} {regs false} {asm false}} {} -foreach spec {{status false}} { +foreach spec {{src true} {cmd true} {status false} {regs false} {asm false}} { lassign $spec window valid_p with_test_prefix "window=$window" { @@ -60,7 +59,6 @@ foreach spec {{status false}} { } Term::check_box "check src box" 0 0 80 15 - Term::command "focus prev" } } diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c index 4fc8e7a4503..492a5191025 100644 --- a/gdb/tui/tui-win.c +++ b/gdb/tui/tui-win.c @@ -362,13 +362,19 @@ show_tui_resize_message (struct ui_file *file, int from_tty, /* Generic window name completion function. Complete window name pointed - to by TEXT and WORD. If INCLUDE_NEXT_PREV_P is true then the special - window names 'next' and 'prev' will also be considered as possible - completions of the window name. */ + to by TEXT and WORD. + + If EXCLUDE_CANNOT_FOCUS_P is true, then windows that can't take focus + will be excluded from the completions, otherwise they will be included. + + If INCLUDE_NEXT_PREV_P is true then the special window names 'next' and + 'prev' will also be considered as possible completions of the window + name. This is independent of EXCLUDE_CANNOT_FOCUS_P. */ static void window_name_completer (completion_tracker &tracker, - int include_next_prev_p, + bool include_next_prev_p, + bool exclude_cannot_focus_p, const char *text, const char *word) { std::vector completion_name_vec; @@ -377,10 +383,14 @@ window_name_completer (completion_tracker &tracker, { const char *completion_name = NULL; - /* We can't focus on an invisible window. */ + /* Don't include an invisible window. */ if (!win_info->is_visible ()) continue; + /* If requested, exclude windows that can't be focused. */ + if (exclude_cannot_focus_p && !win_info->can_focus ()) + continue; + completion_name = win_info->name (); gdb_assert (completion_name != NULL); completion_name_vec.push_back (completion_name); @@ -415,7 +425,7 @@ focus_completer (struct cmd_list_element *ignore, completion_tracker &tracker, const char *text, const char *word) { - window_name_completer (tracker, 1, text, word); + window_name_completer (tracker, true, true, text, word); } /* Complete possible window names for winheight command. TEXT is the @@ -432,7 +442,7 @@ winheight_completer (struct cmd_list_element *ignore, if (word != text) return; - window_name_completer (tracker, 0, text, word); + window_name_completer (tracker, false, false, text, word); } /* Update gdb's knowledge of the terminal size. */ -- 2.25.4