Make TUI resizing tests more robust
[deliverable/binutils-gdb.git] / gdb / tui / tui-win.c
index 37e22c550f9b4a1be91dc2bbf19e1d90491ff9b5..feeee34c0831d76c82a216d0da1251b200124692 100644 (file)
@@ -33,6 +33,7 @@
 #include "top.h"
 #include "source.h"
 #include "event-loop.h"
+#include "gdbcmd.h"
 
 #include "tui/tui.h"
 #include "tui/tui-io.h"
@@ -340,6 +341,22 @@ tui_set_var_cmd (const char *null_args,
     tui_rehighlight_all ();
 }
 
+\f
+
+/* True if TUI resizes should print a message.  This is used by the
+   test suite.  */
+
+static bool resize_message;
+
+static void
+show_tui_resize_message (struct ui_file *file, int from_tty,
+                        struct cmd_list_element *c, const char *value)
+{
+  fprintf_filtered (file, _("TUI resize messaging is %s.\n"), value);
+}
+
+\f
+
 /* 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
@@ -529,7 +546,7 @@ tui_resize_all (void)
 #endif      
       /* Turn keypad off while we resize.  */
       if (win_with_focus != TUI_CMD_WIN)
-       keypad (TUI_CMD_WIN->handle, FALSE);
+       keypad (TUI_CMD_WIN->handle.get (), FALSE);
       tui_update_gdb_sizes ();
       tui_set_term_height_to (screenheight);
       tui_set_term_width_to (screenwidth);
@@ -639,7 +656,7 @@ tui_resize_all (void)
       /* Turn keypad back on, unless focus is in the command
         window.  */
       if (win_with_focus != TUI_CMD_WIN)
-       keypad (TUI_CMD_WIN->handle, TRUE);
+       keypad (TUI_CMD_WIN->handle.get (), TRUE);
     }
 }
 
@@ -677,6 +694,13 @@ tui_async_resize_screen (gdb_client_data arg)
       tui_resize_all ();
       tui_refresh_all_win ();
       tui_update_gdb_sizes ();
+      if (resize_message)
+       {
+         static int count;
+         printf_unfiltered ("@@ resize done %d, size = %dx%d\n", count,
+                            tui_term_width (), tui_term_height ());
+         ++count;
+       }
       tui_redisplay_readline ();
     }
 }
@@ -791,7 +815,7 @@ tui_set_focus_command (const char *arg, int from_tty)
        error (_("Window \"%s\" is not visible"), arg);
 
       tui_set_win_focus_to (win_info);
-      keypad (TUI_CMD_WIN->handle, (win_info != TUI_CMD_WIN));
+      keypad (TUI_CMD_WIN->handle.get (), win_info != TUI_CMD_WIN);
       printf_filtered (_("Focus set to %s window.\n"),
                       tui_win_with_focus ()->name ());
     }
@@ -1050,7 +1074,7 @@ tui_adjust_win_heights (struct tui_win_info *primary_win_info,
                  second_win = *(tui_source_windows ().begin ());
                }
              if (primary_win_info == TUI_CMD_WIN)
-               { /* Split the change in height accross the 1st & 2nd
+               { /* Split the change in height across the 1st & 2nd
                     windows, adjusting them as well.  */
                  /* Subtract the locator.  */
                  int first_split_diff = diff / 2;
@@ -1072,7 +1096,7 @@ tui_adjust_win_heights (struct tui_win_info *primary_win_info,
                            second_split_diff++;
                        }
                    }
-                 /* Make sure that the minimum hieghts are
+                 /* Make sure that the minimum heights are
                     honored.  */
                  while ((first_win->height + first_split_diff) < 3)
                    {
@@ -1434,4 +1458,14 @@ Show the tab witdh, in characters, for the TUI."), _("\
 This variable controls how many spaces are used to display a tab character."),
                             tui_set_tab_width, tui_show_tab_width,
                             &tui_setlist, &tui_showlist);
+
+  add_setshow_boolean_cmd ("tui-resize-message", class_maintenance,
+                          &resize_message, _("\
+Set TUI resize messaging."), _("\
+Show TUI resize messaging."), _("\
+When enabled GDB will print a message when the terminal is resized."),
+                          nullptr,
+                          show_tui_resize_message,
+                          &maintenance_set_cmdlist,
+                          &maintenance_show_cmdlist);
 }
This page took 0.027822 seconds and 4 git commands to generate.