Introduce reset_locator function in tui-layout.c
authorTom Tromey <tom@tromey.com>
Sat, 29 Jun 2019 05:56:25 +0000 (23:56 -0600)
committerTom Tromey <tom@tromey.com>
Wed, 17 Jul 2019 18:19:13 +0000 (12:19 -0600)
init_and_make_win in tui-layout.c is now only called for the locator
-- earlier changes have made most of the cases here obsolete.  This
patch removes init_and_make_win and introduces a reset_locator
function.  Window creation is now much simpler to follow, because it
is no longer quite so dynamic.  (Though it will become even simpler in
coming patches.)

gdb/ChangeLog
2019-07-17  Tom Tromey  <tom@tromey.com>

* tui/tui-layout.c (show_source_disasm_command): Use
reset_locator.
(reset_locator): New function.
(init_and_make_win): Remove.
(show_source_or_disasm_and_command): Use reset_locator.

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

index 1c56652d8a9cb0301fce256bcf6aa17aa1cb03bb..76549e029a370ccb78c2ffba074d6ccd63433da3 100644 (file)
@@ -1,3 +1,11 @@
+2019-07-17  Tom Tromey  <tom@tromey.com>
+
+       * tui/tui-layout.c (show_source_disasm_command): Use
+       reset_locator.
+       (reset_locator): New function.
+       (init_and_make_win): Remove.
+       (show_source_or_disasm_and_command): Use reset_locator.
+
 2019-07-17  Tom Tromey  <tom@tromey.com>
 
        * tui/tui-winsource.c (tui_set_exec_info_content): Remove
index 23537b7f4969a9c8141767cabf9a879352526256..ab849a9813de7cb77781d4d60dc146d7b06fcfe1 100644 (file)
 ** Static Local Decls
 ********************************/
 static void show_layout (enum tui_layout_type);
-static tui_gen_win_info *init_and_make_win (tui_gen_win_info *,
-                                           enum tui_win_type,
-                                           int, int, int, int,
-                                           enum tui_box);
+static void reset_locator (tui_gen_win_info *,
+                          int, int, int, int);
 static void show_source_or_disasm_and_command (enum tui_layout_type);
 static struct tui_win_info *make_command_window (int, int);
 static struct tui_win_info *make_source_window (int, int);
@@ -614,13 +612,11 @@ show_source_disasm_command (void)
        {
          tui_win_list[DISASSEM_WIN]
            = make_disasm_window (asm_height, src_height - 1);
-         init_and_make_win (locator,
-                            LOCATOR_WIN,
-                            2 /* 1 */ ,
-                            tui_term_width (),
-                            0,
-                            (src_height + asm_height) - 1,
-                            DONT_BOX_WINDOW);
+         reset_locator (locator,
+                        2 /* 1 */ ,
+                        tui_term_width (),
+                        0,
+                        (src_height + asm_height) - 1);
        }
       else
        {
@@ -696,13 +692,11 @@ show_data (enum tui_layout_type new_layout)
       else
        tui_win_list[win_type]
          = make_disasm_window (src_height, data_height - 1);
-      init_and_make_win (locator,
-                            LOCATOR_WIN,
-                            2 /* 1 */ ,
-                            tui_term_width (),
-                            0,
-                            total_height - 1,
-                            DONT_BOX_WINDOW);
+      reset_locator (locator,
+                    2 /* 1 */ ,
+                    tui_term_width (),
+                    0,
+                    total_height - 1);
       base = (tui_source_window_base *) tui_win_list[win_type];
     }
   else
@@ -751,48 +745,13 @@ tui_gen_win_info::reset (enum tui_win_type win_type,
   origin.y = origin_y_;
 }
 
-/* init_and_make_win().
- */
-static tui_gen_win_info *
-init_and_make_win (tui_gen_win_info *win_info, 
-                  enum tui_win_type win_type,
-                  int height, int width, 
-                  int origin_x, int origin_y,
-                  enum tui_box box_it)
+static void
+reset_locator (tui_gen_win_info *win_info, 
+              int height, int width, 
+              int origin_x, int origin_y)
 {
-  if (win_info == NULL)
-    {
-      switch (win_type)
-       {
-       case SRC_WIN:
-         win_info = new tui_source_window ();
-         break;
-
-       case DISASSEM_WIN:
-         win_info = new tui_disasm_window ();
-         break;
-
-       case DATA_WIN:
-         win_info = new tui_data_window ();
-         break;
-
-       case CMD_WIN:
-         win_info = new tui_cmd_window ();
-         break;
-
-       case EXEC_INFO_WIN:
-         win_info = new tui_exec_info_window ();
-         break;
-
-       default:
-         gdb_assert_not_reached (_("unhandled window type"));
-       }
-    }
-
-  win_info->reset (win_type, height, width, origin_x, origin_y);
-  tui_make_window (win_info, box_it);
-
-  return win_info;
+  win_info->reset (LOCATOR_WIN, height, width, origin_x, origin_y);
+  tui_make_window (win_info, DONT_BOX_WINDOW);
 }
 
 
@@ -825,13 +784,11 @@ show_source_or_disasm_and_command (enum tui_layout_type layout_type)
            *win_info_ptr = make_source_window (src_height - 1, 0);
          else
            *win_info_ptr = make_disasm_window (src_height - 1, 0);
-         init_and_make_win (locator,
-                            LOCATOR_WIN,
-                            2 /* 1 */ ,
-                            tui_term_width (),
-                            0,
-                            src_height - 1,
-                            DONT_BOX_WINDOW);
+         reset_locator (locator,
+                        2 /* 1 */ ,
+                        tui_term_width (),
+                        0,
+                        src_height - 1);
          base = (tui_source_window_base *) *win_info_ptr;
        }
       else