Add comments describing tui_ui_out and its fields, cleanup a bit
[deliverable/binutils-gdb.git] / gdb / tui / tui-layout.c
index e3993ab9f11a0f1c2157c68910a6e170509e9eba..f4e926e7061856836dc33ae2ac8123d435eb0776 100644 (file)
@@ -1,6 +1,6 @@
 /* TUI layout window management.
 
-   Copyright (C) 1998-2015 Free Software Foundation, Inc.
+   Copyright (C) 1998-2019 Free Software Foundation, Inc.
 
    Contributed by Hewlett-Packard Company.
 
@@ -62,7 +62,7 @@ static void show_source_disasm_command (void);
 static void show_data (enum tui_layout_type);
 static enum tui_layout_type next_layout (void);
 static enum tui_layout_type prev_layout (void);
-static void tui_layout_command (char *, int);
+static void tui_layout_command (const char *, int);
 static void extract_display_start_addr (struct gdbarch **, CORE_ADDR *);
 
 
@@ -353,22 +353,20 @@ tui_default_win_viewport_height (enum tui_win_type type,
 /* Complete possible layout names.  TEXT is the complete text entered so
    far, WORD is the word currently being completed.  */
 
-static VEC (char_ptr) *
+static void
 layout_completer (struct cmd_list_element *ignore,
+                 completion_tracker &tracker,
                  const char *text, const char *word)
 {
   static const char *layout_names [] =
     { "src", "asm", "split", "regs", "next", "prev", NULL };
 
-  return complete_on_enum (layout_names, text, word);
+  complete_on_enum (tracker, layout_names, text, word);
 }
 
 /* Function to initialize gdb commands, for tui window layout
    manipulation.  */
 
