Add FIXME explaining include problem.
[deliverable/binutils-gdb.git] / gdb / tui / tuiLayout.c
index 9d30bdec9735af2a6cd0a00b537b06a5ca12516c..aa98882d9d38143ee952079272ac4c7390d2f896 100644 (file)
@@ -1,5 +1,8 @@
 /* TUI layout window management.
-   Copyright 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+
+   Copyright 1998, 1999, 2000, 2001, 2002 Free Software Foundation,
+   Inc.
+
    Contributed by Hewlett-Packard Company.
 
    This file is part of GDB.
    Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
+/* FIXME: cagney/2002-02-28: The GDB coding standard indicates that
+   "defs.h" should be included first.  Unfortunatly some systems
+   (currently Debian GNU/Linux) include the <stdbool.h> via <curses.h>
+   and they clash with "bfd.h"'s definiton of true/false.  The correct
+   fix is to remove true/false from "bfd.h", however, until that
+   happens, hack around it by including "config.h" and <curses.h>
+   first.  */
+
+#include "config.h"
+#ifdef HAVE_NCURSES_H       
+#include <ncurses.h>
+#else
+#ifdef HAVE_CURSES_H
+#include <curses.h>
+#endif
+#endif
+
 #include "defs.h"
 #include "command.h"
 #include "symtab.h"
 #include "frame.h"
+#include <ctype.h>
 
 #include "tui.h"
 #include "tuiData.h"
+#include "tuiDataWin.h"
 #include "tuiGeneralWin.h"
 #include "tuiStack.h"
 #include "tuiRegs.h"
+#include "tuiWin.h"
+#include "tuiSourceWin.h"
 #include "tuiDisassem.h"
 
 /*******************************
@@ -51,12 +75,9 @@ static TuiLayoutType _nextLayout (void);
 static TuiLayoutType _prevLayout (void);
 static void _tuiLayout_command (char *, int);
 static void _tuiToggleLayout_command (char *, int);
-static void _tui_vToggleLayout_command (va_list);
 static void _tuiToggleSplitLayout_command (char *, int);
-static void _tui_vToggleSplitLayout_command (va_list);
-static Opaque _extractDisplayStartAddr (void);
+static CORE_ADDR _extractDisplayStartAddr (void);
 static void _tuiHandleXDBLayout (TuiLayoutDefPtr);
-static TuiStatus _tuiSetLayoutTo (char *);
 
 
 /***************************************
@@ -148,7 +169,7 @@ tuiSetLayout (TuiLayoutType layoutType,
     {
       TuiLayoutType curLayout = currentLayout (), newLayout = UNDEFINED_LAYOUT;
       int regsPopulate = FALSE;
-      Opaque addr = _extractDisplayStartAddr ();
+      CORE_ADDR addr = _extractDisplayStartAddr ();
       TuiWinInfoPtr newWinWithFocus = (TuiWinInfoPtr) NULL, winWithFocus = tuiWinWithFocus ();
       TuiLayoutDefPtr layoutDef = tuiLayoutDef ();
 
@@ -197,8 +218,7 @@ tuiSetLayout (TuiLayoutType layoutType,
                         ** 2. if target was compiled without -g
                         ** We still want to show the assembly though!
                       */
-                     addr = vcatch_errors ((OpaqueFuncPtr)
-                                           tuiGetBeginAsmAddress);
+                     addr = tuiGetBeginAsmAddress ();
                      tuiSetWinFocusTo (disassemWin);
                      layoutDef->displayMode = DISASSEM_WIN;
                      layoutDef->split = FALSE;
