* ada-lang.c (field_alignment): Guard against NULL.
[deliverable/binutils-gdb.git] / gdb / tui / tui-layout.c
index 4e3de8f698aaace02d74326b057f69664f48ef42..5995af0d2b021e7700ef013232f42d655a096962 100644 (file)
@@ -1,7 +1,7 @@
 /* TUI layout window management.
 
-   Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software
-   Foundation, Inc.
+   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2007
+   Free Software Foundation, Inc.
 
    Contributed by Hewlett-Packard Company.
 
@@ -19,8 +19,8 @@
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place - Suite 330,
-   Boston, MA 02111-1307, USA.  */
+   Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
 
 #include "defs.h"
 #include "command.h"
@@ -39,6 +39,7 @@
 #include "tui/tui-winsource.h"
 #include "tui/tui-disasm.h"
 
+#include "gdb_string.h"
 #include "gdb_curses.h"
 
 /*******************************
@@ -46,7 +47,7 @@
 ********************************/
 static void show_layout (enum tui_layout_type);
 static void init_gen_win_info (struct tui_gen_win_info *, enum tui_win_type, int, int, int, int);
-static void init_and_make_win (void **, enum tui_win_type, int, int, int, int, int);
+static void *init_and_make_win (void *, enum tui_win_type, int, int, int, int, int);
 static void show_source_or_disasm_and_command (enum tui_layout_type);
 static void make_source_or_disasm_window (struct tui_win_info * *, enum tui_win_type, int, int);
 static void make_command_window (struct tui_win_info * *, int, int);
@@ -138,7 +139,6 @@ tui_set_layout (enum tui_layout_type layout_type,
       enum tui_layout_type cur_layout = tui_current_layout (), new_layout = UNDEFINED_LAYOUT;
       int regs_populate = FALSE;
       CORE_ADDR addr = extract_display_start_addr ();
-      struct tui_win_info * new_win_with_focus = (struct tui_win_info *) NULL;
       struct tui_win_info * win_with_focus = tui_win_with_focus ();
       struct tui_layout_def * layout_def = tui_layout_def ();
 
@@ -233,10 +233,8 @@ tui_set_layout (enum tui_layout_type layout_type,
                      break;
                    }
                }
-             if (new_win_with_focus != (struct tui_win_info *) NULL)
-               tui_set_win_focus_to (new_win_with_focus);
              /*
-                ** Now update the window content
+              * Now update the window content.
               */
              if (!regs_populate &&
                  (new_layout == SRC_DATA_COMMAND ||
@@ -247,10 +245,7 @@ tui_set_layout (enum tui_layout_type layout_type,
            }
          if (regs_populate)
            {
-             layout_def->regs_display_type =
-               (regs_display_type == TUI_UNDEFINED_REGS ?
-                TUI_GENERAL_REGS : regs_display_type);
-             tui_show_registers (layout_def->regs_display_type);
+              tui_show_registers (TUI_DATA_WIN->detail.data_display_info.current_group);
            }
        }
     }
@@ -374,8 +369,8 @@ tui_default_win_viewport_height (enum tui_win_type type,
 void
 _initialize_tui_layout (void)
 {
-  add_com ("layout", class_tui, tui_layout_command,
-           "Change the layout of windows.\n\
+  add_com ("layout", class_tui, tui_layout_command, _("\
+Change the layout of windows.\n\
 Usage: layout prev | next | <layout_name> \n\
 Layout names are:\n\
    src   : Displays source and command windows.\n\
@@ -386,14 +381,14 @@ Layout names are:\n\
            register window is displayed. If the\n\
            source/assembly/command (split) is displayed, \n\
            the register window is displayed with \n\
-           the window that has current logical focus.\n");
+           the window that has current logical focus.\n"));
   if (xdb_commands)
     {
-      add_com ("td", class_tui, tui_toggle_layout_command,
-               "Toggle between Source/Command and Disassembly/Command layouts.\n");
-      add_com ("ts", class_tui, tui_toggle_split_layout_command,
-               "Toggle between Source/Command or Disassembly/Command and \n\
-Source/Disassembly/Command layouts.\n");
+      add_com ("td", class_tui, tui_toggle_layout_command, _("\
+Toggle between Source/Command and Disassembly/Command layouts.\n"));
+      add_com ("ts", class_tui, tui_toggle_split_layout_command, _("\
+Toggle between Source/Command or Disassembly/Command and \n\
+Source/Disassembly/Command layouts.\n"));
     }
 }
 
@@ -425,7 +420,7 @@ tui_set_layout_for_display_command (const char *layout_name)
       /* First check for ambiguous input */
       if (strlen (buf_ptr) <= 1 && (*buf_ptr == 'S' || *buf_ptr == '$'))
        {
-         warning ("Ambiguous command input.\n");
+         warning (_("Ambiguous command input."));
          status = TUI_FAILURE;
        }
       else
@@ -496,10 +491,10 @@ tui_set_layout_for_display_command (const char *layout_name)
            new_layout = prev_layout ();
          else
            status = TUI_FAILURE;
-         xfree (buf_ptr);
 
          tui_set_layout (new_layout, dpy_type);
        }
+      xfree (buf_ptr);
     }
   else
     status = TUI_FAILURE;
@@ -521,14 +516,14 @@ extract_display_start_addr (void)
     case SRC_COMMAND:
     case SRC_DATA_COMMAND:
       find_line_pc (cursal.symtab,
-                   TUI_SRC_WIN->detail.source_info.start_line_or_addr.line_no,
+                   TUI_SRC_WIN->detail.source_info.start_line_or_addr.u.line_no,
                    &pc);
       addr = pc;
       break;
     case DISASSEM_COMMAND:
     case SRC_DISASSEM_COMMAND:
     case DISASSEM_DATA_COMMAND:
