/* TUI window generic functions.
- 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.
Author: Susan B. Macchia */
+/* 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 <string.h>
#include <ctype.h>
#include "defs.h"
#include "breakpoint.h"
#include "frame.h"
#include "cli/cli-cmds.h"
+#include "top.h"
+#include "source.h"
#include "tui.h"
#include "tuiData.h"
#include "tuiSourceWin.h"
#include "tuiDataWin.h"
-/*******************************
-** External Declarations
-********************************/
-extern void init_page_info ();
-
/*******************************
** Static Local Decls
********************************/
** PUBLIC FUNCTIONS
***************************************/
+#ifndef ACS_LRCORNER
+# define ACS_LRCORNER '+'
+#endif
+#ifndef ACS_LLCORNER
+# define ACS_LLCORNER '+'
+#endif
+#ifndef ACS_ULCORNER
+# define ACS_ULCORNER '+'
+#endif
+#ifndef ACS_URCORNER
+# define ACS_URCORNER '+'
+#endif
+#ifndef ACS_HLINE
+# define ACS_HLINE '-'
+#endif
+#ifndef ACS_VLINE
+# define ACS_VLINE '|'
+#endif
+
/* Possible values for tui-border-kind variable. */
static const char *tui_border_kind_enums[] = {
"space",
return need_redraw;
}
+static void
+set_tui_cmd (char *args, int from_tty)
+{
+}
+
+static void
+show_tui_cmd (char *args, int from_tty)
+{
+}
/*
** _initialize_tuiWin().
_initialize_tuiWin (void)
{
struct cmd_list_element *c;
+ static struct cmd_list_element *tui_setlist;
+ static struct cmd_list_element *tui_showlist;
/* Define the classes of commands.
They will appear in the help list in the reverse of this order. */
-
- add_cmd ("tui", class_tui, NO_FUNCTION,
+ add_cmd ("tui", class_tui, NULL,
"Text User Interface commands.",
&cmdlist);
+ add_prefix_cmd ("tui", class_tui, set_tui_cmd,
+ "TUI configuration variables",
+ &tui_setlist, "set tui ",
+ 0/*allow-unknown*/, &setlist);
+ add_prefix_cmd ("tui", class_tui, show_tui_cmd,
+ "TUI configuration variables",
+ &tui_showlist, "show tui ",
+ 0/*allow-unknown*/, &showlist);
+
add_com ("refresh", class_tui, _tuiRefreshAll_command,
"Refresh the terminal display.\n");
if (xdb_commands)
/* Define the tui control variables. */
c = add_set_enum_cmd
- ("tui-border-kind", class_tui,
- tui_border_kind_enums, (char*) &tui_border_kind,
+ ("border-kind", no_class,
+ tui_border_kind_enums, &tui_border_kind,
"Set the kind of border for TUI windows.\n"
"This variable controls the border of TUI windows:\n"
"space use a white space\n"
"ascii use ascii characters + - | for the border\n"
"acs use the Alternate Character Set\n",
- &setlist);
- add_show_from_set (c, &showlist);
+ &tui_setlist);
+ add_show_from_set (c, &tui_showlist);
c = add_set_enum_cmd
- ("tui-border-mode", class_tui,
- tui_border_mode_enums, (char*) &tui_border_mode,
+ ("border-mode", no_class,
+ tui_border_mode_enums, &tui_border_mode,
"Set the attribute mode to use for the TUI window borders.\n"
"This variable controls the attributes to use for the window borders:\n"
"normal normal display\n"
"half-standout use half bright and standout mode\n"
"bold use extra bright or bold\n"
"bold-standout use extra bright or bold with standout mode\n",
- &setlist);
- add_show_from_set (c, &showlist);
+ &tui_setlist);
+ add_show_from_set (c, &tui_showlist);
c = add_set_enum_cmd
- ("tui-active-border-mode", class_tui,
- tui_border_mode_enums, (char*) &tui_active_border_mode,
+ ("active-border-mode", no_class,
+ tui_border_mode_enums, &tui_active_border_mode,
"Set the attribute mode to use for the active TUI window border.\n"
"This variable controls the attributes to use for the active window border:\n"
"normal normal display\n"
"half-standout use half bright and standout mode\n"
"bold use extra bright or bold\n"
"bold-standout use extra bright or bold with standout mode\n",
- &setlist);
- add_show_from_set (c, &showlist);
+ &tui_setlist);
+ add_show_from_set (c, &tui_showlist);
}
-
-/*
- ** tuiClearWinFocusFrom
- ** Clear the logical focus from winInfo
- */
+/* Update gdb's knowledge of the terminal size. */
void
-tuiClearWinFocusFrom (TuiWinInfoPtr winInfo)
+tui_update_gdb_sizes ()
{
- if (m_winPtrNotNull (winInfo))
- {
- if (winInfo->generic.type != CMD_WIN)
- unhighlightWin (winInfo);
- tuiSetWinWithFocus ((TuiWinInfoPtr) NULL);
- }
-
- return;
-} /* tuiClearWinFocusFrom */
-
-
-/*
- ** tuiClearWinFocus().
- ** Clear the window that has focus.
- */
-void
-tuiClearWinFocus (void)
-{
- tuiClearWinFocusFrom (tuiWinWithFocus ());
+ char cmd[50];
+ extern int screenheight, screenwidth; /* in readline */
- return;
-} /* tuiClearWinFocus */
+ /* Set to TUI command window dimension or use readline values. */
+ sprintf (cmd, "set width %d",
+ tui_active ? cmdWin->generic.width : screenwidth);
+ execute_command (cmd, 0);
+ sprintf (cmd, "set height %d",
+ tui_active ? cmdWin->generic.height : screenheight);
+ execute_command (cmd, 0);
+}
/*
{
case SRC_WIN:
case DISASSEM_WIN:
- tuiClearWin (&winList[type]->generic);
- if (winList[type]->detail.sourceInfo.hasLocator)
- tuiClearLocatorDisplay ();
tuiShowSourceContent (winList[type]);
checkAndDisplayHighlightIfNeeded (winList[type]);
tuiEraseExecInfoContent (winList[type]);
}
}
}
- tuiClearLocatorDisplay ();
tuiShowLocatorContent ();
-
- return;
-} /* tuiRefreshAll */
+}
/*
TuiWinInfoPtr firstWin, secondWin;
TuiGenWinInfoPtr locator = locatorWinInfoPtr ();
TuiWinType winType;
- int i, newHeight, splitDiff, cmdSplitDiff, numWinsDisplayed = 2;
+ int newHeight, splitDiff, cmdSplitDiff, numWinsDisplayed = 2;
/* turn keypad off while we resize */
if (winWithFocus != cmdWin)
keypad (cmdWin->generic.handle, FALSE);
- init_page_info ();
+ tui_update_gdb_sizes ();
setTermHeightTo (screenheight);
setTermWidthTo (screenwidth);
if (curLayout == SRC_DISASSEM_COMMAND ||
TuiWinInfoPtr winWithFocus = tuiWinWithFocus ();
for (type = SRC_WIN; (type < MAX_MAJOR_WINDOWS); type++)
- if (winList[type]->generic.isVisible)
+ if (winList[type] && winList[type]->generic.isVisible)
{
if (winWithFocus == winList[type])
printf_filtered (" %s\t(%d lines) <has focus>\n",
warning ("Invalid window height specified.\n%s",
WIN_HEIGHT_USAGE);
else
- init_page_info ();
+ tui_update_gdb_sizes ();
}
else
warning ("Invalid window height specified.\n%s",
status = TUI_SUCCESS;
if (newHeight != primaryWinInfo->generic.height)
{
- int i, diff;
+ int diff;
TuiWinInfoPtr winInfo;
TuiGenWinInfoPtr locator = locatorWinInfoPtr ();
TuiLayoutType curLayout = currentLayout ();
_makeInvisibleAndSetNewHeight (TuiWinInfoPtr winInfo, int height)
{
int i;
- struct symtab *s;
TuiGenWinInfoPtr genWinInfo;
default:
break;
}
-
- return;
-} /* _makeInvisibleAndSetNewHeight */
+}
/*
static void
_makeVisibleWithNewHeight (TuiWinInfoPtr winInfo)
{
- int i;
struct symtab *s;
m_beVisible (&winInfo->generic);
if (winInfo->generic.content != (OpaquePtr) NULL)
{
TuiLineOrAddress lineOrAddr;
+ struct symtab_and_line cursal
+ = get_current_source_symtab_and_line ();
if (winInfo->generic.type == SRC_WIN)
lineOrAddr.lineNo =
winInfo->detail.sourceInfo.startLineOrAddr.addr;
freeWinContent (&winInfo->generic);
tuiUpdateSourceWindow (winInfo,
- current_source_symtab, lineOrAddr, TRUE);
+ cursal.symtab, lineOrAddr, TRUE);
}
- else if (selected_frame != (struct frame_info *) NULL)
+ else if (deprecated_selected_frame != (struct frame_info *) NULL)
{
TuiLineOrAddress line;
- extern int current_source_line;
+ struct symtab_and_line cursal = get_current_source_symtab_and_line ();
+
- s = find_pc_symtab (selected_frame->pc);
+ s = find_pc_symtab (deprecated_selected_frame->pc);
if (winInfo->generic.type == SRC_WIN)
- line.lineNo = current_source_line;
+ line.lineNo = cursal.line;
else
{
- find_line_pc (s, current_source_line, &line.addr);
+ find_line_pc (s, cursal.line, &line.addr);
}
tuiUpdateSourceWindow (winInfo, s, line, TRUE);
}
if (m_hasLocator (winInfo))
{
m_beVisible (locatorWinInfoPtr ());
- tuiClearLocatorDisplay ();
tuiShowLocatorContent ();
}
break;
if (ok)
{
- int diff, curHeight;
+ int diff;
TuiLayoutType curLayout = currentLayout ();
diff = (newHeight - primaryWinInfo->generic.height) * (-1);
}
else
{
- int curTotalHeight, totalHeight, minHeight;
+ int curTotalHeight, totalHeight, minHeight = 0;
TuiWinInfoPtr firstWin, secondWin;
if (curLayout == SRC_DISASSEM_COMMAND)
** line that the first and second windows share, and add one
** for the locator.
*/
- curTotalHeight =
+ totalHeight = curTotalHeight =
(firstWin->generic.height + secondWin->generic.height - 1)
+ cmdWin->generic.height + 1 /*locator */ ;
if (primaryWinInfo == cmdWin)