* tuiWin.c, tuiWin.h, tui.c, tui.h, tuiCommand.c: Add FSF copyright.
tuiCommand.h, tuiIO.c, tuiIO.h, tuiData.h, tuiData.c: Likewise.
tuiDataWin.c, tuiDataWin.h, tuiDisassem.c, tuiDisassem.h: Likewise.
tuiGeneralWin.c, tuiGeneralWin.h, tuiLayout.c, tuiLayout.h: Likewise.
tuiRegs.c, tuiRegs.h, tuiSource.c, tuiSource.h: Likewise.
tuiSouceWin.c, tuiSourceWin.h, tuiStack.c, tuiStack.h: Likewise.
2001-07-14 21:01:25 +02:00
|
|
|
/* General window behavior.
|
2002-03-01 07:19:28 +01:00
|
|
|
|
|
|
|
Copyright 1998, 1999, 2000, 2001, 2002 Free Software Foundation,
|
|
|
|
Inc.
|
|
|
|
|
* tuiWin.c, tuiWin.h, tui.c, tui.h, tuiCommand.c: Add FSF copyright.
tuiCommand.h, tuiIO.c, tuiIO.h, tuiData.h, tuiData.c: Likewise.
tuiDataWin.c, tuiDataWin.h, tuiDisassem.c, tuiDisassem.h: Likewise.
tuiGeneralWin.c, tuiGeneralWin.h, tuiLayout.c, tuiLayout.h: Likewise.
tuiRegs.c, tuiRegs.h, tuiSource.c, tuiSource.h: Likewise.
tuiSouceWin.c, tuiSourceWin.h, tuiStack.c, tuiStack.h: Likewise.
2001-07-14 21:01:25 +02:00
|
|
|
Contributed by Hewlett-Packard Company.
|
|
|
|
|
|
|
|
This file is part of GDB.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
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. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
2002-03-01 07:19:28 +01:00
|
|
|
/* 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. */
|
|
|
|
|
2002-02-08 16:54:32 +01:00
|
|
|
#include "config.h"
|
|
|
|
#ifdef HAVE_NCURSES_H
|
|
|
|
#include <ncurses.h>
|
|
|
|
#else
|
|
|
|
#ifdef HAVE_CURSES_H
|
|
|
|
#include <curses.h>
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
#include "defs.h"
|
|
|
|
#include "tui.h"
|
|
|
|
#include "tuiData.h"
|
|
|
|
#include "tuiGeneralWin.h"
|
2001-07-21 21:44:38 +02:00
|
|
|
#include "tuiWin.h"
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
/*
|
1999-07-07 22:19:36 +02:00
|
|
|
** local support functions
|
|
|
|
*/
|
2000-05-28 03:12:42 +02:00
|
|
|
static void _winResize (void);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
|
|
/***********************
|
|
|
|
** PUBLIC FUNCTIONS
|
|
|
|
***********************/
|
|
|
|
/*
|
1999-07-07 22:19:36 +02:00
|
|
|
** tuiRefreshWin()
|
|
|
|
** Refresh the window
|
|
|
|
*/
|
1999-04-16 03:35:26 +02:00
|
|
|
void
|
2001-07-14 21:31:09 +02:00
|
|
|
tuiRefreshWin (TuiGenWinInfoPtr winInfo)
|
1999-04-16 03:35:26 +02:00
|
|
|
{
|
|
|
|
if (winInfo->type == DATA_WIN && winInfo->contentSize > 0)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; (i < winInfo->contentSize); i++)
|
|
|
|
{
|
|
|
|
TuiGenWinInfoPtr dataItemWinPtr;
|
|
|
|
|
|
|
|
dataItemWinPtr = &((TuiWinContent)
|
|
|
|
winInfo->content)[i]->whichElement.dataWindow;
|
|
|
|
if (m_genWinPtrNotNull (dataItemWinPtr) &&
|
|
|
|
dataItemWinPtr->handle != (WINDOW *) NULL)
|
|
|
|
wrefresh (dataItemWinPtr->handle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (winInfo->type == CMD_WIN)
|
|
|
|
{
|
|
|
|
/* Do nothing */
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (winInfo->handle != (WINDOW *) NULL)
|
|
|
|
wrefresh (winInfo->handle);
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
} /* tuiRefreshWin */
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
1999-07-07 22:19:36 +02:00
|
|
|
** tuiDelwin()
|
|
|
|
** Function to delete the curses window, checking for null
|
|
|
|
*/
|
1999-04-16 03:35:26 +02:00
|
|
|
void
|
2001-07-14 21:31:09 +02:00
|
|
|
tuiDelwin (WINDOW * window)
|
1999-04-16 03:35:26 +02:00
|
|
|
{
|
|
|
|
if (window != (WINDOW *) NULL)
|
|
|
|
delwin (window);
|
|
|
|
|
|
|
|
return;
|
|
|
|
} /* tuiDelwin */
|
|
|
|
|
|
|
|
|
2001-07-21 21:44:38 +02:00
|
|
|
/* Draw a border arround the window. */
|
1999-04-16 03:35:26 +02:00
|
|
|
void
|
2001-07-14 21:31:09 +02:00
|
|
|
boxWin (TuiGenWinInfoPtr winInfo, int highlightFlag)
|
1999-04-16 03:35:26 +02:00
|
|
|
{
|
2001-07-21 21:44:38 +02:00
|
|
|
if (winInfo && winInfo->handle)
|
1999-04-16 03:35:26 +02:00
|
|
|
{
|
2001-07-21 21:44:38 +02:00
|
|
|
WINDOW *win;
|
|
|
|
int attrs;
|
|
|
|
|
|
|
|
win = winInfo->handle;
|
1999-04-16 03:35:26 +02:00
|
|
|
if (highlightFlag == HILITE)
|
2001-07-21 21:44:38 +02:00
|
|
|
attrs = tui_active_border_attrs;
|
1999-04-16 03:35:26 +02:00
|
|
|
else
|
2001-07-21 21:44:38 +02:00
|
|
|
attrs = tui_border_attrs;
|
|
|
|
|
|
|
|
wattron (win, attrs);
|
|
|
|
wborder (win, tui_border_vline, tui_border_vline,
|
|
|
|
tui_border_hline, tui_border_hline,
|
|
|
|
tui_border_ulcorner, tui_border_urcorner,
|
|
|
|
tui_border_llcorner, tui_border_lrcorner);
|
|
|
|
wattroff (win, attrs);
|
1999-04-16 03:35:26 +02:00
|
|
|
}
|
2001-07-21 21:44:38 +02:00
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
1999-07-07 22:19:36 +02:00
|
|
|
** unhighlightWin().
|
|
|
|
*/
|
1999-04-16 03:35:26 +02:00
|
|
|
void
|
2001-07-14 21:31:09 +02:00
|
|
|
unhighlightWin (TuiWinInfoPtr winInfo)
|
1999-04-16 03:35:26 +02:00
|
|
|
{
|
|
|
|
if (m_winPtrNotNull (winInfo) && winInfo->generic.handle != (WINDOW *) NULL)
|
|
|
|
{
|
|
|
|
boxWin ((TuiGenWinInfoPtr) winInfo, NO_HILITE);
|
|
|
|
wrefresh (winInfo->generic.handle);
|
|
|
|
m_setWinHighlightOff (winInfo);
|
|
|
|
}
|
|
|
|
} /* unhighlightWin */
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
1999-07-07 22:19:36 +02:00
|
|
|
** highlightWin().
|
|
|
|
*/
|
1999-04-16 03:35:26 +02:00
|
|
|
void
|
2001-07-14 21:31:09 +02:00
|
|
|
highlightWin (TuiWinInfoPtr winInfo)
|
1999-04-16 03:35:26 +02:00
|
|
|
{
|
|
|
|
if (m_winPtrNotNull (winInfo) &&
|
|
|
|
winInfo->canHighlight && winInfo->generic.handle != (WINDOW *) NULL)
|
|
|
|
{
|
|
|
|
boxWin ((TuiGenWinInfoPtr) winInfo, HILITE);
|
|
|
|
wrefresh (winInfo->generic.handle);
|
|
|
|
m_setWinHighlightOn (winInfo);
|
|
|
|
}
|
|
|
|
} /* highlightWin */
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
1999-07-07 22:19:36 +02:00
|
|
|
** checkAndDisplayHighlightIfNecessay
|
|
|
|
*/
|
1999-04-16 03:35:26 +02:00
|
|
|
void
|
2001-07-14 21:31:09 +02:00
|
|
|
checkAndDisplayHighlightIfNeeded (TuiWinInfoPtr winInfo)
|
1999-04-16 03:35:26 +02:00
|
|
|
{
|
|
|
|
if (m_winPtrNotNull (winInfo) && winInfo->generic.type != CMD_WIN)
|
|
|
|
{
|
|
|
|
if (winInfo->isHighlighted)
|
|
|
|
highlightWin (winInfo);
|
|
|
|
else
|
|
|
|
unhighlightWin (winInfo);
|
|
|
|
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
} /* checkAndDisplayHighlightIfNeeded */
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
1999-07-07 22:19:36 +02:00
|
|
|
** makeWindow().
|
|
|
|
*/
|
1999-04-16 03:35:26 +02:00
|
|
|
void
|
2001-07-14 21:31:09 +02:00
|
|
|
makeWindow (TuiGenWinInfoPtr winInfo, int boxIt)
|
1999-04-16 03:35:26 +02:00
|
|
|
{
|
|
|
|
WINDOW *handle;
|
|
|
|
|
|
|
|
handle = newwin (winInfo->height,
|
|
|
|
winInfo->width,
|
|
|
|
winInfo->origin.y,
|
|
|
|
winInfo->origin.x);
|
|
|
|
winInfo->handle = handle;
|
|
|
|
if (handle != (WINDOW *) NULL)
|
|
|
|
{
|
|
|
|
if (boxIt == BOX_WINDOW)
|
|
|
|
boxWin (winInfo, NO_HILITE);
|
|
|
|
winInfo->isVisible = TRUE;
|
|
|
|
scrollok (handle, TRUE);
|
|
|
|
tuiRefreshWin (winInfo);
|
|
|
|
|
|
|
|
#ifndef FOR_TEST
|
|
|
|
if ( /*!m_WinIsAuxillary(winInfo->type) && */
|
|
|
|
(winInfo->type != CMD_WIN) &&
|
|
|
|
(winInfo->content == (OpaquePtr) NULL))
|
|
|
|
{
|
|
|
|
mvwaddstr (handle, 1, 1, winName (winInfo));
|
|
|
|
tuiRefreshWin (winInfo);
|
|
|
|
}
|
1999-07-07 22:19:36 +02:00
|
|
|
#endif /*FOR_TEST */
|
1999-04-16 03:35:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
} /* makeWindow */
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
1999-07-07 22:19:36 +02:00
|
|
|
** tuiClearWin().
|
|
|
|
** Clear the window of all contents without calling wclear.
|
|
|
|
*/
|
1999-04-16 03:35:26 +02:00
|
|
|
void
|
2001-07-14 21:31:09 +02:00
|
|
|
tuiClearWin (TuiGenWinInfoPtr winInfo)
|
1999-04-16 03:35:26 +02:00
|
|
|
{
|
|
|
|
if (m_genWinPtrNotNull (winInfo) && winInfo->handle != (WINDOW *) NULL)
|
|
|
|
{
|
|
|
|
int curRow, curCol;
|
|
|
|
|
|
|
|
for (curRow = 0; (curRow < winInfo->height); curRow++)
|
|
|
|
for (curCol = 0; (curCol < winInfo->width); curCol++)
|
|
|
|
mvwaddch (winInfo->handle, curRow, curCol, ' ');
|
|
|
|
|
|
|
|
tuiRefreshWin (winInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
} /* tuiClearWin */
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
1999-07-07 22:19:36 +02:00
|
|
|
** makeVisible().
|
|
|
|
** We can't really make windows visible, or invisible. So we
|
|
|
|
** have to delete the entire window when making it visible,
|
|
|
|
** and create it again when making it visible.
|
|
|
|
*/
|
1999-04-16 03:35:26 +02:00
|
|
|
void
|
2001-07-14 21:31:09 +02:00
|
|
|
makeVisible (TuiGenWinInfoPtr winInfo, int visible)
|
1999-04-16 03:35:26 +02:00
|
|
|
{
|
|
|
|
/* Don't tear down/recreate command window */
|
|
|
|
if (winInfo->type == CMD_WIN)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (visible)
|
|
|
|
{
|
|
|
|
if (!winInfo->isVisible)
|
|
|
|
{
|
|
|
|
makeWindow (
|
|
|
|
winInfo,
|
|
|
|
(winInfo->type != CMD_WIN && !m_winIsAuxillary (winInfo->type)));
|
|
|
|
winInfo->isVisible = TRUE;
|
|
|
|
}
|
|
|
|
tuiRefreshWin (winInfo);
|
|
|
|
}
|
|
|
|
else if (!visible &&
|
|
|
|
winInfo->isVisible && winInfo->handle != (WINDOW *) NULL)
|
|
|
|
{
|
|
|
|
winInfo->isVisible = FALSE;
|
|
|
|
tuiClearWin (winInfo);
|
|
|
|
tuiDelwin (winInfo->handle);
|
|
|
|
winInfo->handle = (WINDOW *) NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
} /* makeVisible */
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
1999-07-07 22:19:36 +02:00
|
|
|
** makeAllVisible().
|
|
|
|
** Makes all windows invisible (except the command and locator windows)
|
|
|
|
*/
|
1999-04-16 03:35:26 +02:00
|
|
|
void
|
2001-07-14 21:31:09 +02:00
|
|
|
makeAllVisible (int visible)
|
1999-04-16 03:35:26 +02:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < MAX_MAJOR_WINDOWS; i++)
|
|
|
|
{
|
|
|
|
if (m_winPtrNotNull (winList[i]) &&
|
|
|
|
((winList[i])->generic.type) != CMD_WIN)
|
|
|
|
{
|
|
|
|
if (m_winIsSourceType ((winList[i])->generic.type))
|
|
|
|
makeVisible ((winList[i])->detail.sourceInfo.executionInfo,
|
|
|
|
visible);
|
|
|
|
makeVisible ((TuiGenWinInfoPtr) winList[i], visible);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
} /* makeAllVisible */
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
1999-07-07 22:19:36 +02:00
|
|
|
** scrollWinForward
|
|
|
|
*/
|
1999-04-16 03:35:26 +02:00
|
|
|
void
|
2001-07-14 21:31:09 +02:00
|
|
|
scrollWinForward (TuiGenWinInfoPtr winInfo, int numLines)
|
1999-04-16 03:35:26 +02:00
|
|
|
{
|
|
|
|
if (winInfo->content != (OpaquePtr) NULL &&
|
|
|
|
winInfo->lastVisibleLine < winInfo->contentSize - 1)
|
|
|
|
{
|
|
|
|
int i, firstLine, newLastLine;
|
|
|
|
|
|
|
|
firstLine = winInfo->lastVisibleLine - winInfo->viewportHeight + 1;
|
|
|
|
if (winInfo->lastVisibleLine + numLines > winInfo->contentSize)
|
|
|
|
newLastLine = winInfo->contentSize - 1;
|
|
|
|
else
|
|
|
|
newLastLine = winInfo->lastVisibleLine + numLines - 1;
|
|
|
|
|
|
|
|
for (i = (newLastLine - winInfo->viewportHeight);
|
|
|
|
(i <= newLastLine); i++)
|
|
|
|
{
|
|
|
|
TuiWinElementPtr line;
|
|
|
|
int lineHeight;
|
|
|
|
|
|
|
|
line = (TuiWinElementPtr) winInfo->content[i];
|
|
|
|
if (line->highlight)
|
|
|
|
wstandout (winInfo->handle);
|
|
|
|
mvwaddstr (winInfo->handle,
|
|
|
|
i - (newLastLine - winInfo->viewportHeight),
|
|
|
|
1,
|
|
|
|
displayableWinContentOf (winInfo, line));
|
|
|
|
if (line->highlight)
|
|
|
|
wstandend (winInfo->handle);
|
|
|
|
lineHeight = winElementHeight (winInfo, line);
|
|
|
|
newLastLine += (lineHeight - 1);
|
|
|
|
}
|
|
|
|
winInfo->lastVisibleLine = newLastLine;
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
} /* scrollWinForward */
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
1999-07-07 22:19:36 +02:00
|
|
|
** scrollWinBackward
|
|
|
|
*/
|
1999-04-16 03:35:26 +02:00
|
|
|
void
|
2001-07-14 21:31:09 +02:00
|
|
|
scrollWinBackward (TuiGenWinInfoPtr winInfo, int numLines)
|
1999-04-16 03:35:26 +02:00
|
|
|
{
|
|
|
|
if (winInfo->content != (OpaquePtr) NULL &&
|
|
|
|
(winInfo->lastVisibleLine - winInfo->viewportHeight) > 0)
|
|
|
|
{
|
|
|
|
int i, newLastLine, firstLine;
|
|
|
|
|
|
|
|
firstLine = winInfo->lastVisibleLine - winInfo->viewportHeight + 1;
|
|
|
|
if ((firstLine - numLines) < 0)
|
|
|
|
newLastLine = winInfo->viewportHeight - 1;
|
|
|
|
else
|
|
|
|
newLastLine = winInfo->lastVisibleLine - numLines + 1;
|
|
|
|
|
|
|
|
for (i = newLastLine - winInfo->viewportHeight; (i <= newLastLine); i++)
|
|
|
|
{
|
|
|
|
TuiWinElementPtr line;
|
|
|
|
int lineHeight;
|
|
|
|
|
|
|
|
line = (TuiWinElementPtr) winInfo->content[i];
|
|
|
|
if (line->highlight)
|
|
|
|
wstandout (winInfo->handle);
|
|
|
|
mvwaddstr (winInfo->handle,
|
|
|
|
i - (newLastLine - winInfo->viewportHeight),
|
|
|
|
1,
|
|
|
|
displayableWinContentOf (winInfo, line));
|
|
|
|
if (line->highlight)
|
|
|
|
wstandend (winInfo->handle);
|
|
|
|
lineHeight = winElementHeight (winInfo, line);
|
|
|
|
newLastLine += (lineHeight - 1);
|
|
|
|
}
|
|
|
|
winInfo->lastVisibleLine = newLastLine;
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
} /* scrollWinBackward */
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
1999-07-07 22:19:36 +02:00
|
|
|
** refreshAll().
|
|
|
|
** Function to refresh all the windows currently displayed
|
|
|
|
*/
|
1999-04-16 03:35:26 +02:00
|
|
|
void
|
2001-07-14 21:31:09 +02:00
|
|
|
refreshAll (TuiWinInfoPtr * list)
|
1999-04-16 03:35:26 +02:00
|
|
|
{
|
|
|
|
TuiWinType type;
|
|
|
|
TuiGenWinInfoPtr locator = locatorWinInfoPtr ();
|
|
|
|
|
|
|
|
for (type = SRC_WIN; (type < MAX_MAJOR_WINDOWS); type++)
|
|
|
|
{
|
2001-07-17 00:13:38 +02:00
|
|
|
if (list[type] && list[type]->generic.isVisible)
|
1999-04-16 03:35:26 +02:00
|
|
|
{
|
|
|
|
if (type == SRC_WIN || type == DISASSEM_WIN)
|
|
|
|
{
|
|
|
|
touchwin (list[type]->detail.sourceInfo.executionInfo->handle);
|
|
|
|
tuiRefreshWin (list[type]->detail.sourceInfo.executionInfo);
|
|
|
|
}
|
|
|
|
touchwin (list[type]->generic.handle);
|
|
|
|
tuiRefreshWin (&list[type]->generic);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (locator->isVisible)
|
|
|
|
{
|
|
|
|
touchwin (locator->handle);
|
|
|
|
tuiRefreshWin (locator);
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
} /* refreshAll */
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************
|
|
|
|
** Local Static Functions
|
|
|
|
*********************************/
|