-      addr = TUI_DISASM_WIN->detail.source_info.start_line_or_addr.addr;
+      addr = TUI_DISASM_WIN->detail.source_info.start_line_or_addr.u.addr;
       break;
     default:
       addr = 0;
@@ -594,7 +589,7 @@ tui_layout_command (char *arg, int from_tty)
 
   /* Switch to the selected layout.  */
   if (tui_set_layout_for_display_command (arg) != TUI_SUCCESS)
-    warning ("Invalid layout specified.\n%s", LAYOUT_USAGE);
+    warning (_("Invalid layout specified.\n%s"), LAYOUT_USAGE);
 
 }
 
@@ -642,13 +637,13 @@ prev_layout (void)
 static void
 make_command_window (struct tui_win_info * * win_info_ptr, int height, int origin_y)
 {
-  init_and_make_win ((void **) win_info_ptr,
-                  CMD_WIN,
-                  height,
-                  tui_term_width (),
-                  0,
-                  origin_y,
-                  DONT_BOX_WINDOW);
+  *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)->can_highlight = FALSE;
 }
@@ -681,13 +676,13 @@ make_disasm_window (struct tui_win_info * * win_info_ptr, int height, int origin
 static void
 make_data_window (struct tui_win_info * * win_info_ptr, int height, int origin_y)
 {
-  init_and_make_win ((void **) win_info_ptr,
-                  DATA_WIN,
-                  height,
-                  tui_term_width (),
-                  0,
-                  origin_y,
-                  BOX_WINDOW);
+  *win_info_ptr = init_and_make_win (*win_info_ptr,
+                                    DATA_WIN,
+                                    height,
+                                    tui_term_width (),
+                                    0,
+                                    origin_y,
+                                    BOX_WINDOW);
 }
 
 
@@ -753,13 +748,13 @@ show_source_disasm_command (void)
          if (TUI_DISASM_WIN == NULL)
            {
              make_disasm_window (&TUI_DISASM_WIN, asm_height, src_height - 1);
-             init_and_make_win ((void **) & locator,
-                              LOCATOR_WIN,
-                              2 /* 1 */ ,
-                              tui_term_width (),
-                              0,
-                              (src_height + asm_height) - 1,
-                              DONT_BOX_WINDOW);
+             locator = init_and_make_win (locator,
+                                          LOCATOR_WIN,
+                                          2 /* 1 */ ,
+                                          tui_term_width (),
+                                          0,
+                                          (src_height + asm_height) - 1,
+                                          DONT_BOX_WINDOW);
            }
          else
            {
@@ -846,13 +841,13 @@ 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);
-      init_and_make_win ((void **) & locator,
-                      LOCATOR_WIN,
-                      2 /* 1 */ ,
-                      tui_term_width (),
-                      0,
-                      total_height - 1,
-                      DONT_BOX_WINDOW);
+      locator = init_and_make_win (locator,
+                                  LOCATOR_WIN,
+                                  2 /* 1 */ ,
+                                  tui_term_width (),
+                                  0,
+                                  total_height - 1,
+                                  DONT_BOX_WINDOW);
     }
   else
     {
@@ -913,11 +908,11 @@ init_gen_win_info (struct tui_gen_win_info * win_info, enum tui_win_type type,
 /*
    ** init_and_make_win().
  */
-static void
-init_and_make_win (void ** win_info_ptr, enum tui_win_type win_type,
-                 int height, int width, int origin_x, int origin_y, int box_it)
+static void *
+init_and_make_win (void *opaque_win_info, enum tui_win_type win_type,
+                  int height, int width, int origin_x, int origin_y,
+                  int box_it)
 {
-  void *opaque_win_info = *win_info_ptr;
   struct tui_gen_win_info * generic;
 
   if (opaque_win_info == NULL)
@@ -944,7 +939,7 @@ init_and_make_win (void ** win_info_ptr, enum tui_win_type win_type,
        }
       tui_make_window (generic, box_it);
     }
-  *win_info_ptr = opaque_win_info;
+  return opaque_win_info;
 }
 
 
@@ -961,23 +956,23 @@ make_source_or_disasm_window (struct tui_win_info * * win_info_ptr, enum tui_win
     execution_info = tui_source_exec_info_win_ptr ();
   else
     execution_info = tui_disassem_exec_info_win_ptr ();
-  init_and_make_win ((void **) & execution_info,
-                  EXEC_INFO_WIN,
-                  height,
-                  3,
-                  0,
-                  origin_y,
-                  DONT_BOX_WINDOW);
+  execution_info = init_and_make_win (execution_info,
+                                     EXEC_INFO_WIN,
+                                     height,
+                                     3,
+                                     0,
+                                     origin_y,
+                                     DONT_BOX_WINDOW);
   /*
      ** Now create the source window.
    */
-  init_and_make_win ((void **) win_info_ptr,
-                  type,
-                  height,
-                  tui_term_width () - execution_info->width,
-                  execution_info->width,
-                  origin_y,
-                  BOX_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)->detail.source_info.execution_info = execution_info;
 }
@@ -1011,13 +1006,13 @@ 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);
-         init_and_make_win ((void **) & locator,
-                          LOCATOR_WIN,
-                          2 /* 1 */ ,
-                          tui_term_width (),
-                          0,
-                          src_height - 1,
-                          DONT_BOX_WINDOW);
+         locator = init_and_make_win (locator,
+                                      LOCATOR_WIN,
+                                      2 /* 1 */ ,
+                                      tui_term_width (),
+                                      0,
+                                      src_height - 1,
+                                      DONT_BOX_WINDOW);
        }
       else
        {
This page took 0.029535 seconds and 4 git commands to generate.