1 /* Data/register window display.
2 Copyright 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
3 Contributed by Hewlett-Packard Company.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
22 /* If we need <curses.h>, we must include it before we get "bfd.h". */
35 #include "tuiGeneralWin.h"
39 /*****************************************
40 ** STATIC LOCAL FUNCTIONS FORWARD DECLS **
41 ******************************************/
45 /*****************************************
46 ** PUBLIC FUNCTIONS **
47 ******************************************/
51 ** tuiFirstDataItemDisplayed()
52 ** Answer the index first element displayed.
53 ** If none are displayed, then return (-1).
56 tuiFirstDataItemDisplayed (void)
61 for (i = 0; (i < dataWin->generic.contentSize && elementNo < 0); i++)
63 TuiGenWinInfoPtr dataItemWin;
65 dataItemWin = &((TuiWinContent)
66 dataWin->generic.content)[i]->whichElement.dataWindow;
67 if (dataItemWin->handle != (WINDOW *) NULL && dataItemWin->isVisible)
72 } /* tuiFirstDataItemDisplayed */
76 ** tuiFirstDataElementNoInLine()
77 ** Answer the index of the first element in lineNo. If lineNo is
78 ** past the data area (-1) is returned.
81 tuiFirstDataElementNoInLine (int lineNo)
83 int firstElementNo = (-1);
86 ** First see if there is a register on lineNo, and if so, set the
87 ** first element number
89 if ((firstElementNo = tuiFirstRegElementNoInLine (lineNo)) == -1)
91 ** Looking at the general data, the 1st element on lineNo
95 return firstElementNo;
96 } /* tuiFirstDataElementNoInLine */
100 ** tuiDeleteDataContentWindows()
101 ** Function to delete all the item windows in the data window.
102 ** This is usually done when the data window is scrolled.
105 tuiDeleteDataContentWindows (void)
108 TuiGenWinInfoPtr dataItemWinPtr;
110 for (i = 0; (i < dataWin->generic.contentSize); i++)
112 dataItemWinPtr = &((TuiWinContent)
113 dataWin->generic.content)[i]->whichElement.dataWindow;
114 tuiDelwin (dataItemWinPtr->handle);
115 dataItemWinPtr->handle = (WINDOW *) NULL;
116 dataItemWinPtr->isVisible = FALSE;
120 } /* tuiDeleteDataContentWindows */
124 tuiEraseDataContent (char *prompt)
126 werase (dataWin->generic.handle);
127 checkAndDisplayHighlightIfNeeded (dataWin);
128 if (prompt != (char *) NULL)
130 int halfWidth = (dataWin->generic.width - 2) / 2;
133 if (strlen (prompt) >= halfWidth)
136 xPos = halfWidth - strlen (prompt);
137 mvwaddstr (dataWin->generic.handle,
138 (dataWin->generic.height / 2),
142 wrefresh (dataWin->generic.handle);
145 } /* tuiEraseDataContent */
149 ** tuiDisplayAllData().
150 ** This function displays the data that is in the data window's
151 ** content. It does not set the content.
154 tuiDisplayAllData (void)
156 if (dataWin->generic.contentSize <= 0)
157 tuiEraseDataContent (NO_DATA_STRING);
160 tuiEraseDataContent ((char *) NULL);
161 tuiDeleteDataContentWindows ();
162 checkAndDisplayHighlightIfNeeded (dataWin);
163 tuiDisplayRegistersFrom (0);
165 ** Then display the other data
167 if (dataWin->detail.dataDisplayInfo.dataContent !=
168 (TuiWinContent) NULL &&
169 dataWin->detail.dataDisplayInfo.dataContentCount > 0)
174 } /* tuiDisplayAllData */
178 ** tuiDisplayDataFromLine()
179 ** Function to display the data starting at line, lineNo, in the
183 tuiDisplayDataFromLine (int lineNo)
185 int _lineNo = lineNo;
190 checkAndDisplayHighlightIfNeeded (dataWin);
192 /* there is no general data, force regs to display (if there are any) */
193 if (dataWin->detail.dataDisplayInfo.dataContentCount <= 0)
194 tuiDisplayRegistersFromLine (_lineNo, TRUE);
197 int elementNo, startLineNo;
198 int regsLastLine = tuiLastRegsLineNo ();
201 /* display regs if we can */
202 if (tuiDisplayRegistersFromLine (_lineNo, FALSE) < 0)
204 ** _lineNo is past the regs display, so calc where the
205 ** start data element is
207 if (regsLastLine < _lineNo)
208 { /* figure out how many lines each element is to obtain
209 the start elementNo */
214 ** calculate the starting element of the data display, given
215 ** regsLastLine and how many lines each element is, up to
219 /* Now display the data , starting at elementNo */
223 } /* tuiDisplayDataFromLine */
227 ** tuiDisplayDataFrom()
228 ** Display data starting at element elementNo
231 tuiDisplayDataFrom (int elementNo, int reuseWindows)
233 int firstLine = (-1);
235 if (elementNo < dataWin->detail.dataDisplayInfo.regsContentCount)
236 firstLine = tuiLineFromRegElementNo (elementNo);
238 { /* calculate the firstLine from the element number */
243 tuiEraseDataContent ((char *) NULL);
245 tuiDeleteDataContentWindows ();
246 tuiDisplayDataFromLine (firstLine);
250 } /* tuiDisplayDataFrom */
254 ** tuiRefreshDataWin()
255 ** Function to redisplay the contents of the data window.
258 tuiRefreshDataWin (void)
260 tuiEraseDataContent ((char *) NULL);
261 if (dataWin->generic.contentSize > 0)
263 int firstElement = tuiFirstDataItemDisplayed ();
265 if (firstElement >= 0) /* re-use existing windows */
266 tuiDisplayDataFrom (firstElement, TRUE);
270 } /* tuiRefreshDataWin */
274 ** tuiCheckDataValues().
275 ** Function to check the data values and hilite any that have changed
278 tuiCheckDataValues (struct frame_info *frame)
280 tuiCheckRegisterValues (frame);
282 /* Now check any other data values that there are */
283 if (m_winPtrNotNull (dataWin) && dataWin->generic.isVisible)
287 for (i = 0; dataWin->detail.dataDisplayInfo.dataContentCount; i++)
290 TuiDataElementPtr dataElementPtr;
291 TuiGenWinInfoPtr dataItemWinPtr;
294 dataItemPtr = &dataWin->detail.dataDisplayInfo.
295 dataContent[i]->whichElement.dataWindow;
296 dataElementPtr = &((TuiWinContent)
297 dataItemWinPtr->content)[0]->whichElement.data;
299 has changed (dataElementPtr, frame, &newValue)
301 dataElementPtr->value = newValue;
302 update the display with the new value, hiliting it.
307 } /* tuiCheckDataValues */
311 ** tuiVerticalDataScroll()
312 ** Scroll the data window vertically forward or backward.
315 tuiVerticalDataScroll (TuiScrollDirection scrollDirection, int numToScroll)
318 int firstLine = (-1);
320 firstElementNo = tuiFirstDataItemDisplayed ();
321 if (firstElementNo < dataWin->detail.dataDisplayInfo.regsContentCount)
322 firstLine = tuiLineFromRegElementNo (firstElementNo);
324 { /* calculate the first line from the element number which is in
325 ** the general data content
331 int lastElementNo, lastLine;
333 if (scrollDirection == FORWARD_SCROLL)
334 firstLine += numToScroll;
336 firstLine -= numToScroll;
337 tuiEraseDataContent ((char *) NULL);
338 tuiDeleteDataContentWindows ();
339 tuiDisplayDataFromLine (firstLine);
343 } /* tuiVerticalDataScroll */
346 /*****************************************
347 ** STATIC LOCAL FUNCTIONS **
348 ******************************************/