Introduce refresh_window method
authorTom Tromey <tom@tromey.com>
Sun, 16 Jun 2019 22:28:12 +0000 (16:28 -0600)
committerTom Tromey <tom@tromey.com>
Tue, 25 Jun 2019 13:48:38 +0000 (07:48 -0600)
This replaces tui_refresh_win with a new refresh_window method.  This
removes another spot that was checking the window's type.

gdb/ChangeLog
2019-06-25  Tom Tromey  <tom@tromey.com>

* tui/tui-winsource.c (tui_erase_source_content)
(tui_show_source_content, tui_show_exec_info_content)
(tui_erase_exec_info_content): Use refresh_window method.
* tui/tui-wingeneral.h (tui_refresh_win): Don't declare.
* tui/tui-wingeneral.c (tui_gen_win_info::refresh_window): Rename
from tui_refresh_win.
(tui_data_window::refresh_window): New method.
(tui_win_info::refresh, tui_source_window_base::refresh)
(tui_refresh_all): Use refresh_window method.
* tui/tui-stack.c (tui_show_locator_content): Call refresh_window
method.
* tui/tui-regs.c (tui_display_register): Call refresh_window
method.
* tui/tui-layout.c (show_source_disasm_command)
(show_source_or_disasm_and_command): Call refresh_window method.
* tui/tui-data.h (struct tui_gen_win_info)
(struct tui_data_window, struct tui_cmd_window) <refresh_window>:
New method.

gdb/ChangeLog
gdb/tui/tui-data.h
gdb/tui/tui-layout.c
gdb/tui/tui-regs.c
gdb/tui/tui-stack.c
gdb/tui/tui-wingeneral.c
gdb/tui/tui-wingeneral.h
gdb/tui/tui-winsource.c

index 41b7de392d5b8da6945d712d59c5088cb263d8ef..25c2d01adc513606ecde719dfca22360bb3a89a2 100644 (file)
@@ -1,3 +1,24 @@
+2019-06-25  Tom Tromey  <tom@tromey.com>
+
+       * tui/tui-winsource.c (tui_erase_source_content)
+       (tui_show_source_content, tui_show_exec_info_content)
+       (tui_erase_exec_info_content): Use refresh_window method.
+       * tui/tui-wingeneral.h (tui_refresh_win): Don't declare.
+       * tui/tui-wingeneral.c (tui_gen_win_info::refresh_window): Rename
+       from tui_refresh_win.
+       (tui_data_window::refresh_window): New method.
+       (tui_win_info::refresh, tui_source_window_base::refresh)
+       (tui_refresh_all): Use refresh_window method.
+       * tui/tui-stack.c (tui_show_locator_content): Call refresh_window
+       method.
+       * tui/tui-regs.c (tui_display_register): Call refresh_window
+       method.
+       * tui/tui-layout.c (show_source_disasm_command)
+       (show_source_or_disasm_and_command): Call refresh_window method.
+       * tui/tui-data.h (struct tui_gen_win_info)
+       (struct tui_data_window, struct tui_cmd_window) <refresh_window>:
+       New method.
+
 2019-06-25  Tom Tromey  <tom@tromey.com>
 
        * tui/tui.c (tui_rl_other_window, tui_enable)
index 08d388fb8c1c35fa2c5436771608ed3f0ab00d36..8f77c9d4e07b09cfb9ed71ff5901c9ecd8c73f29 100644 (file)
@@ -48,6 +48,9 @@ struct tui_gen_win_info
   {
   }
 
+  /* Call to refresh this window.  */
+  virtual void refresh_window ();
+
   /* Window handle.  */
   WINDOW *handle = nullptr;
   /* Type of window.  */
@@ -418,6 +421,8 @@ struct tui_data_window : public tui_win_info
 
   void set_new_height (int height) override;
 
+  void refresh_window () override;
+
   /* Start of data display content.  */
   tui_win_content data_content = NULL;
   int data_content_count = 0;
@@ -456,6 +461,10 @@ struct tui_cmd_window : public tui_win_info
 
   int max_height () const override;
 
+  void refresh_window () override
+  {
+  }
+
   int start_line = 0;
 
 protected:
index 9685d7fc4e5f824c989857892206cb6248c4140e..d9e1617f19a7692a4da8ef16003a073fe887b687 100644 (file)
@@ -701,7 +701,7 @@ show_source_disasm_command (void)
          TUI_CMD_WIN->can_highlight = false;
          tui_make_visible (TUI_CMD_WIN);
        }
-      tui_refresh_win (TUI_CMD_WIN);
+      TUI_CMD_WIN->refresh_window ();
       tui_set_current_layout_to (SRC_DISASSEM_COMMAND);
     }
 }
@@ -956,7 +956,7 @@ show_source_or_disasm_and_command (enum tui_layout_type layout_type)
        {
          tui_win_list[CMD_WIN] = make_command_window (cmd_height,
                                                       src_height);
-         tui_refresh_win (TUI_CMD_WIN);
+         TUI_CMD_WIN->refresh_window ();
        }
       else
        {
index cfb735c81d5071ce367c9d45cb6278be655a8b2d..c748d513fc34309d80e63b847a8c807057c1356b 100644 (file)
@@ -534,7 +534,7 @@ tui_display_register (struct tui_data_element *data,
           to code that causes the compiler to generate an unused-value
           warning.  */
        (void) wstandend (win_info->handle);
-      tui_refresh_win (win_info);
+      win_info->refresh_window ();
     }
 }
 
