1 /* Data/register window display.
3 Copyright 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation,
6 Contributed by Hewlett-Packard Company.
8 This file is part of GDB.
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330,
23 Boston, MA 02111-1307, USA. */
28 #include "tuiGeneralWin.h"
40 /*****************************************
41 ** STATIC LOCAL FUNCTIONS FORWARD DECLS **
42 ******************************************/
46 /*****************************************
47 ** PUBLIC FUNCTIONS **
48 ******************************************/
52 ** tuiFirstDataItemDisplayed()
53 ** Answer the index first element displayed.
54 ** If none are displayed, then return (-1).
57 tuiFirstDataItemDisplayed (void)
62 for (i
= 0; (i
< dataWin
->generic
.contentSize
&& elementNo
< 0); i
++)
64 TuiGenWinInfoPtr dataItemWin
;
66 dataItemWin
= &((TuiWinContent
)
67 dataWin
->generic
.content
)[i
]->whichElement
.dataWindow
;
68 if (dataItemWin
->handle
!= (WINDOW
*) NULL
&& dataItemWin
->isVisible
)
73 } /* tuiFirstDataItemDisplayed */
77 ** tuiFirstDataElementNoInLine()
78 ** Answer the index of the first element in lineNo. If lineNo is
79 ** past the data area (-1) is returned.
82 tuiFirstDataElementNoInLine (int lineNo
)
84 int firstElementNo
= (-1);
87 ** First see if there is a register on lineNo, and if so, set the
88 ** first element number
90 if ((firstElementNo
= tuiFirstRegElementNoInLine (lineNo
)) == -1)
92 ** Looking at the general data, the 1st element on lineNo
96 return firstElementNo
;
97 } /* tuiFirstDataElementNoInLine */
101 ** tuiDeleteDataContentWindows()
102 ** Function to delete all the item windows in the data window.
103 ** This is usually done when the data window is scrolled.
106 tuiDeleteDataContentWindows (void)
109 TuiGenWinInfoPtr dataItemWinPtr
;
111 for (i
= 0; (i
< dataWin
->generic
.contentSize
); i
++)
113 dataItemWinPtr
= &((TuiWinContent
)
114 dataWin
->generic
.content
)[i
]->whichElement
.dataWindow
;
115 tuiDelwin (dataItemWinPtr
->handle
);
116 dataItemWinPtr
->handle
= (WINDOW
*) NULL
;
117 dataItemWinPtr
->isVisible
= FALSE
;
121 } /* tuiDeleteDataContentWindows */
125 tuiEraseDataContent (char *prompt
)
127 werase (dataWin
->generic
.handle
);
128 checkAndDisplayHighlightIfNeeded (dataWin
);
129 if (prompt
!= (char *) NULL
)
131 int halfWidth
= (dataWin
->generic
.width
- 2) / 2;
134 if (strlen (prompt
) >= halfWidth
)
137 xPos
= halfWidth
- strlen (prompt
);
138 mvwaddstr (dataWin
->generic
.handle
,
139 (dataWin
->generic
.height
/ 2),
143 wrefresh (dataWin
->generic
.handle
);
146 } /* tuiEraseDataContent */
150 ** tuiDisplayAllData().
151 ** This function displays the data that is in the data window's
152 ** content. It does not set the content.
155 tuiDisplayAllData (void)
157 if (dataWin
->generic
.contentSize
<= 0)
158 tuiEraseDataContent (NO_DATA_STRING
);
161 tuiEraseDataContent ((char *) NULL
);
162 tuiDeleteDataContentWindows ();
163 checkAndDisplayHighlightIfNeeded (dataWin
);
164 tuiDisplayRegistersFrom (0);
166 ** Then display the other data
168 if (dataWin
->detail
.dataDisplayInfo
.dataContent
!=
169 (TuiWinContent
) NULL
&&
170 dataWin
->detail
.dataDisplayInfo
.dataContentCount
> 0)
175 } /* tuiDisplayAllData */
179 ** tuiDisplayDataFromLine()
180 ** Function to display the data starting at line, lineNo, in the
184 tuiDisplayDataFromLine (int lineNo
)
186 int _lineNo
= lineNo
;
191 checkAndDisplayHighlightIfNeeded (dataWin
);
193 /* there is no general data, force regs to display (if there are any) */
194 if (dataWin
->detail
.dataDisplayInfo
.dataContentCount
<= 0)
195 tuiDisplayRegistersFromLine (_lineNo
, TRUE
);
198 int elementNo
, startLineNo
;
199 int regsLastLine
= tuiLastRegsLineNo ();
202 /* display regs if we can */
203 if (tuiDisplayRegistersFromLine (_lineNo
, FALSE
) < 0)
205 ** _lineNo is past the regs display, so calc where the
206 ** start data element is
208 if (regsLastLine
< _lineNo
)
209 { /* figure out how many lines each element is to obtain
210 the start elementNo */
215 ** calculate the starting element of the data display, given
216 ** regsLastLine and how many lines each element is, up to
220 /* Now display the data , starting at elementNo */
224 } /* tuiDisplayDataFromLine */
228 ** tuiDisplayDataFrom()
229 ** Display data starting at element elementNo
232 tuiDisplayDataFrom (int elementNo
, int reuseWindows
)
234 int firstLine
= (-1);
236 if (elementNo
< dataWin
->detail
.dataDisplayInfo
.regsContentCount
)
237 firstLine
= tuiLineFromRegElementNo (elementNo
);
239 { /* calculate the firstLine from the element number */
244 tuiEraseDataContent ((char *) NULL
);
246 tuiDeleteDataContentWindows ();
247 tuiDisplayDataFromLine (firstLine
);
251 } /* tuiDisplayDataFrom */
255 ** tuiRefreshDataWin()
256 ** Function to redisplay the contents of the data window.
259 tuiRefreshDataWin (void)
261 tuiEraseDataContent ((char *) NULL
);
262 if (dataWin
->generic
.contentSize
> 0)
264 int firstElement
= tuiFirstDataItemDisplayed ();
266 if (firstElement
>= 0) /* re-use existing windows */
267 tuiDisplayDataFrom (firstElement
, TRUE
);
271 } /* tuiRefreshDataWin */
275 ** tuiCheckDataValues().
276 ** Function to check the data values and hilite any that have changed
279 tuiCheckDataValues (struct frame_info
*frame
)
281 tuiCheckRegisterValues (frame
);
283 /* Now check any other data values that there are */
284 if (m_winPtrNotNull (dataWin
) && dataWin
->generic
.isVisible
)
288 for (i
= 0; dataWin
->detail
.dataDisplayInfo
.dataContentCount
; i
++)
291 TuiDataElementPtr dataElementPtr
;
292 TuiGenWinInfoPtr dataItemWinPtr
;
295 dataItemPtr
= &dataWin
->detail
.dataDisplayInfo
.
296 dataContent
[i
]->whichElement
.dataWindow
;
297 dataElementPtr
= &((TuiWinContent
)
298 dataItemWinPtr
->content
)[0]->whichElement
.data
;
300 has
changed (dataElementPtr
, frame
, &newValue
)
302 dataElementPtr
->value
= newValue
;
303 update the display with the
new value
, hiliting it
.
308 } /* tuiCheckDataValues */
312 ** tuiVerticalDataScroll()
313 ** Scroll the data window vertically forward or backward.
316 tuiVerticalDataScroll (TuiScrollDirection scrollDirection
, int numToScroll
)
319 int firstLine
= (-1);
321 firstElementNo
= tuiFirstDataItemDisplayed ();
322 if (firstElementNo
< dataWin
->detail
.dataDisplayInfo
.regsContentCount
)
323 firstLine
= tuiLineFromRegElementNo (firstElementNo
);
325 { /* calculate the first line from the element number which is in
326 ** the general data content
332 int lastElementNo
, lastLine
;
334 if (scrollDirection
== FORWARD_SCROLL
)
335 firstLine
+= numToScroll
;
337 firstLine
-= numToScroll
;
338 tuiEraseDataContent ((char *) NULL
);
339 tuiDeleteDataContentWindows ();
340 tuiDisplayDataFromLine (firstLine
);
344 } /* tuiVerticalDataScroll */
347 /*****************************************
348 ** STATIC LOCAL FUNCTIONS **
349 ******************************************/