]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Simplify register display
authorTom Tromey <tom@tromey.com>
Mon, 15 Jul 2019 21:28:56 +0000 (15:28 -0600)
committerTom Tromey <tom@tromey.com>
Fri, 30 Aug 2019 18:57:05 +0000 (12:57 -0600)
This patch starts with the observation that the code in
tui_data_window::display_registers_from can all be replaced with a
call to resize.  To make this work propertly, it also changes
tui_display_register to be the "rerender" method on
tui_data_item_window.

The refresh_window method is needed due to the use of nested windows
here.  The ncurses man page makes it sound like this is not very well
supported; and experience bears this out: negelecting the touchwin
call in this path will cause the register window to blank when
switching focus.

gdb/ChangeLog
2019-08-30  Tom Tromey  <tom@tromey.com>

* tui/tui-regs.h (struct tui_data_item_window) <rerender,
refresh_window>: Declare.
* tui/tui-regs.c (tui_data_window::display_registers_from): Call
resize.
(tui_data_item_window::rerender): Rename from
tui_display_register.
(tui_data_item_window::refresh_window): New method.
* tui/tui-layout.c (tui_gen_win_info::resize): Do nothing on
no-op.

gdb/ChangeLog
gdb/tui/tui-layout.c
gdb/tui/tui-regs.c
gdb/tui/tui-regs.h

index 2a2c08cae46df69ded50501f465982fabbf96734..388f5ebe9290eb16d01513239636a13626a7b796 100644 (file)
@@ -1,3 +1,15 @@
+2019-08-30  Tom Tromey  <tom@tromey.com>
+
+       * tui/tui-regs.h (struct tui_data_item_window) <rerender,
+       refresh_window>: Declare.
+       * tui/tui-regs.c (tui_data_window::display_registers_from): Call
+       resize.
+       (tui_data_item_window::rerender): Rename from
+       tui_display_register.
+       (tui_data_item_window::refresh_window): New method.
+       * tui/tui-layout.c (tui_gen_win_info::resize): Do nothing on
+       no-op.
+
 2019-08-30  Tom Tromey  <tom@tromey.com>
 
        * tui/tui-regs.h (struct tui_data_window) <regs_content,
index 387a4f51affeafa246d5acd90461cb20c9b35085..7ec704e52f077d266c61892eef474be09643679d 100644 (file)
@@ -580,6 +580,11 @@ void
 tui_gen_win_info::resize (int height_, int width_,
                          int origin_x_, int origin_y_)
 {
+  if (width == width_ && height == height_
+      && origin.x == origin_x_ && origin.y == origin_y_
+      && handle != nullptr)
+    return;
+
   width = width_;
   height = height_;
   if (height > 1)
index 98096e2cdc4881562ca845cc28fb4fd27c186ea8..f62ba065ebe0f544f6cb0b12910a7d04fd406fa3 100644 (file)
@@ -42,8 +42,6 @@
 
 #include "gdb_curses.h"
 
-static void tui_display_register (struct tui_data_item_window *data);
-
 /* Get the register from the frame and return a printable
    representation of it.  */
 
@@ -274,34 +272,9 @@ tui_data_window::display_registers_from (int start_element_no)
           j < regs_column_count && i < regs_content.size ();
           j++)
        {
-         struct tui_data_item_window *data_item_win;
-
          /* Create the window if necessary.  */
-         data_item_win = &regs_content[i];
-         if (data_item_win->handle != NULL
-             && (data_item_win->height != 1
-                 || data_item_win->width != item_win_width
-                 || data_item_win->origin.x != (item_win_width * j) + 1
-                 || data_item_win->origin.y != cur_y))
-           {
-             tui_delete_win (data_item_win->handle);
-             data_item_win->handle = 0;
-           }
-                  
-         if (data_item_win->handle == NULL)
-           {
-             data_item_win->height = 1;
-             data_item_win->width = item_win_width;
-             data_item_win->origin.x = (item_win_width * j) + 1;
-             data_item_win->origin.y = cur_y;
-             data_item_win->make_visible (true);
-             scrollok (data_item_win->handle, FALSE);
-           }
-         touchwin (data_item_win->handle);
-
-         /* Get the printable representation of the register
-            and display it.  */
-         tui_display_register (data_item_win);
+         regs_content[i].resize (1, item_win_width,
+                                 (item_win_width * j) + 1, cur_y);
          i++;          /* Next register.  */
        }
       cur_y++;         /* Next row.  */
