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).
46 tuiFirstDataItemDisplayed (void)
48 tuiFirstDataItemDisplayed ()
54 for (i
= 0; (i
< dataWin
->generic
.contentSize
&& elementNo
< 0); i
++)
56 TuiGenWinInfoPtr dataItemWin
;
58 dataItemWin
= &((TuiWinContent
)
59 dataWin
->generic
.content
)[i
]->whichElement
.dataWindow
;
60 if (dataItemWin
->handle
!= (WINDOW
*) NULL
&& dataItemWin
->isVisible
)
65 } /* tuiFirstDataItemDisplayed */
69 ** tuiFirstDataElementNoInLine()
70 ** Answer the index of the first element in lineNo. If lineNo is
71 ** past the data area (-1) is returned.
75 tuiFirstDataElementNoInLine (
78 tuiFirstDataElementNoInLine (lineNo
)
82 int firstElementNo
= (-1);
85 ** First see if there is a register on lineNo, and if so, set the
86 ** first element number
88 if ((firstElementNo
= tuiFirstRegElementNoInLine (lineNo
)) == -1)
90 ** Looking at the general data, the 1st element on lineNo
94 return firstElementNo
;
95 } /* tuiFirstDataElementNoInLine */
99 ** tuiDeleteDataContentWindows()
100 ** Function to delete all the item windows in the data window.
101 ** This is usually done when the data window is scrolled.
105 tuiDeleteDataContentWindows (void)
107 tuiDeleteDataContentWindows ()
111 TuiGenWinInfoPtr dataItemWinPtr
;
113 for (i
= 0; (i
< dataWin
->generic
.contentSize
); i
++)
115 dataItemWinPtr
= &((TuiWinContent
)
116 dataWin
->generic
.content
)[i
]->whichElement
.dataWindow
;
117 tuiDelwin (dataItemWinPtr
->handle
);
118 dataItemWinPtr
->handle
= (WINDOW
*) NULL
;
119 dataItemWinPtr
->isVisible
= FALSE
;
123 } /* tuiDeleteDataContentWindows */
128 tuiEraseDataContent (
131 tuiEraseDataContent (prompt
)
135 werase (dataWin
->generic
.handle
);
136 checkAndDisplayHighlightIfNeeded (dataWin
);
137 if (prompt
!= (char *) NULL
)
139 int halfWidth
= (dataWin
->generic
.width
- 2) / 2;
142 if (strlen (prompt
) >= halfWidth
)
145 xPos
= halfWidth
- strlen (prompt
);
146 mvwaddstr (dataWin
->generic
.handle
,
147 (dataWin
->generic
.height
/ 2),
151 wrefresh (dataWin
->generic
.handle
);
154 } /* tuiEraseDataContent */
158 ** tuiDisplayAllData().
159 ** This function displays the data that is in the data window's
160 ** content. It does not set the content.
164 tuiDisplayAllData (void)
169 if (dataWin
->generic
.contentSize
<= 0)
170 tuiEraseDataContent (NO_DATA_STRING
);
173 tuiEraseDataContent ((char *) NULL
);
174 tuiDeleteDataContentWindows ();
175 checkAndDisplayHighlightIfNeeded (dataWin
);
176 tuiDisplayRegistersFrom (0);
178 ** Then display the other data
180 if (dataWin
->detail
.dataDisplayInfo
.dataContent
!=
181 (TuiWinContent
) NULL
&&
182 dataWin
->detail
.dataDisplayInfo
.dataContentCount
> 0)
187 } /* tuiDisplayAllData */
191 ** tuiDisplayDataFromLine()
192 ** Function to display the data starting at line, lineNo, in the
197 tuiDisplayDataFromLine (
200 tuiDisplayDataFromLine (lineNo
)
204 int _lineNo
= lineNo
;
209 checkAndDisplayHighlightIfNeeded (dataWin
);
211 /* there is no general data, force regs to display (if there are any) */
212 if (dataWin
->detail
.dataDisplayInfo
.dataContentCount
<= 0)
213 tuiDisplayRegistersFromLine (_lineNo
, TRUE
);
216 int elementNo
, startLineNo
;
217 int regsLastLine
= tuiLastRegsLineNo ();
220 /* display regs if we can */
221 if (tuiDisplayRegistersFromLine (_lineNo
, FALSE
) < 0)
223 ** _lineNo is past the regs display, so calc where the
224 ** start data element is
226 if (regsLastLine
< _lineNo
)
227 { /* figure out how many lines each element is to obtain
228 the start elementNo */
233 ** calculate the starting element of the data display, given
234 ** regsLastLine and how many lines each element is, up to
238 /* Now display the data , starting at elementNo */
242 } /* tuiDisplayDataFromLine */
246 ** tuiDisplayDataFrom()
247 ** Display data starting at element elementNo
255 tuiDisplayDataFrom (elementNo
, reuseWindows
)
260 int firstLine
= (-1);
262 if (elementNo
< dataWin
->detail
.dataDisplayInfo
.regsContentCount
)
263 firstLine
= tuiLineFromRegElementNo (elementNo
);
265 { /* calculate the firstLine from the element number */
270 tuiEraseDataContent ((char *) NULL
);
272 tuiDeleteDataContentWindows ();
273 tuiDisplayDataFromLine (firstLine
);
277 } /* tuiDisplayDataFrom */
281 ** tuiRefreshDataWin()
282 ** Function to redisplay the contents of the data window.
286 tuiRefreshDataWin (void)
291 tuiEraseDataContent ((char *) NULL
);
292 if (dataWin
->generic
.contentSize
> 0)
294 int firstElement
= tuiFirstDataItemDisplayed ();
296 if (firstElement
>= 0) /* re-use existing windows */
297 tuiDisplayDataFrom (firstElement
, TRUE
);
301 } /* tuiRefreshDataWin */
305 ** tuiCheckDataValues().
306 ** Function to check the data values and hilite any that have changed
311 struct frame_info
*frame
)
313 tuiCheckDataValues (frame
)
314 struct frame_info
*frame
;
317 tuiCheckRegisterValues (frame
);
319 /* Now check any other data values that there are */
320 if (m_winPtrNotNull (dataWin
) && dataWin
->generic
.isVisible
)
324 for (i
= 0; dataWin
->detail
.dataDisplayInfo
.dataContentCount
; i
++)
327 TuiDataElementPtr dataElementPtr
;
328 TuiGenWinInfoPtr dataItemWinPtr
;
331 dataItemPtr
= &dataWin
->detail
.dataDisplayInfo
.
332 dataContent
[i
]->whichElement
.dataWindow
;
333 dataElementPtr
= &((TuiWinContent
)
334 dataItemWinPtr
->content
)[0]->whichElement
.data
;
336 has
changed (dataElementPtr
, frame
, &newValue
)
338 dataElementPtr
->value
= newValue
;
339 update the display with the
new value
, hiliting it
.
344 } /* tuiCheckDataValues */
348 ** tui_vCheckDataValues().
349 ** Function to check the data values and hilite any that have
350 ** changed with args in a va_list
354 tui_vCheckDataValues (
357 tui_vCheckDataValues (args
)
361 struct frame_info
*frame
= va_arg (args
, struct frame_info
*);
363 tuiCheckDataValues (frame
);
366 } /* tui_vCheckDataValues */
370 ** tuiVerticalDataScroll()
371 ** Scroll the data window vertically forward or backward.
375 tuiVerticalDataScroll (
376 TuiScrollDirection scrollDirection
,
379 tuiVerticalDataScroll (scrollDirection
, numToScroll
)
380 TuiScrollDirection scrollDirection
;
385 int firstLine
= (-1);
387 firstElementNo
= tuiFirstDataItemDisplayed ();
388 if (firstElementNo
< dataWin
->detail
.dataDisplayInfo
.regsContentCount
)
389 firstLine
= tuiLineFromRegElementNo (firstElementNo
);
391 { /* calculate the first line from the element number which is in
392 ** the general data content
398 int lastElementNo
, lastLine
;
400 if (scrollDirection
== FORWARD_SCROLL
)
401 firstLine
+= numToScroll
;
403 firstLine
-= numToScroll
;
404 tuiEraseDataContent ((char *) NULL
);
405 tuiDeleteDataContentWindows ();
406 tuiDisplayDataFromLine (firstLine
);
410 } /* tuiVerticalDataScroll */
413 /*****************************************
414 ** STATIC LOCAL FUNCTIONS **
415 ******************************************/