@@ -211,8 +231,7 @@ tuiSetLayout (TuiLayoutType layoutType,
                         ** 2. if target was compiled without -g
                         ** We still want to show the assembly though!
                       */
-                     addr = vcatch_errors ((OpaqueFuncPtr)
-                                           tuiGetBeginAsmAddress);
+                     addr = tuiGetBeginAsmAddress ();
                      if (winWithFocus == srcWin)
                        tuiSetWinFocusTo (srcWin);
                      else
@@ -235,8 +254,7 @@ tuiSetLayout (TuiLayoutType layoutType,
                         ** 2. if target was compiled without -g
                         ** We still want to show the assembly though!
                       */
-                     addr = vcatch_errors ((OpaqueFuncPtr)
-                                           tuiGetBeginAsmAddress);
+                     addr = tuiGetBeginAsmAddress ();
                      if (winWithFocus != dataWin)
                        tuiSetWinFocusTo (disassemWin);
                      else
@@ -275,23 +293,6 @@ tuiSetLayout (TuiLayoutType layoutType,
   return status;
 }                              /* tuiSetLayout */
 
-
-/*
-   ** tui_vSetLayoutTo()
-   **        Function to set the layout to SRC, ASM, SPLIT, NEXT, PREV, DATA,
-   **        REGS, $REGS, $GREGS, $FREGS, $SREGS with arguments in a va_list
- */
-TuiStatus
-tui_vSetLayoutTo (va_list args)
-{
-  char *layoutName;
-
-  layoutName = va_arg (args, char *);
-
-  return (_tuiSetLayoutTo (layoutName));
-}                              /* tui_vSetLayoutTo */
-
-
 /*
    ** tuiAddWinToLayout().
    **        Add the specified window to the layout in a logical way.
@@ -347,22 +348,6 @@ tuiAddWinToLayout (TuiWinType type)
 }                              /* tuiAddWinToLayout */
 
 
-/*
-   ** tui_vAddWinToLayout().
-   **        Add the specified window to the layout in a logical way,
-   **        with arguments in a va_list.
- */
-void
-tui_vAddWinToLayout (va_list args)
-{
-  TuiWinType type = va_arg (args, TuiWinType);
-
-  tuiAddWinToLayout (type);
-
-  return;
-}                              /* tui_vAddWinToLayout */
-
-
 /*
    ** tuiDefaultWinHeight().
    **        Answer the height of a window.  If it hasn't been created yet,
@@ -435,10 +420,8 @@ tuiDefaultWinViewportHeight (TuiWinType type, TuiLayoutType layout)
 void
 _initialize_tuiLayout (void)
 {
-  if (tui_version)
-    {
-      add_com ("layout", class_tui, _tuiLayout_command,
-              "Change the layout of windows.\n\
+  add_com ("layout", class_tui, _tuiLayout_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\
@@ -450,18 +433,15 @@ Layout names are:\n\
            source/assembly/command (split) is displayed, \n\
            the register window is displayed with \n\
            the window that has current logical focus.\n");
-      if (xdb_commands)
-       {
-         add_com ("td", class_tui, _tuiToggleLayout_command,
-                  "Toggle between Source/Command and Disassembly/Command layouts.\n");
-         add_com ("ts", class_tui, _tuiToggleSplitLayout_command,
-                  "Toggle between Source/Command or Disassembly/Command and \n\
+  if (xdb_commands)
+    {
+      add_com ("td", class_tui, _tuiToggleLayout_command,
+               "Toggle between Source/Command and Disassembly/Command layouts.\n");
+      add_com ("ts", class_tui, _tuiToggleSplitLayout_command,
+               "Toggle between Source/Command or Disassembly/Command and \n\
 Source/Disassembly/Command layouts.\n");
-       }
     }
-
-  return;
-}                              /* _intialize_tuiLayout */
+}
 
 
 /*************************
@@ -474,8 +454,8 @@ Source/Disassembly/Command layouts.\n");
    **    Function to set the layout to SRC, ASM, SPLIT, NEXT, PREV, DATA, REGS,
    **        $REGS, $GREGS, $FREGS, $SREGS.
  */
-static TuiStatus
-_tuiSetLayoutTo (char *layoutName)
+TuiStatus
+tui_set_layout (const char *layoutName)
 {
   TuiStatus status = TUI_SUCCESS;
 
@@ -487,7 +467,7 @@ _tuiSetLayoutTo (char *layoutName)
       TuiRegisterDisplayType dpyType = TUI_UNDEFINED_REGS;
       TuiLayoutType curLayout = currentLayout ();
 
-      bufPtr = (char *) tuiStrDup (layoutName);
+      bufPtr = (char *) xstrdup (layoutName);
       for (i = 0; (i < strlen (layoutName)); i++)
        bufPtr[i] = toupper (bufPtr[i]);
 
@@ -539,7 +519,7 @@ _tuiSetLayoutTo (char *layoutName)
                dpyType = TUI_GENERAL_REGS;
              else if (subset_compare (bufPtr, TUI_SPECIAL_REGS_NAME))
                dpyType = TUI_SPECIAL_REGS;
-             else
+             else if (dataWin)
                {
                  if (dataWin->detail.dataDisplayInfo.regsDisplayType !=
                      TUI_UNDEFINED_REGS)
@@ -574,22 +554,24 @@ _tuiSetLayoutTo (char *layoutName)
     status = TUI_FAILURE;
 
   return status;
-}                              /* _tuiSetLayoutTo */
+}
 
 
-static Opaque
+static CORE_ADDR
 _extractDisplayStartAddr (void)
 {
   TuiLayoutType curLayout = currentLayout ();
-  Opaque addr;
+  CORE_ADDR addr;
+  CORE_ADDR pc;
 
   switch (curLayout)
     {
     case SRC_COMMAND:
     case SRC_DATA_COMMAND:
-      addr = (Opaque) find_line_pc (
-                                    current_source_symtab,
-                         srcWin->detail.sourceInfo.startLineOrAddr.lineNo);
+      find_line_pc (current_source_symtab,
+                   srcWin->detail.sourceInfo.startLineOrAddr.lineNo,
+                   &pc);
+      addr = pc;
       break;
     case DISASSEM_COMMAND:
     case SRC_DISASSEM_COMMAND:
@@ -597,7 +579,7 @@ _extractDisplayStartAddr (void)
       addr = disassemWin->detail.sourceInfo.startLineOrAddr.addr;
       break;
     default:
-      addr = (Opaque) NULL;
+      addr = 0;
       break;
     }
 
@@ -628,15 +610,11 @@ _tuiHandleXDBLayout (TuiLayoutDefPtr layoutDef)
 
 static void
 _tuiToggleLayout_command (char *arg, int fromTTY)
-{
-  tuiDo ((TuiOpaqueFuncPtr) _tui_vToggleLayout_command, arg, fromTTY);
-}
-
-static void
-_tui_vToggleLayout_command (va_list args)
 {
   TuiLayoutDefPtr layoutDef = tuiLayoutDef ();
 
+  /* Make sure the curses mode is enabled.  */
+  tui_enable ();
   if (layoutDef->displayMode == SRC_WIN)
     layoutDef->displayMode = DISASSEM_WIN;
   else
@@ -645,37 +623,33 @@ _tui_vToggleLayout_command (va_list args)
   if (!layoutDef->split)
     _tuiHandleXDBLayout (layoutDef);
 
-  return;
-}                              /* _tuiToggleLayout_command */
+}
 
 
 static void
 _tuiToggleSplitLayout_command (char *arg, int fromTTY)
-{
-  tuiDo ((TuiOpaqueFuncPtr) _tui_vToggleSplitLayout_command, arg, fromTTY);
-}
-
-static void
-_tui_vToggleSplitLayout_command (va_list args)
 {
   TuiLayoutDefPtr layoutDef = tuiLayoutDef ();
 
+  /* Make sure the curses mode is enabled.  */
+  tui_enable ();
   layoutDef->split = (!layoutDef->split);
   _tuiHandleXDBLayout (layoutDef);
 
-  return;
-}                              /* _tui_vToggleSplitLayout_command */
+}
 
 
 static void
 _tuiLayout_command (char *arg, int fromTTY)
 {
-  if ((TuiStatus) tuiDo (
-                  (TuiOpaqueFuncPtr) tui_vSetLayoutTo, arg) != TUI_SUCCESS)
-    warning ("Invalid layout specified.\n%s" LAYOUT_USAGE);
+  /* Make sure the curses mode is enabled.  */
+  tui_enable ();
 
-  return;
-}                              /* _tuiLayout_command */
+  /* Switch to the selected layout.  */
+  if (tui_set_layout (arg) != TUI_SUCCESS)
+    warning ("Invalid layout specified.\n%s", LAYOUT_USAGE);
+
+}
 
 /*
    ** _nextLayout().
@@ -1061,7 +1035,6 @@ _initAndMakeWin (Opaque * winInfoPtr, TuiWinType winType,
       makeWindow (generic, boxIt);
       if (winType == LOCATOR_WIN)
        tuiClearLocatorDisplay ();
-      echo ();
     }
   *winInfoPtr = opaqueWinInfo;
 
This page took 0.027795 seconds and 4 git commands to generate.