@@ -508,43 +481,54 @@ tui_data_window::check_register_values (struct frame_info *frame)
                            &data_item_win.highlight);
 
          if (data_item_win.highlight || was_hilighted)
-           tui_display_register (&data_item_win);
+           data_item_win.rerender ();
        }
     }
 }
 
 /* Display a register in a window.  If hilite is TRUE, then the value
    will be displayed in reverse video.  */
-static void
-tui_display_register (struct tui_data_item_window *data)
+void
+tui_data_item_window::rerender ()
 {
-  if (data->handle != NULL)
-    {
-      int i;
-
-      if (data->highlight)
-       /* We ignore the return value, casting it to void in order to avoid
-          a compiler warning.  The warning itself was introduced by a patch
-          to ncurses 5.7 dated 2009-08-29, changing this macro to expand
-          to code that causes the compiler to generate an unused-value
-          warning.  */
-       (void) wstandout (data->handle);
+  int i;
+
+  scrollok (handle, FALSE);
+  if (highlight)
+    /* We ignore the return value, casting it to void in order to avoid
+       a compiler warning.  The warning itself was introduced by a patch
+       to ncurses 5.7 dated 2009-08-29, changing this macro to expand
+       to code that causes the compiler to generate an unused-value
+       warning.  */
+    (void) wstandout (handle);
       
-      wmove (data->handle, 0, 0);
-      for (i = 1; i < data->width; i++)
-        waddch (data->handle, ' ');
-      wmove (data->handle, 0, 0);
-      if (data->content)
-        waddstr (data->handle, data->content.get ());
-
-      if (data->highlight)
-       /* We ignore the return value, casting it to void in order to avoid
-          a compiler warning.  The warning itself was introduced by a patch
-          to ncurses 5.7 dated 2009-08-29, changing this macro to expand
-          to code that causes the compiler to generate an unused-value
-          warning.  */
-       (void) wstandend (data->handle);
-      data->refresh_window ();
+  wmove (handle, 0, 0);
+  for (i = 1; i < width; i++)
+    waddch (handle, ' ');
+  wmove (handle, 0, 0);
+  if (content)
+    waddstr (handle, content.get ());
+
+  if (highlight)
+    /* We ignore the return value, casting it to void in order to avoid
+       a compiler warning.  The warning itself was introduced by a patch
+       to ncurses 5.7 dated 2009-08-29, changing this macro to expand
+       to code that causes the compiler to generate an unused-value
+       warning.  */
+    (void) wstandend (handle);
+  refresh_window ();
+}
+
+void
+tui_data_item_window::refresh_window ()
+{
+  if (handle != nullptr)
+    {
+      /* This seems to be needed because the data items are nested
+        windows, which according to the ncurses man pages aren't well
+        supported.  */
+      touchwin (handle);
+      wrefresh (handle);
     }
 }
 
index 2606c39f5a190bcce744a54f13ca940cee3988a5..1f9fa73f1cc5be0f3be2da1a416e7d08cd7120e2 100644 (file)
@@ -37,6 +37,10 @@ struct tui_data_item_window : public tui_gen_win_info
 
   tui_data_item_window (tui_data_item_window &&) = default;
 
+  void rerender () override;
+
+  void refresh_window () override;
+
   const char *name = nullptr;
   /* The register number, or data display number.  */
   int item_no = -1;