* gdb.base/help.exp: Allow Win32 child process.
[deliverable/binutils-gdb.git] / gdb / tui / tuiLayout.c
index 18fda5877a5d4aca84eddf927743aa8e65214452..cddbd14342f64c8b0825e4d856432d161df5e469 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 "source.h"
 #include <ctype.h>
 
 #include "tui.h"
@@ -38,7 +59,7 @@
 /*******************************
 ** Static Local Decls
 ********************************/
-
+static void showLayout (TuiLayoutType);
 static void _initGenWinInfo (TuiGenWinInfoPtr, TuiWinType, int, int, int, int);
 static void _initAndMakeWin (Opaque *, TuiWinType, int, int, int, int, int);
 static void _showSourceOrDisassemAndCommand (TuiLayoutType);
@@ -55,9 +76,7 @@ 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 CORE_ADDR _extractDisplayStartAddr (void);
 static void _tuiHandleXDBLayout (TuiLayoutDefPtr);
 
@@ -68,20 +87,8 @@ static void _tuiHandleXDBLayout (TuiLayoutDefPtr);
 
 #define LAYOUT_USAGE     "Usage: layout prev | next | <layout_name> \n"
 
-/***************************************
-** Static Local Data
-***************************************/
-static TuiLayoutType lastLayout = UNDEFINED_LAYOUT;
-
-/***************************************
-** PUBLIC FUNCTIONS
-***************************************/
-
-/*
-   ** showLayout().
-   **        Show the screen layout defined
- */
-void
+/* Show the screen layout defined.  */
+static void
 showLayout (TuiLayoutType layout)
 {
   TuiLayoutType curLayout = currentLayout ();
@@ -93,7 +100,6 @@ showLayout (TuiLayoutType layout)
          ** should free the content and reallocate on next display of
          ** source/asm
        */
-      tuiClearAllSourceWinsContent (NO_EMPTY_SOURCE_PROMPT);
       freeAllSourceWinsContent ();
       clearSourceWindows ();
       if (layout == SRC_DATA_COMMAND || layout == DISASSEM_DATA_COMMAND)
@@ -128,9 +134,7 @@ showLayout (TuiLayoutType layout)
            }
        }
     }
-
-  return;
-}                              /* showLayout */
+}
 
 
 /*
@@ -177,8 +181,6 @@ tuiSetLayout (TuiLayoutType layoutType,
        {
          if (newLayout != curLayout)
            {
-             if (winWithFocus != cmdWin)
-               tuiClearWinFocus ();
              showLayout (newLayout);
              /*
                 ** Now determine where focus should be
@@ -273,24 +275,7 @@ tuiSetLayout (TuiLayoutType layoutType,
     status = TUI_FAILURE;
 
   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().
@@ -347,22 +332,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 +404,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 +417,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 */
+}
 
 
 /*************************
@@ -487,7 +451,7 @@ tui_set_layout (const 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]);
 
@@ -583,12 +547,13 @@ _extractDisplayStartAddr (void)
   TuiLayoutType curLayout = currentLayout ();
   CORE_ADDR addr;
   CORE_ADDR pc;
+  struct symtab_and_line cursal = get_current_source_symtab_and_line ();
 
   switch (curLayout)
     {
     case SRC_COMMAND:
     case SRC_DATA_COMMAND:
-      find_line_pc (current_source_symtab,
+      find_line_pc (cursal.symtab,
                    srcWin->detail.sourceInfo.startLineOrAddr.lineNo,
                    &pc);
       addr = pc;
@@ -633,6 +598,8 @@ _tuiToggleLayout_command (char *arg, int fromTTY)
 {
   TuiLayoutDefPtr layoutDef = tuiLayoutDef ();
 
+  /* Make sure the curses mode is enabled.  */
+  tui_enable ();
   if (layoutDef->displayMode == SRC_WIN)
     layoutDef->displayMode = DISASSEM_WIN;
   else
@@ -649,6 +616,8 @@ _tuiToggleSplitLayout_command (char *arg, int fromTTY)
 {
   TuiLayoutDefPtr layoutDef = tuiLayoutDef ();
 
+  /* Make sure the curses mode is enabled.  */
+  tui_enable ();
   layoutDef->split = (!layoutDef->split);
   _tuiHandleXDBLayout (layoutDef);
 
@@ -658,6 +627,10 @@ _tuiToggleSplitLayout_command (char *arg, int fromTTY)
 static void
 _tuiLayout_command (char *arg, int fromTTY)
 {
+  /* Make sure the curses mode is enabled.  */
+  tui_enable ();
+
+  /* Switch to the selected layout.  */
   if (tui_set_layout (arg) != TUI_SUCCESS)
     warning ("Invalid layout specified.\n%s", LAYOUT_USAGE);
 
@@ -806,8 +779,6 @@ _showDisassemCommand (void)
 static void
 _showSourceDisassemCommand (void)
 {
-  TuiGenWinInfoPtr locator = locatorWinInfoPtr ();
-
   if (currentLayout () != SRC_DISASSEM_COMMAND)
     {
       int cmdHeight, srcHeight, asmHeight;
@@ -1045,13 +1016,9 @@ _initAndMakeWin (Opaque * winInfoPtr, TuiWinType winType,
            ((TuiWinInfoPtr) opaqueWinInfo)->canHighlight = TRUE;
        }
       makeWindow (generic, boxIt);
-      if (winType == LOCATOR_WIN)
-       tuiClearLocatorDisplay ();
     }
   *winInfoPtr = opaqueWinInfo;
-
-  return;
-}                              /* _initAndMakeWin */
+}
 
 
 /*
@@ -1104,7 +1071,6 @@ _showSourceOrDisassemAndCommand (TuiLayoutType layoutType)
   if (currentLayout () != layoutType)
     {
       TuiWinInfoPtr *winInfoPtr;
-      int areaLeft;
       int srcHeight, cmdHeight;
       TuiGenWinInfoPtr locator = locatorWinInfoPtr ();
 
This page took 0.027182 seconds and 4 git commands to generate.