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. */
25 #include "tuiGeneralWin.h"
29 /*****************************************
30 ** STATIC LOCAL FUNCTIONS FORWARD DECLS **
31 ******************************************/
35 /*****************************************
36 ** PUBLIC FUNCTIONS **
37 ******************************************/
41 ** tuiFirstDataItemDisplayed()
42 ** Answer the index first element displayed.
43 ** If none are displayed, then return (-1).
46 tuiFirstDataItemDisplayed (void)
51 for (i
= 0; (i
< dataWin
->generic
.contentSize
&& elementNo
< 0); i
++)
53 TuiGenWinInfoPtr dataItemWin
;
55 dataItemWin
= &((TuiWinContent
)
56 dataWin
->generic
.content
)[i
]->whichElement
.dataWindow
;
57 if (dataItemWin
->handle
!= (WINDOW
*) NULL
&& dataItemWin
->isVisible
)
62 } /* tuiFirstDataItemDisplayed */
66 ** tuiFirstDataElementNoInLine()
67 ** Answer the index of the first element in lineNo. If lineNo is
68 ** past the data area (-1) is returned.
71 tuiFirstDataElementNoInLine (int lineNo
)
73 int firstElementNo
= (-1);
76 ** First see if there is a register on lineNo, and if so, set the
77 ** first element number
79 if ((firstElementNo
= tuiFirstRegElementNoInLine (lineNo
)) == -1)
81 ** Looking at the general data, the 1st element on lineNo
85 return firstElementNo
;
86 } /* tuiFirstDataElementNoInLine */
90 ** tuiDeleteDataContentWindows()
91 ** Function to delete all the item windows in the data window.
92 ** This is usually done when the data window is scrolled.
95 tuiDeleteDataContentWindows (void)
98 TuiGenWinInfoPtr dataItemWinPtr
;
100 for (i
= 0; (i
< dataWin
->generic
.contentSize
); i
++)
102 dataItemWinPtr
= &((TuiWinContent
)
103 dataWin
->generic
.content
)[i
]->whichElement
.dataWindow
;
104 tuiDelwin (dataItemWinPtr
->handle
);
105 dataItemWinPtr
->handle
= (WINDOW
*) NULL
;
106 dataItemWinPtr
->isVisible
= FALSE
;
110 } /* tuiDeleteDataContentWindows */
114 tuiEraseDataContent (char *prompt
)
116 werase (dataWin
->generic
.handle
);
117 checkAndDisplayHighlightIfNeeded (dataWin
);
118 if (prompt
!= (char *) NULL
)
120 int halfWidth
= (dataWin
->generic
.width
- 2) / 2;
123 if (strlen (prompt
) >= halfWidth
)
126 xPos
= halfWidth
- strlen (prompt
);
127 mvwaddstr (dataWin
->generic
.handle
,
128 (dataWin
->generic
.height
/ 2),
132 wrefresh (dataWin
->generic
.handle
);
135 } /* tuiEraseDataContent */
139 ** tuiDisplayAllData().
140 ** This function displays the data that is in the data window's
141 ** content. It does not set the content.
144 tuiDisplayAllData (void)
146 if (dataWin
->generic
.contentSize
<= 0)
147 tuiEraseDataContent (NO_DATA_STRING
);
150 tuiEraseDataContent ((char *) NULL
);
151 tuiDeleteDataContentWindows ();
152 checkAndDisplayHighlightIfNeeded (dataWin
);
153 tuiDisplayRegistersFrom (0);
155 ** Then display the other data
157 if (dataWin
->detail
.dataDisplayInfo
.dataContent
!=
158 (TuiWinContent
) NULL
&&
159 dataWin
->detail
.dataDisplayInfo
.dataContentCount
> 0)
164 } /* tuiDisplayAllData */
168 ** tuiDisplayDataFromLine()
169 ** Function to display the data starting at line, lineNo, in the
173 tuiDisplayDataFromLine (int lineNo
)
175 int _lineNo
= lineNo
;
180 checkAndDisplayHighlightIfNeeded (dataWin
);
182 /* there is no general data, force regs to display (if there are any) */
183 if (dataWin
->detail
.dataDisplayInfo
.dataContentCount
<= 0)
184 tuiDisplayRegistersFromLine (_lineNo
, TRUE
);
187 int elementNo
, startLineNo
;
188 int regsLastLine
= tuiLastRegsLineNo ();
191 /* display regs if we can */
192 if (tuiDisplayRegistersFromLine (_lineNo
, FALSE
) < 0)
194 ** _lineNo is past the regs display, so calc where the
195 ** start data element is
197 if (regsLastLine
< _lineNo
)
198 { /* figure out how many lines each element is to obtain
199 the start elementNo */
204 ** calculate the starting element of the data display, given
205 ** regsLastLine and how many lines each element is, up to
209 /* Now display the data , starting at elementNo */
213 } /* tuiDisplayDataFromLine */
217 ** tuiDisplayDataFrom()
218 ** Display data starting at element elementNo
221 tuiDisplayDataFrom (int elementNo
, int reuseWindows
)
223 int firstLine
= (-1);
225 if (elementNo
< dataWin
->detail
.dataDisplayInfo
.regsContentCount
)
226 firstLine
= tuiLineFromRegElementNo (elementNo
);
228 { /* calculate the firstLine from the element number */
233 tuiEraseDataContent ((char *) NULL
);
235 tuiDeleteDataContentWindows ();
236 tuiDisplayDataFromLine (firstLine
);
240 } /* tuiDisplayDataFrom */
244 ** tuiRefreshDataWin()
245 ** Function to redisplay the contents of the data window.
248 tuiRefreshDataWin (void)
250 tuiEraseDataContent ((char *) NULL
);
251 if (dataWin
->generic
.contentSize
> 0)
253 int firstElement
= tuiFirstDataItemDisplayed ();
255 if (firstElement
>= 0) /* re-use existing windows */
256 tuiDisplayDataFrom (firstElement
, TRUE
);
260 } /* tuiRefreshDataWin */
264 ** tuiCheckDataValues().
265 ** Function to check the data values and hilite any that have changed
268 tuiCheckDataValues (struct frame_info
*frame
)
270 tuiCheckRegisterValues (frame
);
272 /* Now check any other data values that there are */
273 if (m_winPtrNotNull (dataWin
) && dataWin
->generic
.isVisible
)
277 for (i
= 0; dataWin
->detail
.dataDisplayInfo
.dataContentCount
; i
++)
280 TuiDataElementPtr dataElementPtr
;
281 TuiGenWinInfoPtr dataItemWinPtr
;
284 dataItemPtr
= &dataWin
->detail
.dataDisplayInfo
.
285 dataContent
[i
]->whichElement
.dataWindow
;
286 dataElementPtr
= &((TuiWinContent
)
287 dataItemWinPtr
->content
)[0]->whichElement
.data
;
289 has
changed (dataElementPtr
, frame
, &newValue
)
291 dataElementPtr
->value
= newValue
;
292 update the display with the
new value
, hiliting it
.
297 } /* tuiCheckDataValues */
301 ** tuiVerticalDataScroll()
302 ** Scroll the data window vertically forward or backward.
305 tuiVerticalDataScroll (TuiScrollDirection scrollDirection
, int numToScroll
)
308 int firstLine
= (-1);
310 firstElementNo
= tuiFirstDataItemDisplayed ();
311 if (firstElementNo
< dataWin
->detail
.dataDisplayInfo
.regsContentCount
)
312 firstLine
= tuiLineFromRegElementNo (firstElementNo
);
314 { /* calculate the first line from the element number which is in
315 ** the general data content
321 int lastElementNo
, lastLine
;
323 if (scrollDirection
== FORWARD_SCROLL
)
324 firstLine
+= numToScroll
;
326 firstLine
-= numToScroll
;
327 tuiEraseDataContent ((char *) NULL
);
328 tuiDeleteDataContentWindows ();
329 tuiDisplayDataFromLine (firstLine
);
333 } /* tuiVerticalDataScroll */
336 /*****************************************
337 ** STATIC LOCAL FUNCTIONS **
338 ******************************************/