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 3F6463858D38 for ; Wed, 25 Jan 2023 11:33:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3F6463858D38 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=1674646433; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=8x/6RL6tjEI0FfgaJ5HQYHhrLI4EFTNjiKLDnFRiLQM=; b=A7w9pch5FfrpPEgCezwenGZeJWdrdVjxbVzxkDuJl0fUZNTBGPjv5jy6xo5G1zHcXzTAKF Fu26oqcAI1XHd7a/FTazyuBjM74zlSeR2tUVhgsou/I+N1wlniQn0Qby/5E9S6FM5Zw23E 7imEcPpYovcbfpCRICBMAiX8/Eq3MQI= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-340-Q1NWttB5MvmTGf_efJPVWw-1; Wed, 25 Jan 2023 06:33:52 -0500 X-MC-Unique: Q1NWttB5MvmTGf_efJPVWw-1 Received: by mail-qt1-f200.google.com with SMTP id f2-20020ac80682000000b003b6364059d2so7379747qth.9 for ; Wed, 25 Jan 2023 03:33:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:date:references:in-reply-to:subject:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=zUib+++iC2DsETqzn4+CaYEZ4bmXJfVMq8f6RzphiU0=; b=J/rEJMJa/E3blxfaJfnbgZjYgd7JsdkcIrkqHm6AbmqhmFkPsoUJHXxZRxI9pRL+AY QhK4KCArc249/TxBFOFzXh08afKCANc3nNjxRBIycMZaKZrq5W4xYVPC2g7YEaXTmELI AG7i4tr8dESZ4Ba8fDqbnCAs20ItQDmwey+nGP8Y0amFtV4aOI5vdyHiWJFx5plnNn6k a8VlnQvWZslhvZ4gU3Q0R9nP2iWmDu96zWKKeLQUsCHo8IZTo/s7v0C8XywUaNtUfOY0 55eQ88t14RJHO0l7Vi2BzjzSDQHn98WU/Y6o0NaKCqt9u8eiDV+tSvwvTgq4BG2pyqCo 4Hqg== X-Gm-Message-State: AO0yUKX9/iQdo3I6LR7Y+7+J6JqI9FyP1OlCuN+Fkce0RaPDg3MEwSIJ UtnSaS58EZMJxyvnELomlpsQBqg20Q1p8Cu7RW2DnJD19E4VlwrglpLRseQ7uGAjYhblmYPK9Sp vVK6OfxlsMXq2C/p+CYqPNvtDJaqD5hbjZNjvMM1792MqJ/mNnTlTWPG/KmrOkxLgsDGvvrkfeA == X-Received: by 2002:ac8:7d14:0:b0:3b0:2fa:8a90 with SMTP id g20-20020ac87d14000000b003b002fa8a90mr3268782qtb.8.1674646431788; Wed, 25 Jan 2023 03:33:51 -0800 (PST) X-Google-Smtp-Source: AK7set9MX4RVub6XS2V7mIkSXtNggdbOoYzpd7Bx7zsFnxY8FIW/7qv80LaSsG0Fn4+buB0C6a+0Rw== X-Received: by 2002:ac8:7d14:0:b0:3b0:2fa:8a90 with SMTP id g20-20020ac87d14000000b003b002fa8a90mr3268741qtb.8.1674646431382; Wed, 25 Jan 2023 03:33:51 -0800 (PST) Received: from localhost (95.72.115.87.dyn.plus.net. [87.115.72.95]) by smtp.gmail.com with ESMTPSA id r2-20020ac83b42000000b003b6464eda40sm3156238qtf.25.2023.01.25.03.33.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jan 2023 03:33:51 -0800 (PST) From: Andrew Burgess To: gdb-patches@sourceware.org Subject: Re: [PATCH 06/15] gdb/tui: better filtering of tab completion results for focus command In-Reply-To: References: Date: Wed, 25 Jan 2023 11:33:49 +0000 Message-ID: <87bkmmx2zm.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain 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: Andrew Burgess writes: > 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. I've gone ahead and pushed this change. The final version that I pushed is included below. Thanks, Andrew --- commit 6db98f026e4dcd7ca9d069542a7bbb3f4539482b Author: Andrew Burgess Date: Tue Dec 20 15:45:32 2022 +0000 gdb/tui: better filtering of tab completion results for focus command 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. diff --git a/gdb/testsuite/gdb.tui/completion.exp b/gdb/testsuite/gdb.tui/completion.exp index a3b3114a472..97d0f806a81 100644 --- a/gdb/testsuite/gdb.tui/completion.exp +++ b/gdb/testsuite/gdb.tui/completion.exp @@ -15,8 +15,9 @@ require allow_tui_tests -gdb_exit -gdb_start +tuiterm_env + +clean_restart if {[target_info exists gdb,nointerrupts]} { return @@ -56,3 +57,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/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. */