mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-23 03:29:47 +08:00
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.
This commit is contained in:
@ -15,8 +15,9 @@
|
|||||||
|
|
||||||
require allow_tui_tests
|
require allow_tui_tests
|
||||||
|
|
||||||
gdb_exit
|
tuiterm_env
|
||||||
gdb_start
|
|
||||||
|
clean_restart
|
||||||
|
|
||||||
if {[target_info exists gdb,nointerrupts]} {
|
if {[target_info exists gdb,nointerrupts]} {
|
||||||
return
|
return
|
||||||
@ -56,3 +57,16 @@ with_test_prefix "completion of layout names" {
|
|||||||
with_test_prefix "completion of focus command" {
|
with_test_prefix "completion of focus command" {
|
||||||
test_tab_completion "focus" "cmd *next *prev *src *"
|
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"
|
||||||
|
@ -362,13 +362,19 @@ show_tui_resize_message (struct ui_file *file, int from_tty,
|
|||||||
|
|
||||||
|
|
||||||
/* Generic window name completion function. Complete window name pointed
|
/* Generic window name completion function. Complete window name pointed
|
||||||
to by TEXT and WORD. If INCLUDE_NEXT_PREV_P is true then the special
|
to by TEXT and WORD.
|
||||||
window names 'next' and 'prev' will also be considered as possible
|
|
||||||
completions of the window name. */
|
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
|
static void
|
||||||
window_name_completer (completion_tracker &tracker,
|
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)
|
const char *text, const char *word)
|
||||||
{
|
{
|
||||||
std::vector<const char *> completion_name_vec;
|
std::vector<const char *> completion_name_vec;
|
||||||
@ -377,10 +383,14 @@ window_name_completer (completion_tracker &tracker,
|
|||||||
{
|
{
|
||||||
const char *completion_name = NULL;
|
const char *completion_name = NULL;
|
||||||
|
|
||||||
/* We can't focus on an invisible window. */
|
/* Don't include an invisible window. */
|
||||||
if (!win_info->is_visible ())
|
if (!win_info->is_visible ())
|
||||||
continue;
|
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 ();
|
completion_name = win_info->name ();
|
||||||
gdb_assert (completion_name != NULL);
|
gdb_assert (completion_name != NULL);
|
||||||
completion_name_vec.push_back (completion_name);
|
completion_name_vec.push_back (completion_name);
|
||||||
@ -415,7 +425,7 @@ focus_completer (struct cmd_list_element *ignore,
|
|||||||
completion_tracker &tracker,
|
completion_tracker &tracker,
|
||||||
const char *text, const char *word)
|
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
|
/* Complete possible window names for winheight command. TEXT is the
|
||||||
@ -432,7 +442,7 @@ winheight_completer (struct cmd_list_element *ignore,
|
|||||||
if (word != text)
|
if (word != text)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
window_name_completer (tracker, 0, text, word);
|
window_name_completer (tracker, false, false, text, word);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update gdb's knowledge of the terminal size. */
|
/* Update gdb's knowledge of the terminal size. */
|
||||||
|
Reference in New Issue
Block a user