index a38971542eb473d2a7a8ccc0cd3750dd970af71a..efa24453b6528a06b5a2dab4c15addd5b02963b1 100644 (file)
@@ -267,7 +267,7 @@ tui_show_locator_content (void)
       waddstr (locator->handle, string);
       wclrtoeol (locator->handle);
       (void) wstandend (locator->handle);
-      tui_refresh_win (locator);
+      locator->refresh_window ();
       wmove (locator->handle, 0, 0);
       xfree (string);
       locator->content_in_use = TRUE;
index 06d7ad5a030b881d9cf67fc06eaa03c5b9ff1763..f1089a9f38a09f09ffdc65aea282784f68f7c312 100644 (file)
 ** PUBLIC FUNCTIONS
 ***********************/
 
-/* Refresh the window.  */
+/* See tui-data.h.  */
+
 void
-tui_refresh_win (struct tui_gen_win_info *win_info)
+tui_gen_win_info::refresh_window ()
 {
-  if (win_info->type == DATA_WIN && win_info->content_size > 0)
-    {
-      int i;
+  if (handle != NULL)
+    wrefresh (handle);
+}
 
-      for (i = 0; (i < win_info->content_size); i++)
+/* See tui-data.h.  */
+
+void
+tui_data_window::refresh_window ()
+{
+  if (content_size > 0)
+    {
+      for (int i = 0; i < content_size; i++)
        {
          struct tui_gen_win_info *data_item_win_ptr;
 
-         data_item_win_ptr = win_info->content[i]->which_element.data_window;
+         data_item_win_ptr = content[i]->which_element.data_window;
          if (data_item_win_ptr != NULL
              && data_item_win_ptr->handle != NULL)
            wrefresh (data_item_win_ptr->handle);
        }
     }
-  else if (win_info->type == CMD_WIN)
-    {
-      /* Do nothing.  */
-    }
   else
-    {
-      if (win_info->handle != NULL)
-       wrefresh (win_info->handle);
-    }
-
-  return;
+    tui_gen_win_info::refresh_window ();
 }
 
-
 /* Function to delete the curses window, checking for NULL.  */
 void
 tui_delete_win (WINDOW *window)
@@ -260,7 +258,7 @@ void
 tui_win_info::refresh ()
 {
   touchwin (handle);
-  tui_refresh_win (this);
+  refresh_window ();
 }
 
 /* See tui-data.h.  */
@@ -269,7 +267,7 @@ void
 tui_source_window_base::refresh ()
 {
   touchwin (execution_info->handle);
-  tui_refresh_win (execution_info);
+  execution_info->refresh_window ();
   tui_win_info::refresh ();
 }
 
@@ -289,7 +287,7 @@ tui_refresh_all (struct tui_win_info **list)
   if (locator->is_visible)
     {
       touchwin (locator->handle);
-      tui_refresh_win (locator);
+      locator->refresh_window ();
     }
 }
 
index 73b10d2131196709ad2925563dcaffebf02b275e..15e61c94166d284450eba1211397e3860fe6411f 100644 (file)
@@ -39,6 +39,5 @@ extern void tui_highlight_win (struct tui_win_info *);
 extern void tui_check_and_display_highlight_if_needed (struct tui_win_info *);
 extern void tui_refresh_all (struct tui_win_info **);
 extern void tui_delete_win (WINDOW *window);
-extern void tui_refresh_win (struct tui_gen_win_info *);
 
 #endif /* TUI_TUI_WINGENERAL_H */
index f63526bb446850228a4375bbba5e56637fcf7904..254c7e00dcb3392c87db89af53d06c725385fbfd 100644 (file)
@@ -260,7 +260,7 @@ tui_erase_source_content (struct tui_win_info *win_info,
 
          tui_set_source_content_nil (win_info, no_src_str);
        }
-      tui_refresh_win (win_info);
+      win_info->refresh_window ();
     }
 }
 
@@ -305,7 +305,7 @@ tui_show_source_content (struct tui_win_info *win_info)
     tui_erase_source_content (win_info, TRUE);
 
   tui_check_and_display_highlight_if_needed (win_info);
-  tui_refresh_win (win_info);
+  win_info->refresh_window ();
   win_info->content_in_use = TRUE;
 }
 
@@ -550,14 +550,14 @@ tui_show_exec_info_content (struct tui_win_info *win_info)
   int cur_line;
 
   werase (exec_info->handle);
-  tui_refresh_win (exec_info);
+  exec_info->refresh_window ();
   for (cur_line = 1; (cur_line <= exec_info->content_size); cur_line++)
     mvwaddstr (exec_info->handle,
               cur_line,
               0,
               (char *) exec_info->content[cur_line - 1]
                          ->which_element.simple_string);
-  tui_refresh_win (exec_info);
+  exec_info->refresh_window ();
   exec_info->content_in_use = TRUE;
 }
 
@@ -569,7 +569,7 @@ tui_erase_exec_info_content (struct tui_win_info *win_info)
   struct tui_gen_win_info *exec_info = base->execution_info;
 
   werase (exec_info->handle);
-  tui_refresh_win (exec_info);
+  exec_info->refresh_window ();
 }
 
 void