1 /* Data/register window display.
3 Copyright 1998, 1999, 2000, 2001, 2002 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. */
25 /* FIXME: cagney/2002-02-28: The GDB coding standard indicates that
26 "defs.h" should be included first. Unfortunatly some systems
27 (currently Debian GNU/Linux) include the <stdbool.h> via <curses.h>
28 and they clash with "bfd.h"'s definiton of true/false. The correct
29 fix is to remove true/false from "bfd.h", however, until that
30 happens, hack around it by including "config.h" and <curses.h>
45 #include "tuiGeneralWin.h"
49 /*****************************************
50 ** STATIC LOCAL FUNCTIONS FORWARD DECLS **
51 ******************************************/
55 /*****************************************
56 ** PUBLIC FUNCTIONS **
57 ******************************************/
61 ** tuiFirstDataItemDisplayed()
62 ** Answer the index first element displayed.
63 ** If none are displayed, then return (-1).
66 tuiFirstDataItemDisplayed (void)
71 for (i
= 0; (i
< dataWin
->generic
.contentSize
&& elementNo
< 0); i
++)
73 TuiGenWinInfoPtr dataItemWin
;
75 dataItemWin
= &((TuiWinContent
)
76 dataWin
->generic
.content
)[i
]->whichElement
.dataWindow
;
77 if (dataItemWin
->handle
!= (WINDOW
*) NULL
&& dataItemWin
->isVisible
)
82 } /* tuiFirstDataItemDisplayed */
86 ** tuiFirstDataElementNoInLine()
87 ** Answer the index of the first element in lineNo. If lineNo is
88 ** past the data area (-1) is returned.
91 tuiFirstDataElementNoInLine (int lineNo
)
93 int firstElementNo
= (-1);
96 ** First see if there is a register on lineNo, and if so, set the
97 ** first element number
99 if ((firstElementNo
= tuiFirstRegElementNoInLine (lineNo
)) == -1)
101 ** Looking at the general data, the 1st element on lineNo
105 return firstElementNo
;
106 } /* tuiFirstDataElementNoInLine */
110 ** tuiDeleteDataContentWindows()
111 ** Function to delete all the item windows in the data window.
112 ** This is usually done when the data window is scrolled.
115 tuiDeleteDataContentWindows (void)
118 TuiGenWinInfoPtr dataItemWinPtr
;
120 for (i
= 0; (i
< dataWin
->generic
.contentSize
); i
++)
122 dataItemWinPtr
= &((TuiWinContent
)
123 dataWin
->generic
.content
)[i
]->whichElement
.dataWindow
;
124 tuiDelwin (dataItemWinPtr
->handle
);
125 dataItemWinPtr
->handle
= (WINDOW
*) NULL
;
126 dataItemWinPtr
->isVisible
= FALSE
;
130 } /* tuiDeleteDataContentWindows */
134 tuiEraseDataContent (char *prompt
)
136 werase (dataWin
->generic
.handle
);
137 checkAndDisplayHighlightIfNeeded (dataWin
);
138 if (prompt
!= (char *) NULL
)
140 int halfWidth
= (dataWin
->generic
.width
- 2) / 2;
143 if (strlen (prompt
) >= halfWidth
)
146 xPos
= halfWidth
- strlen (prompt
);
147 mvwaddstr (dataWin
->generic
.handle
,
148 (dataWin
->generic
.height
/ 2),
152 wrefresh (dataWin
->generic
.handle
);
155 } /* tuiEraseDataContent */
159 ** tuiDisplayAllData().
160 ** This function displays the data that is in the data window's
161 ** content. It does not set the content.
164 tuiDisplayAllData (void)
166 if (dataWin
->generic
.contentSize
<= 0)
167 tuiEraseDataContent (NO_DATA_STRING
);
170 tuiEraseDataContent ((char *) NULL
);
171 tuiDeleteDataContentWindows ();
172 checkAndDisplayHighlightIfNeeded (dataWin
);
173 tuiDisplayRegistersFrom (0);
175 ** Then display the other data
177 if (dataWin
->detail
.dataDisplayInfo
.dataContent
!=
178 (TuiWinContent
) NULL
&&
179 dataWin
->detail
.dataDisplayInfo
.dataContentCount
> 0)
184 } /* tuiDisplayAllData */
188 ** tuiDisplayDataFromLine()
189 ** Function to display the data starting at line, lineNo, in the
193 tuiDisplayDataFromLine (int lineNo
)
195 int _lineNo
= lineNo
;
200 checkAndDisplayHighlightIfNeeded (dataWin
);
202 /* there is no general data, force regs to display (if there are any) */
203 if (dataWin
->detail
.dataDisplayInfo
.dataContentCount
<= 0)
204 tuiDisplayRegistersFromLine (_lineNo
, TRUE
);
207 int elementNo
, startLineNo
;
208 int regsLastLine
= tuiLastRegsLineNo ();
211 /* display regs if we can */
212 if (tuiDisplayRegistersFromLine (_lineNo
, FALSE
) < 0)
214 ** _lineNo is past the regs display, so calc where the
215 ** start data element is
217 if (regsLastLine
< _lineNo
)
218 { /* figure out how many lines each element is to obtain
219 the start elementNo */
224 ** calculate the starting element of the data display, given
225 ** regsLastLine and how many lines each element is, up to
229 /* Now display the data , starting at elementNo */
233 } /* tuiDisplayDataFromLine */
237 ** tuiDisplayDataFrom()
238 ** Display data starting at element elementNo
241 tuiDisplayDataFrom (int elementNo
, int reuseWindows
)
243 int firstLine
= (-1);
245 if (elementNo
< dataWin
->detail
.dataDisplayInfo
.regsContentCount
)
246 firstLine
= tuiLineFromRegElementNo (elementNo
);
248 { /* calculate the firstLine from the element number */
253 tuiEraseDataContent ((char *) NULL
);
255 tuiDeleteDataContentWindows ();
256 tuiDisplayDataFromLine (firstLine
);
260 } /* tuiDisplayDataFrom */
264 ** tuiRefreshDataWin()
265 ** Function to redisplay the contents of the data window.
268 tuiRefreshDataWin (void)
270 tuiEraseDataContent ((char *) NULL
);
271 if (dataWin
->generic
.contentSize
> 0)
273 int firstElement
= tuiFirstDataItemDisplayed ();
275 if (firstElement
>= 0) /* re-use existing windows */
276 tuiDisplayDataFrom (firstElement
, TRUE
);
280 } /* tuiRefreshDataWin */
284 ** tuiCheckDataValues().
285 ** Function to check the data values and hilite any that have changed
288 tuiCheckDataValues (struct frame_info
*frame
)
290 tuiCheckRegisterValues (frame
);
292 /* Now check any other data values that there are */
293 if (m_winPtrNotNull (dataWin
) && dataWin
->generic
.isVisible
)
297 for (i
= 0; dataWin
->detail
.dataDisplayInfo
.dataContentCount
; i
++)
300 TuiDataElementPtr dataElementPtr
;
301 TuiGenWinInfoPtr dataItemWinPtr
;
304 dataItemPtr
= &dataWin
->detail
.dataDisplayInfo
.
305 dataContent
[i
]->whichElement
.dataWindow
;
306 dataElementPtr
= &((TuiWinContent
)
307 dataItemWinPtr
->content
)[0]->whichElement
.data
;
309 has
changed (dataElementPtr
, frame
, &newValue
)
311 dataElementPtr
->value
= newValue
;
312 update the display with the
new value
, hiliting it
.
317 } /* tuiCheckDataValues */
321 ** tuiVerticalDataScroll()
322 ** Scroll the data window vertically forward or backward.
325 tuiVerticalDataScroll (TuiScrollDirection scrollDirection
, int numToScroll
)
328 int firstLine
= (-1);
330 firstElementNo
= tuiFirstDataItemDisplayed ();
331 if (firstElementNo
< dataWin
->detail
.dataDisplayInfo
.regsContentCount
)
332 firstLine
= tuiLineFromRegElementNo (firstElementNo
);
334 { /* calculate the first line from the element number which is in
335 ** the general data content
341 int lastElementNo
, lastLine
;
343 if (scrollDirection
== FORWARD_SCROLL
)
344 firstLine
+= numToScroll
;
346 firstLine
-= numToScroll
;
347 tuiEraseDataContent ((char *) NULL
);
348 tuiDeleteDataContentWindows ();
349 tuiDisplayDataFromLine (firstLine
);
353 } /* tuiVerticalDataScroll */
356 /*****************************************
357 ** STATIC LOCAL FUNCTIONS **
358 ******************************************/