Simplify TUI boxing
[deliverable/binutils-gdb.git] / gdb / tui / tui-layout.c
index 3ee3354b2ff4625ab10cab376c54952f6207382c..69b929d37b28000c0cf1ec73dce6911735e4ad3d 100644 (file)
@@ -83,34 +83,32 @@ show_layout (enum tui_layout_type layout)
       /* First make the current layout be invisible.  */
       tui_make_all_invisible ();
       tui_locator_win_info_ptr ()->make_visible (false);
-      if (layout == SRC_DATA_COMMAND 
-         || layout == DISASSEM_DATA_COMMAND)
+      switch (layout)
        {
+       case SRC_DATA_COMMAND:
+       case DISASSEM_DATA_COMMAND:
          show_data (layout);
          tui_refresh_all ();
+         break;
+         /* 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;
        }
-      else
-       {
-         switch (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 ();
     }
 }
 
@@ -258,7 +256,7 @@ tui_add_win_to_layout (enum tui_win_type type)
 /* Answer the height of a window.  If it hasn't been created yet,
    answer what the height of a window would be based upon its type and
    the layout.  */
-int
+static int
 tui_default_win_height (enum tui_win_type type, 
                        enum tui_layout_type layout)
 {
@@ -500,59 +498,56 @@ show_disasm_command (void)
 static void
 show_source_disasm_command (void)
 {
-  if (tui_current_layout () != SRC_DISASSEM_COMMAND)
-    {
-      int cmd_height, src_height, asm_height;
+  int cmd_height, src_height, asm_height;
 
-      if (TUI_CMD_WIN != NULL)
-       cmd_height = TUI_CMD_WIN->height;
-      else
-       cmd_height = tui_term_height () / 3;
+  if (TUI_CMD_WIN != NULL)
+    cmd_height = TUI_CMD_WIN->height;
+  else
+    cmd_height = tui_term_height () / 3;
 
-      src_height = (tui_term_height () - cmd_height) / 2;
-      asm_height = tui_term_height () - (src_height + cmd_height);
+  src_height = (tui_term_height () - cmd_height) / 2;
+  asm_height = tui_term_height () - (src_height + cmd_height);
 
-      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->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);
-      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 */ ,
+  if (TUI_SRC_WIN == NULL)
+    tui_win_list[SRC_WIN] = new tui_source_window ();
+  TUI_SRC_WIN->reset (src_height,
                      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);
-
-      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);
-      current_layout = SRC_DISASSEM_COMMAND;
-    }
+                     0);
+  TUI_SRC_WIN->make_visible (true);
+  TUI_SRC_WIN->m_has_locator = false;
+
+  struct tui_locator_window *locator = tui_locator_win_info_ptr ();
+  gdb_assert (locator != nullptr);
+
+  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_SRC_WIN->m_has_locator = false;
+  TUI_DISASM_WIN->m_has_locator = true;
+  locator->make_visible (true);
+  tui_show_locator_content ();
+  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);
+  current_layout = SRC_DISASSEM_COMMAND;
 }
 
 
@@ -603,6 +598,7 @@ show_data (enum tui_layout_type new_layout)
   locator->make_visible (true);
   tui_show_locator_content ();
   tui_add_to_source_windows (base);
+  TUI_CMD_WIN->make_visible (true);
   current_layout = new_layout;
 }
 
@@ -630,57 +626,54 @@ tui_gen_win_info::reset (int height_, int width_,
 static void
 show_source_or_disasm_and_command (enum tui_layout_type layout_type)
 {
-  if (tui_current_layout () != layout_type)
+  struct tui_source_window_base *win_info;
+  int src_height, cmd_height;
+  struct tui_locator_window *locator = tui_locator_win_info_ptr ();
+  gdb_assert (locator != nullptr);
+
+  if (TUI_CMD_WIN != NULL)
+    cmd_height = TUI_CMD_WIN->height;
+  else
+    cmd_height = tui_term_height () / 3;
+  src_height = tui_term_height () - cmd_height;
+
+  if (layout_type == SRC_COMMAND)
+    {
+      if (tui_win_list[SRC_WIN] == nullptr)
+       tui_win_list[SRC_WIN] = new tui_source_window ();
+      win_info = TUI_SRC_WIN;
+    }
+  else
     {
-      struct tui_source_window_base *win_info;
-      int src_height, cmd_height;
-      struct tui_locator_window *locator = tui_locator_win_info_ptr ();
-      gdb_assert (locator != nullptr);
+      if (tui_win_list[DISASSEM_WIN] == nullptr)
+       tui_win_list[DISASSEM_WIN] = new tui_disasm_window ();
+      win_info = TUI_DISASM_WIN;
+    }
 
-      if (TUI_CMD_WIN != NULL)
-       cmd_height = TUI_CMD_WIN->height;
-      else
-       cmd_height = tui_term_height () / 3;
-      src_height = tui_term_height () - cmd_height;
+  locator->reset (2 /* 1 */ ,
+                 tui_term_width (),
+                 0,
+                 src_height - 1);
+  win_info->reset (src_height - 1,
+                  tui_term_width (),
+                  0,
+                  0);
+  win_info->make_visible (true);
 
-      if (layout_type == SRC_COMMAND)
-       {
-         if (tui_win_list[SRC_WIN] == nullptr)
-           tui_win_list[SRC_WIN] = new tui_source_window ();
-         win_info = TUI_SRC_WIN;
-       }
-      else
-       {
-         if (tui_win_list[DISASSEM_WIN] == nullptr)
-           tui_win_list[DISASSEM_WIN] = new tui_disasm_window ();
-         win_info = TUI_DISASM_WIN;
-       }
 
-      locator->reset (2 /* 1 */ ,
+  win_info->m_has_locator = true;
+  locator->make_visible (true);
+  tui_show_locator_content ();
+  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 - 1);
-      win_info->reset (src_height - 1,
-                      tui_term_width (),
-                      0,
-                      0);
-      win_info->make_visible (true);
-
-
-      win_info->m_has_locator = true;
-      locator->make_visible (true);
-      tui_show_locator_content ();
-      tui_show_source_content (win_info);
-
-      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);
-      current_layout = layout_type;
-    }
+                     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);
+  current_layout = layout_type;
 }
This page took 0.026153 seconds and 4 git commands to generate.