From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1726) id 4E855385B52B; Wed, 25 Jan 2023 11:27:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4E855385B52B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1674646052; bh=+U2//Zfmf3dN3UBwAikJ0lk9a+k+1nyDK49hIS/tij4=; h=From:To:Subject:Date:From; b=Nihlwl95MScj8u77daiJ5OnLVhincuZXum0CgSUZGDwA3PSvzapzSHMRlvx70JWNs gTKLQv3ByYc3nemMGGIwTC/vCgoIm5MNQvjCAo4ac+7O2E8Qs8eHi70pC3XxQMl2wZ O3LXH6vkZP0SULjonm2Vak5Y43slY8EueGtgTWFk= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Andrew Burgess To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb/tui: better filtering of tab completion results for focus command X-Act-Checkin: binutils-gdb X-Git-Author: Andrew Burgess X-Git-Refname: refs/heads/master X-Git-Oldrev: 6789344ab22f7fbce94a31297b994f85685b90c6 X-Git-Newrev: 6db98f026e4dcd7ca9d069542a7bbb3f4539482b Message-Id: <20230125112732.4E855385B52B@sourceware.org> Date: Wed, 25 Jan 2023 11:27:32 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D6db98f026e4d= cd7ca9d069542a7bbb3f4539482b 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 =20 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. =20 This commit improves the tab-completion results for the focus command so that the status window is not included. Diff: --- gdb/testsuite/gdb.tui/completion.exp | 18 ++++++++++++++++-- gdb/tui/tui-win.c | 24 +++++++++++++++++------- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/gdb/testsuite/gdb.tui/completion.exp b/gdb/testsuite/gdb.tui/c= ompletion.exp index a3b3114a472..97d0f806a81 100644 --- a/gdb/testsuite/gdb.tui/completion.exp +++ b/gdb/testsuite/gdb.tui/completion.exp @@ -15,8 +15,9 @@ =20 require allow_tui_tests =20 -gdb_exit -gdb_start +tuiterm_env + +clean_restart =20 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 fr= om_tty, =0C =20 /* 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. */ =20 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 =3D NULL; =20 - /* We can't focus on an invisible window. */ + /* Don't include an invisible window. */ if (!win_info->is_visible ()) continue; =20 + /* If requested, exclude windows that can't be focused. */ + if (exclude_cannot_focus_p && !win_info->can_focus ()) + continue; + completion_name =3D win_info->name (); gdb_assert (completion_name !=3D 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); } =20 /* Complete possible window names for winheight command. TEXT is the @@ -432,7 +442,7 @@ winheight_completer (struct cmd_list_element *ignore, if (word !=3D text) return; =20 - window_name_completer (tracker, 0, text, word); + window_name_completer (tracker, false, false, text, word); } =20 /* Update gdb's knowledge of the terminal size. */