+/* Complete possible window names to focus on. TEXT is the complete text
+ entered so far, WORD is the word currently being completed. */
+
+static VEC (char_ptr) *
+focus_completer (struct cmd_list_element *ignore,
+ const char *text, const char *word)
+{
+ VEC (const_char_ptr) *completion_name_vec = NULL;
+ VEC (char_ptr) *matches_vec;
+ int win_type;
+
+ for (win_type = SRC_WIN; win_type < MAX_MAJOR_WINDOWS; win_type++)
+ {
+ const char *completion_name = NULL;
+
+ /* We can't focus on an invisible window. */
+ if (tui_win_list[win_type] == NULL
+ || !tui_win_list[win_type]->generic.is_visible)
+ continue;
+
+ switch (win_type)
+ {
+ case SRC_WIN:
+ completion_name = "src";
+ break;
+ case DISASSEM_WIN:
+ completion_name = "asm";
+ break;
+ case DATA_WIN:
+ completion_name = "regs";
+ break;
+ case CMD_WIN:
+ completion_name = "cmd";
+ break;
+ default:
+ break;
+ }
+
+ if (completion_name != NULL)
+ VEC_safe_push (const_char_ptr, completion_name_vec, completion_name);
+ }
+
+ /* If no windows are considered visible then the TUI has not yet been
+ initialized. But still "focus src" and "focus cmd" will work because
+ invoking the focus command will entail initializing the TUI which sets the
+ default layout to SRC_COMMAND. */
+ if (VEC_length (const_char_ptr, completion_name_vec) == 0)
+ {
+ VEC_safe_push (const_char_ptr, completion_name_vec, "src");
+ VEC_safe_push (const_char_ptr, completion_name_vec, "cmd");
+ }
+
+ VEC_safe_push (const_char_ptr, completion_name_vec, "next");
+ VEC_safe_push (const_char_ptr, completion_name_vec, "prev");
+ VEC_safe_push (const_char_ptr, completion_name_vec, NULL);
+
+ matches_vec
+ = complete_on_enum (VEC_address (const_char_ptr, completion_name_vec),
+ text, word);
+
+ VEC_free (const_char_ptr, completion_name_vec);
+
+ return matches_vec;
+}
+