static void tui_set_tab_width_command (char *, int);
static void tui_refresh_all_command (char *, int);
static void tui_set_win_height_command (char *, int);
-static void tui_xdb_set_win_height_command (char *, int);
static void tui_all_windows_info (char *, int);
static void tui_set_focus_command (char *, int);
static void tui_scroll_forward_command (char *, int);
tui_rehighlight_all ();
}
+/* 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;
+}
+
/* Function to initialize gdb commands, for tui window
manipulation. */
{
static struct cmd_list_element *tui_setlist;
static struct cmd_list_element *tui_showlist;
+ struct cmd_list_element *focus_cmd;
/* Define the classes of commands.
They will appear in the help list in the reverse of this order. */
add_com ("refresh", class_tui, tui_refresh_all_command,
_("Refresh the terminal display.\n"));
- if (xdb_commands)
- add_com_alias ("U", "refresh", class_tui, 0);
add_com ("tabset", class_tui, tui_set_tab_width_command, _("\
Set the width (in characters) of tab stops.\n\
Usage: tabset <n>\n"));
add_com_alias ("wh", "winheight", class_tui, 0);
add_info ("win", tui_all_windows_info,
_("List of all displayed windows.\n"));
- add_com ("focus", class_tui, tui_set_focus_command, _("\
+ focus_cmd = add_com ("focus", class_tui, tui_set_focus_command, _("\
Set focus to named window or next/prev window.\n\
Usage: focus {<win> | next | prev}\n\
Valid Window names are:\n\
regs : the register display\n\
cmd : the command window\n"));
add_com_alias ("fs", "focus", class_tui, 0);
+ set_cmd_completer (focus_cmd, focus_completer);
add_com ("+", class_tui, tui_scroll_forward_command, _("\
Scroll window forward.\n\
Usage: + [win] [n]\n"));
add_com (">", class_tui, tui_scroll_right_command, _("\
Scroll window text to the right.\n\
Usage: > [win] [n]\n"));
- if (xdb_commands)
- add_com ("w", class_xdb, tui_xdb_set_win_height_command, _("\
-XDB compatibility command for setting the height of a command window.\n\
-Usage: w <#lines>\n"));
/* Define the tui control variables. */
add_setshow_enum_cmd ("border-kind", no_class, tui_border_kind_enums,
void
tui_update_gdb_sizes (void)
{
- char cmd[50];
-
- /* Set to TUI command window dimension or use readline values. */
- xsnprintf (cmd, sizeof (cmd), "set width %d",
- tui_active ? TUI_CMD_WIN->generic.width : tui_term_width());
- execute_command (cmd, 0);
- xsnprintf (cmd, sizeof (cmd), "set height %d",
- tui_active ? TUI_CMD_WIN->generic.height : tui_term_height());
- execute_command (cmd, 0);
+ int width, height;
+
+ if (tui_active)
+ {
+ width = TUI_CMD_WIN->generic.width;
+ height = TUI_CMD_WIN->generic.height;
+ }
+ else
+ {
+ width = tui_term_width ();
+ height = tui_term_height ();
+ }
+
+ set_screen_width_and_height (width, height);
}
void
tui_refresh_all_win (void)
{
- enum tui_win_type type;
+ int type;
clearok (curscr, TRUE);
tui_refresh_all (tui_win_list);
void
tui_rehighlight_all (void)
{
- enum tui_win_type type;
+ int type;
for (type = SRC_WIN; type < MAX_MAJOR_WINDOWS; type++)
tui_check_and_display_highlight_if_needed (tui_win_list[type]);
struct tui_win_info *first_win;
struct tui_win_info *second_win;
struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
- enum tui_win_type win_type;
+ int win_type;
int new_height, split_diff, cmd_split_diff, num_wins_displayed = 2;
#ifdef HAVE_RESIZE_TERM
static void
tui_sigwinch_handler (int signal)
{
- /* Set win_resized to TRUE and asynchronously invoke our resize callback. If
- the callback is invoked while TUI is active then it ought to successfully
- resize the screen, resetting win_resized to FALSE. Of course, if the
- callback is invoked while TUI is inactive then it will do nothing; in that
- case, win_resized will remain TRUE until we get a chance to synchronously
- resize the screen from tui_enable(). */
mark_async_signal_handler (tui_sigwinch_token);
tui_set_win_resized_to (TRUE);
}
static void
tui_async_resize_screen (gdb_client_data arg)
{
+ rl_resize_terminal ();
+
if (!tui_active)
- return;
+ {
+ int screen_height, screen_width;
- tui_resize_all ();
- tui_refresh_all_win ();
- tui_update_gdb_sizes ();
- tui_set_win_resized_to (FALSE);
- tui_redisplay_readline ();
+ rl_get_screen_size (&screen_height, &screen_width);
+ set_screen_width_and_height (screen_width, screen_height);
+
+ /* win_resized is left set so that the next call to tui_enable()
+ resizes the TUI windows. */
+ }
+ else
+ {
+ tui_set_win_resized_to (FALSE);
+ tui_resize_all ();
+ tui_refresh_all_win ();
+ tui_update_gdb_sizes ();
+ tui_redisplay_readline ();
+ }
}
#endif
tui_refresh_data_win ();
xfree (buf_ptr);
printf_filtered (_("Focus set to %s window.\n"),
- tui_win_name ((struct tui_gen_win_info *)
- tui_win_with_focus ()));
+ tui_win_name (&tui_win_with_focus ()->generic));
}
else
warning (_("Incorrect Number of Arguments.\n%s"), FOCUS_USAGE);
static void
tui_all_windows_info (char *arg, int from_tty)
{
- enum tui_win_type type;
+ int type;
struct tui_win_info *win_with_focus = tui_win_with_focus ();
for (type = SRC_WIN; (type < MAX_MAJOR_WINDOWS); type++)
tui_set_win_height (arg, from_tty);
}
-
-/* XDB Compatibility command for setting the window height. This will
- increase or decrease the command window by the specified
- amount. */
-static void
-tui_xdb_set_win_height (char *arg, int from_tty)
-{
- /* Make sure the curses mode is enabled. */
- tui_enable ();
- if (arg != (char *) NULL)
- {
- int input_no = atoi (arg);
-
- if (input_no > 0)
- { /* Add 1 for the locator. */
- int new_height = tui_term_height () - (input_no + 1);
-
- if (!new_height_ok (tui_win_list[CMD_WIN], new_height)
- || tui_adjust_win_heights (tui_win_list[CMD_WIN],
- new_height) == TUI_FAILURE)
- warning (_("Invalid window height specified.\n%s"),
- XDBWIN_HEIGHT_USAGE);
- }
- else
- warning (_("Invalid window height specified.\n%s"),
- XDBWIN_HEIGHT_USAGE);
- }
- else
- warning (_("Invalid window height specified.\n%s"), XDBWIN_HEIGHT_USAGE);
-}
-
-/* Set the height of the specified window, with va_list. */
-static void
-tui_xdb_set_win_height_command (char *arg, int from_tty)
-{
- tui_xdb_set_win_height (arg, from_tty);
-}
-
-
/* Function to adjust all window heights around the primary. */
static enum tui_status
tui_adjust_win_heights (struct tui_win_info *primary_win_info,