]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gdb/tui/tui-layout.c
TUI window resize should not need invisibility
[thirdparty/binutils-gdb.git] / gdb / tui / tui-layout.c
index f4f834dc83e2274fa5abb5ea049c963550d4ff78..e0e804bac2abe4524f282a2b7b2d4138b362d921 100644 (file)
@@ -76,13 +76,7 @@ show_layout (enum tui_layout_type layout)
 
   if (layout != cur_layout)
     {
-      /* Since the new layout may cause changes in window size, we
-         should free the content and reallocate on next display of
-         source/asm.  */
-      tui_clear_source_windows ();
-      /* First make the current layout be invisible.  */
       tui_make_all_invisible ();
-      tui_locator_win_info_ptr ()->make_visible (false);
       switch (layout)
        {
        case SRC_DATA_COMMAND:
@@ -93,20 +87,18 @@ show_layout (enum tui_layout_type layout)
          /* Now show the new layout.  */
        case SRC_COMMAND:
          show_source_command ();
-         tui_add_to_source_windows (TUI_SRC_WIN);
          break;
        case DISASSEM_COMMAND:
          show_disasm_command ();
-         tui_add_to_source_windows (TUI_DISASM_WIN);
          break;
        case SRC_DISASSEM_COMMAND:
          show_source_disasm_command ();
-         tui_add_to_source_windows (TUI_SRC_WIN);
-         tui_add_to_source_windows (TUI_DISASM_WIN);
          break;
        default:
          break;
        }
+
+      tui_delete_invisible_windows ();
     }
 }
 
@@ -302,7 +294,7 @@ tui_default_win_viewport_height (enum tui_win_type type,
 
   h = tui_default_win_height (type, layout);
 
-  if (tui_win_list[type] == TUI_CMD_WIN)
+  if (type == CMD_WIN)
     h -= 1;
   else
     h -= 2;
@@ -508,43 +500,37 @@ show_source_disasm_command (void)
 
   if (TUI_SRC_WIN == NULL)
     tui_win_list[SRC_WIN] = new tui_source_window ();
-  TUI_SRC_WIN->reset (src_height,
-                     tui_term_width (),
-                     0,
-                     0);
-  TUI_SRC_WIN->make_visible (true);
+  TUI_SRC_WIN->resize (src_height,
+                      tui_term_width (),
+                      0,
+                      0);
   TUI_SRC_WIN->m_has_locator = false;
 
   struct tui_locator_window *locator = tui_locator_win_info_ptr ();
   gdb_assert (locator != nullptr);
 
-  tui_show_source_content (TUI_SRC_WIN);
+  TUI_SRC_WIN->show_source_content ();
   if (TUI_DISASM_WIN == NULL)
     tui_win_list[DISASSEM_WIN] = new tui_disasm_window ();
-  TUI_DISASM_WIN->reset (asm_height,
-                        tui_term_width (),
-                        0,
-                        src_height - 1);
-  TUI_DISASM_WIN->make_visible (true);
-  locator->reset (2 /* 1 */ ,
-                 tui_term_width (),
-                 0,
-                 (src_height + asm_height) - 1);
+  TUI_DISASM_WIN->resize (asm_height,
+                         tui_term_width (),
+                         0,
+                         src_height - 1);
+  locator->resize (2 /* 1 */ ,
+                  tui_term_width (),
+                  0,
+                  (src_height + asm_height) - 1);
   TUI_SRC_WIN->m_has_locator = false;
   TUI_DISASM_WIN->m_has_locator = true;
-  locator->make_visible (true);
   tui_show_locator_content ();
-  tui_show_source_content (TUI_DISASM_WIN);
+  TUI_DISASM_WIN->show_source_content ();
 
   if (TUI_CMD_WIN == NULL)
     tui_win_list[CMD_WIN] = new tui_cmd_window ();
-  TUI_CMD_WIN->reset (cmd_height,
-                     tui_term_width (),
-                     0,
-                     tui_term_height () - cmd_height);
-  /* FIXME tui_cmd_window won't recreate the handle on
-     make_visible, so we need this instead.  */
-  tui_make_window (TUI_CMD_WIN, DONT_BOX_WINDOW);
+  TUI_CMD_WIN->resize (cmd_height,
+                      tui_term_width (),
+                      0,
+                      tui_term_height () - cmd_height);
   current_layout = SRC_DISASSEM_COMMAND;
 }
 