-/* Provide a prototype to silence -Wmissing-prototypes.  */
-extern initialize_file_ftype _initialize_tui_layout;
-
 void
 _initialize_tui_layout (void)
 {
@@ -376,7 +374,7 @@ _initialize_tui_layout (void)
 
   cmd = add_com ("layout", class_tui, tui_layout_command, _("\
 Change the layout of windows.\n\
-Usage: layout prev | next | <layout_name> \n\
+Usage: layout prev | next | LAYOUT-NAME\n\
 Layout names are:\n\
    src   : Displays source and command windows.\n\
    asm   : Displays disassembly and command windows.\n\
@@ -403,16 +401,16 @@ tui_set_layout_by_name (const char *layout_name)
 {
   enum tui_status status = TUI_SUCCESS;
 
-  if (layout_name != (char *) NULL)
+  if (layout_name != NULL)
     {
       int i;
-      char *buf_ptr;
       enum tui_layout_type new_layout = UNDEFINED_LAYOUT;
       enum tui_layout_type cur_layout = tui_current_layout ();
 
-      buf_ptr = (char *) xstrdup (layout_name);
-      for (i = 0; (i < strlen (layout_name)); i++)
-       buf_ptr[i] = toupper (buf_ptr[i]);
+      std::string copy = layout_name;
+      for (i = 0; i < copy.size (); i++)
+       copy[i] = toupper (copy[i]);
+      const char *buf_ptr = copy.c_str ();
 
       /* First check for ambiguous input.  */
       if (strlen (buf_ptr) <= 1 && *buf_ptr == 'S')
@@ -443,9 +441,13 @@ tui_set_layout_by_name (const char *layout_name)
          else
            status = TUI_FAILURE;
 
-         tui_set_layout (new_layout);
+         if (status == TUI_SUCCESS)
+           {
+             /* Make sure the curses mode is enabled.  */
+             tui_enable ();
+             tui_set_layout (new_layout);
+           }
        }
-      xfree (buf_ptr);
     }
   else
     status = TUI_FAILURE;
@@ -490,15 +492,11 @@ extract_display_start_addr (struct gdbarch **gdbarch_p, CORE_ADDR *addr_p)
 
 
 static void
-tui_layout_command (char *arg, int from_tty)
+tui_layout_command (const char *arg, int from_tty)
 {
-  /* Make sure the curses mode is enabled.  */
-  tui_enable ();
-
   /* Switch to the selected layout.  */
   if (tui_set_layout_by_name (arg) != TUI_SUCCESS)
     warning (_("Invalid layout specified.\n%s"), LAYOUT_USAGE);
-
 }
 
 /* Answer the previous layout to cycle to.  */
@@ -546,13 +544,14 @@ static void
 make_command_window (struct tui_win_info **win_info_ptr, 
                     int height, int origin_y)
 {
-  *win_info_ptr = init_and_make_win (*win_info_ptr,
-                                    CMD_WIN,
-                                    height,
-                                    tui_term_width (),
-                                    0,
-                                    origin_y,
-                                    DONT_BOX_WINDOW);
+  *win_info_ptr
+    = (struct tui_win_info *) init_and_make_win (*win_info_ptr,
+                                                CMD_WIN,
+                                                height,
+                                                tui_term_width (),
+                                                0,
+                                                origin_y,
+                                                DONT_BOX_WINDOW);
 
   (*win_info_ptr)->can_highlight = FALSE;
 }
@@ -586,13 +585,14 @@ static void
 make_data_window (struct tui_win_info **win_info_ptr, 
                  int height, int origin_y)
 {
-  *win_info_ptr = init_and_make_win (*win_info_ptr,
-                                    DATA_WIN,
-                                    height,
-                                    tui_term_width (),
-                                    0,
-                                    origin_y,
-                                    BOX_WINDOW);
+  *win_info_ptr
+    = (struct tui_win_info *) init_and_make_win (*win_info_ptr,
+                                                DATA_WIN,
+                                                height,
+                                                tui_term_width (),
+                                                0,
+                                                origin_y,
+                                                BOX_WINDOW);
 }
 
 
@@ -658,13 +658,15 @@ show_source_disasm_command (void)
          if (TUI_DISASM_WIN == NULL)
            {
              make_disasm_window (&TUI_DISASM_WIN, asm_height, src_height - 1);
-             locator = init_and_make_win (locator,
-                                          LOCATOR_WIN,
-                                          2 /* 1 */ ,
-                                          tui_term_width (),
-                                          0,
-                                          (src_height + asm_height) - 1,
-                                          DONT_BOX_WINDOW);
+             locator
+               = ((struct tui_gen_win_info *)
+                  init_and_make_win (locator,
+                                     LOCATOR_WIN,
+                                     2 /* 1 */ ,
+                                     tui_term_width (),
+                                     0,
+                                     (src_height + asm_height) - 1,
+                                     DONT_BOX_WINDOW));
            }
          else
            {
@@ -750,13 +752,15 @@ show_data (enum tui_layout_type new_layout)
        make_source_window (&tui_win_list[win_type], src_height, data_height - 1);
       else
        make_disasm_window (&tui_win_list[win_type], src_height, data_height - 1);
-      locator = init_and_make_win (locator,
-                                  LOCATOR_WIN,
-                                  2 /* 1 */ ,
-                                  tui_term_width (),
-                                  0,
-                                  total_height - 1,
-                                  DONT_BOX_WINDOW);
+      locator
+       = ((struct tui_gen_win_info *)
+          init_and_make_win (locator,
+                             LOCATOR_WIN,
+                             2 /* 1 */ ,
+                             tui_term_width (),
+                             0,
+                             total_height - 1,
+                             DONT_BOX_WINDOW));
     }
   else
     {
@@ -859,29 +863,33 @@ make_source_or_disasm_window (struct tui_win_info **win_info_ptr,
                              enum tui_win_type type,
                              int height, int origin_y)
 {
-  struct tui_gen_win_info *execution_info = (struct tui_gen_win_info *) NULL;
+  struct tui_gen_win_info *execution_info = NULL;
 
   /* Create the exeuction info window.  */
   if (type == SRC_WIN)
     execution_info = tui_source_exec_info_win_ptr ();
   else
     execution_info = tui_disassem_exec_info_win_ptr ();
-  execution_info = init_and_make_win (execution_info,
-                                     EXEC_INFO_WIN,
-                                     height,
-                                     3,
-                                     0,
-                                     origin_y,
-                                     DONT_BOX_WINDOW);
+  execution_info
+    = ((struct tui_gen_win_info *)
+       init_and_make_win (execution_info,
+                         EXEC_INFO_WIN,
+                         height,
+                         3,
+                         0,
+                         origin_y,
+                         DONT_BOX_WINDOW));
 
   /* Now create the source window.  */
-  *win_info_ptr = init_and_make_win (*win_info_ptr,
-                                    type,
-                                    height,
-                                    tui_term_width () - execution_info->width,
-                                    execution_info->width,
-                                    origin_y,
-                                    BOX_WINDOW);
+  *win_info_ptr
+    = ((struct tui_win_info *)
+       init_and_make_win (*win_info_ptr,
+                         type,
+                         height,
+                         tui_term_width () - execution_info->width,
+                         execution_info->width,
+                         origin_y,
+                         BOX_WINDOW));
 
   (*win_info_ptr)->detail.source_info.execution_info = execution_info;
 }
@@ -914,13 +922,15 @@ show_source_or_disasm_and_command (enum tui_layout_type layout_type)
            make_source_window (win_info_ptr, src_height - 1, 0);
          else
            make_disasm_window (win_info_ptr, src_height - 1, 0);
-         locator = init_and_make_win (locator,
-                                      LOCATOR_WIN,
-                                      2 /* 1 */ ,
-                                      tui_term_width (),
-                                      0,
-                                      src_height - 1,
-                                      DONT_BOX_WINDOW);
+         locator
+           = ((struct tui_gen_win_info *)
+              init_and_make_win (locator,
+                                 LOCATOR_WIN,
+                                 2 /* 1 */ ,
+                                 tui_term_width (),
+                                 0,
+                                 src_height - 1,
+                                 DONT_BOX_WINDOW));
        }
       else
        {
This page took 0.027755 seconds and 4 git commands to generate.