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. */
28 /*****************************************
29 ** STATIC LOCAL FUNCTIONS FORWARD DECLS **
30 ******************************************/
34 /*****************************************
35 ** PUBLIC FUNCTIONS **
36 ******************************************/
40 ** tuiFirstDataItemDisplayed()
41 ** Answer the index first element displayed.
42 ** If none are displayed, then return (-1).
45 tuiFirstDataItemDisplayed (void)
50 for (i = 0; (i < dataWin->generic.contentSize && elementNo < 0); i++)
52 TuiGenWinInfoPtr dataItemWin;
54 dataItemWin = &((TuiWinContent)
55 dataWin->generic.content)[i]->whichElement.dataWindow;
56 if (dataItemWin->handle != (WINDOW *) NULL && dataItemWin->isVisible)
61 } /* tuiFirstDataItemDisplayed */
65 ** tuiFirstDataElementNoInLine()
66 ** Answer the index of the first element in lineNo. If lineNo is
67 ** past the data area (-1) is returned.
70 tuiFirstDataElementNoInLine (int lineNo)
72 int firstElementNo = (-1);
75 ** First see if there is a register on lineNo, and if so, set the
76 ** first element number
78 if ((firstElementNo = tuiFirstRegElementNoInLine (lineNo)) == -1)
80 ** Looking at the general data, the 1st element on lineNo
84 return firstElementNo;
85 } /* tuiFirstDataElementNoInLine */
89 ** tuiDeleteDataContentWindows()
90 ** Function to delete all the item windows in the data window.
91 ** This is usually done when the data window is scrolled.
94 tuiDeleteDataContentWindows (void)
97 TuiGenWinInfoPtr dataItemWinPtr;
99 for (i = 0; (i < dataWin->generic.contentSize); i++)
101 dataItemWinPtr = &((TuiWinContent)
102 dataWin->generic.content)[i]->whichElement.dataWindow;
103 tuiDelwin (dataItemWinPtr->handle);
104 dataItemWinPtr->handle = (WINDOW *) NULL;
105 dataItemWinPtr->isVisible = FALSE;
109 } /* tuiDeleteDataContentWindows */
113 tuiEraseDataContent (char *prompt)
115 werase (dataWin->generic.handle);
116 checkAndDisplayHighlightIfNeeded (dataWin);
117 if (prompt != (char *) NULL)
119 int halfWidth = (dataWin->generic.width - 2) / 2;
122 if (strlen (prompt) >= halfWidth)
125 xPos = halfWidth - strlen (prompt);
126 mvwaddstr (dataWin->generic.handle,
127 (dataWin->generic.height / 2),
131 wrefresh (dataWin->generic.handle);
134 } /* tuiEraseDataContent */
138 ** tuiDisplayAllData().
139 ** This function displays the data that is in the data window's
140 ** content. It does not set the content.
143 tuiDisplayAllData (void)
145 if (dataWin->generic.contentSize <= 0)
146 tuiEraseDataContent (NO_DATA_STRING);
149 tuiEraseDataContent ((char *) NULL);
150 tuiDeleteDataContentWindows ();
151 checkAndDisplayHighlightIfNeeded (dataWin);
152 tuiDisplayRegistersFrom (0);
154 ** Then display the other data
156 if (dataWin->detail.dataDisplayInfo.dataContent !=
157 (TuiWinContent) NULL &&
158 dataWin->detail.dataDisplayInfo.dataContentCount > 0)
163 } /* tuiDisplayAllData */
167 ** tuiDisplayDataFromLine()
168 ** Function to display the data starting at line, lineNo, in the
172 tuiDisplayDataFromLine (int lineNo)
174 int _lineNo = lineNo;
179 checkAndDisplayHighlightIfNeeded (dataWin);
181 /* there is no general data, force regs to display (if there are any) */
182 if (dataWin->detail.dataDisplayInfo.dataContentCount <= 0)
183 tuiDisplayRegistersFromLine (_lineNo, TRUE);
186 int elementNo, startLineNo;
187 int regsLastLine = tuiLastRegsLineNo ();
190 /* display regs if we can */
191 if (tuiDisplayRegistersFromLine (_lineNo, FALSE) < 0)
193 ** _lineNo is past the regs display, so calc where the
194 ** start data element is
196 if (regsLastLine < _lineNo)
197 { /* figure out how many lines each element is to obtain
198 the start elementNo */
203 ** calculate the starting element of the data display, given
204 ** regsLastLine and how many lines each element is, up to
208 /* Now display the data , starting at elementNo */
212 } /* tuiDisplayDataFromLine */
216 ** tuiDisplayDataFrom()
217 ** Display data starting at element elementNo
220 tuiDisplayDataFrom (int elementNo, int reuseWindows)
222 int firstLine = (-1);
224 if (elementNo < dataWin->detail.dataDisplayInfo.regsContentCount)
225 firstLine = tuiLineFromRegElementNo (elementNo);
227 { /* calculate the firstLine from the element number */
232 tuiEraseDataContent ((char *) NULL);
234 tuiDeleteDataContentWindows ();
235 tuiDisplayDataFromLine (firstLine);
239 } /* tuiDisplayDataFrom */
243 ** tuiRefreshDataWin()
244 ** Function to redisplay the contents of the data window.
247 tuiRefreshDataWin (void)
249 tuiEraseDataContent ((char *) NULL);
250 if (dataWin->generic.contentSize > 0)
252 int firstElement = tuiFirstDataItemDisplayed ();
254 if (firstElement >= 0) /* re-use existing windows */
255 tuiDisplayDataFrom (firstElement, TRUE);
259 } /* tuiRefreshDataWin */
263 ** tuiCheckDataValues().
264 ** Function to check the data values and hilite any that have changed
267 tuiCheckDataValues (struct frame_info *frame)
269 tuiCheckRegisterValues (frame);
271 /* Now check any other data values that there are */
272 if (m_winPtrNotNull (dataWin) && dataWin->generic.isVisible)
276 for (i = 0; dataWin->detail.dataDisplayInfo.dataContentCount; i++)
279 TuiDataElementPtr dataElementPtr;
280 TuiGenWinInfoPtr dataItemWinPtr;
283 dataItemPtr = &dataWin->detail.dataDisplayInfo.
284 dataContent[i]->whichElement.dataWindow;
285 dataElementPtr = &((TuiWinContent)
286 dataItemWinPtr->content)[0]->whichElement.data;
288 has changed (dataElementPtr, frame, &newValue)
290 dataElementPtr->value = newValue;
291 update the display with the new value, hiliting it.
296 } /* tuiCheckDataValues */
300 ** tui_vCheckDataValues().
301 ** Function to check the data values and hilite any that have
302 ** changed with args in a va_list
305 tui_vCheckDataValues (va_list args)
307 struct frame_info *frame = va_arg (args, struct frame_info *);
309 tuiCheckDataValues (frame);
312 } /* tui_vCheckDataValues */
316 ** tuiVerticalDataScroll()
317 ** Scroll the data window vertically forward or backward.
320 tuiVerticalDataScroll (TuiScrollDirection scrollDirection, int numToScroll)
323 int firstLine = (-1);
325 firstElementNo = tuiFirstDataItemDisplayed ();
326 if (firstElementNo < dataWin->detail.dataDisplayInfo.regsContentCount)
327 firstLine = tuiLineFromRegElementNo (firstElementNo);
329 { /* calculate the first line from the element number which is in
330 ** the general data content
336 int lastElementNo, lastLine;
338 if (scrollDirection == FORWARD_SCROLL)
339 firstLine += numToScroll;
341 firstLine -= numToScroll;
342 tuiEraseDataContent ((char *) NULL);
343 tuiDeleteDataContentWindows ();
344 tuiDisplayDataFromLine (firstLine);
348 } /* tuiVerticalDataScroll */
351 /*****************************************
352 ** STATIC LOCAL FUNCTIONS **
353 ******************************************/