@@ -565,8 +551,7 @@ show_data (enum tui_layout_type new_layout)
   src_height = total_height - data_height;
   if (tui_win_list[DATA_WIN] == nullptr)
     tui_win_list[DATA_WIN] = new tui_data_window ();
-  tui_win_list[DATA_WIN]->reset (data_height, tui_term_width (), 0, 0);
-  tui_win_list[DATA_WIN]->make_visible (true);
+  tui_win_list[DATA_WIN]->resize (data_height, tui_term_width (), 0, 0);
 
   if (new_layout == SRC_DATA_COMMAND)
     win_type = SRC_WIN;
@@ -583,40 +568,49 @@ show_data (enum tui_layout_type new_layout)
 
   tui_source_window_base *base
     = (tui_source_window_base *) tui_win_list[win_type];
-  tui_win_list[win_type]->reset (src_height,
-                                tui_term_width (),
-                                0,
-                                data_height - 1);
-  locator->reset (2 /* 1 */ ,
-                 tui_term_width (),
-                 0,
-                 total_height - 1);
-  base->make_visible (true);
+  tui_win_list[win_type]->resize (src_height,
+                                 tui_term_width (),
+                                 0,
+                                 data_height - 1);
+  locator->resize (2 /* 1 */ ,
+                  tui_term_width (),
+                  0,
+                  total_height - 1);
+  TUI_CMD_WIN->resize (TUI_CMD_WIN->height, tui_term_width (),
+                      0, total_height);
+
   base->m_has_locator = true;
-  locator->make_visible (true);
   tui_show_locator_content ();
-  tui_add_to_source_windows (base);
   current_layout = new_layout;
 }
 
 void
-tui_gen_win_info::reset (int height_, int width_,
-                        int origin_x_, int origin_y_)
+tui_gen_win_info::resize (int height_, int width_,
+                         int origin_x_, int origin_y_)
 {
-  int h = height_;
-
   width = width_;
-  height = h;
-  if (h > 1)
-    {
-      viewport_height = h - 1;
-      if (type != CMD_WIN)
-       viewport_height--;
-    }
+  height = height_;
+  if (height > 1)
+    viewport_height = height - 2;
   else
     viewport_height = 1;
   origin.x = origin_x_;
   origin.y = origin_y_;
+
+  if (handle != nullptr)
+    {
+#ifdef HAVE_WRESIZE
+      wresize (handle, height, width);
+      mvwin (handle, origin.y, origin.x);
+      wmove (handle, 0, 0);
+#else
+      tui_delete_win (handle);
+      handle = NULL;
+#endif
+    }
+
+  if (handle == nullptr)
+    tui_make_window (this);
 }
 
 /* Show the Source/Command or the Disassem layout.  */
@@ -647,30 +641,24 @@ show_source_or_disasm_and_command (enum tui_layout_type layout_type)
       win_info = TUI_DISASM_WIN;
     }
 
-  locator->reset (2 /* 1 */ ,
-                 tui_term_width (),
-                 0,
-                 src_height - 1);
-  win_info->reset (src_height - 1,
+  locator->resize (2 /* 1 */ ,
                   tui_term_width (),
                   0,
-                  0);
-  win_info->make_visible (true);
-
+                  src_height - 1);
+  win_info->resize (src_height - 1,
+                   tui_term_width (),
+                   0,
+                   0);
 
   win_info->m_has_locator = true;
-  locator->make_visible (true);
   tui_show_locator_content ();
-  tui_show_source_content (win_info);
+  win_info->show_source_content ();
 
   if (TUI_CMD_WIN == NULL)
     tui_win_list[CMD_WIN] = new tui_cmd_window ();
-  TUI_CMD_WIN->reset (cmd_height,
-                     tui_term_width (),
-                     0,
-                     src_height);
-  /* FIXME tui_cmd_window won't recreate the handle on
-     make_visible, so we need this instead.  */
-  tui_make_window (TUI_CMD_WIN, DONT_BOX_WINDOW);
+  TUI_CMD_WIN->resize (cmd_height,
+                      tui_term_width (),
+                      0,
+                      src_height);
   current_layout = layout_type;
 }