Replace CONST with const
[deliverable/binutils-gdb.git] / gdb / tui / tuiDataWin.c
1 /* Data/register window display.
2 Copyright 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
3 Contributed by Hewlett-Packard Company.
4
5 This file is part of GDB.
6
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.
11
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.
16
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. */
21
22 #include "defs.h"
23 #include "tui.h"
24 #include "tuiData.h"
25 #include "tuiGeneralWin.h"
26 #include "tuiRegs.h"
27
28
29 /*****************************************
30 ** STATIC LOCAL FUNCTIONS FORWARD DECLS **
31 ******************************************/
32
33
34
35 /*****************************************
36 ** PUBLIC FUNCTIONS **
37 ******************************************/
38
39
40 /*
41 ** tuiFirstDataItemDisplayed()
42 ** Answer the index first element displayed.
43 ** If none are displayed, then return (-1).
44 */
45 int
46 tuiFirstDataItemDisplayed (void)
47 {
48 int elementNo = (-1);
49 int i;
50
51 for (i = 0; (i < dataWin->generic.contentSize && elementNo < 0); i++)
52 {
53 TuiGenWinInfoPtr dataItemWin;
54
55 dataItemWin = &((TuiWinContent)
56 dataWin->generic.content)[i]->whichElement.dataWindow;
57 if (dataItemWin->handle != (WINDOW *) NULL && dataItemWin->isVisible)
58 elementNo = i;
59 }
60
61 return elementNo;
62 } /* tuiFirstDataItemDisplayed */
63
64
65 /*
66 ** tuiFirstDataElementNoInLine()
67 ** Answer the index of the first element in lineNo. If lineNo is
68 ** past the data area (-1) is returned.
69 */
70 int
71 tuiFirstDataElementNoInLine (int lineNo)
72 {
73 int firstElementNo = (-1);
74
75 /*
76 ** First see if there is a register on lineNo, and if so, set the
77 ** first element number
78 */
79 if ((firstElementNo = tuiFirstRegElementNoInLine (lineNo)) == -1)
80 { /*
81 ** Looking at the general data, the 1st element on lineNo
82 */
83 }
84
85 return firstElementNo;
86 } /* tuiFirstDataElementNoInLine */
87
88
89 /*
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.
93 */
94 void
95 tuiDeleteDataContentWindows (void)
96 {
97 int i;
98 TuiGenWinInfoPtr dataItemWinPtr;
99
100 for (i = 0; (i < dataWin->generic.contentSize); i++)
101 {
102 dataItemWinPtr = &((TuiWinContent)
103 dataWin->generic.content)[i]->whichElement.dataWindow;
104 tuiDelwin (dataItemWinPtr->handle);
105 dataItemWinPtr->handle = (WINDOW *) NULL;
106 dataItemWinPtr->isVisible = FALSE;
107 }
108
109 return;
110 } /* tuiDeleteDataContentWindows */
111
112
113 void
114 tuiEraseDataContent (char *prompt)
115 {
116 werase (dataWin->generic.handle);
117 checkAndDisplayHighlightIfNeeded (dataWin);
118 if (prompt != (char *) NULL)
119 {
120 int halfWidth = (dataWin->generic.width - 2) / 2;
121 int xPos;
122
123 if (strlen (prompt) >= halfWidth)
124 xPos = 1;
125 else
126 xPos = halfWidth - strlen (prompt);
127 mvwaddstr (dataWin->generic.handle,
128 (dataWin->generic.height / 2),
129 xPos,
130 prompt);
131 }
132 wrefresh (dataWin->generic.handle);
133
134 return;
135 } /* tuiEraseDataContent */
136
137
138 /*
139 ** tuiDisplayAllData().
140 ** This function displays the data that is in the data window's
141 ** content. It does not set the content.
142 */
143 void
144 tuiDisplayAllData (void)
145 {
146 if (dataWin->generic.contentSize <= 0)
147 tuiEraseDataContent (NO_DATA_STRING);
148 else
149 {
150 tuiEraseDataContent ((char *) NULL);
151 tuiDeleteDataContentWindows ();
152 checkAndDisplayHighlightIfNeeded (dataWin);
153 tuiDisplayRegistersFrom (0);
154 /*
155 ** Then display the other data
156 */
157 if (dataWin->detail.dataDisplayInfo.dataContent !=
158 (TuiWinContent) NULL &&
159 dataWin->detail.dataDisplayInfo.dataContentCount > 0)
160 {
161 }
162 }
163 return;
164 } /* tuiDisplayAllData */
165
166
167 /*
168 ** tuiDisplayDataFromLine()
169 ** Function to display the data starting at line, lineNo, in the
170 ** data window.
171 */
172 void
173 tuiDisplayDataFromLine (int lineNo)
174 {
175 int _lineNo = lineNo;
176
177 if (lineNo < 0)
178 _lineNo = 0;
179
180 checkAndDisplayHighlightIfNeeded (dataWin);
181
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);
185 else
186 {
187 int elementNo, startLineNo;
188 int regsLastLine = tuiLastRegsLineNo ();
189
190
191 /* display regs if we can */
192 if (tuiDisplayRegistersFromLine (_lineNo, FALSE) < 0)
193 { /*
194 ** _lineNo is past the regs display, so calc where the
195 ** start data element is
196 */
197 if (regsLastLine < _lineNo)
198 { /* figure out how many lines each element is to obtain
199 the start elementNo */
200 }
201 }
202 else
203 { /*
204 ** calculate the starting element of the data display, given
205 ** regsLastLine and how many lines each element is, up to
206 ** _lineNo
207 */
208 }
209 /* Now display the data , starting at elementNo */
210 }
211
212 return;
213 } /* tuiDisplayDataFromLine */
214
215
216 /*
217 ** tuiDisplayDataFrom()
218 ** Display data starting at element elementNo
219 */
220 void
221 tuiDisplayDataFrom (int elementNo, int reuseWindows)
222 {
223 int firstLine = (-1);
224
225 if (elementNo < dataWin->detail.dataDisplayInfo.regsContentCount)
226 firstLine = tuiLineFromRegElementNo (elementNo);
227 else
228 { /* calculate the firstLine from the element number */
229 }
230
231 if (firstLine >= 0)
232 {
233 tuiEraseDataContent ((char *) NULL);
234 if (!reuseWindows)
235 tuiDeleteDataContentWindows ();
236 tuiDisplayDataFromLine (firstLine);
237 }
238
239 return;
240 } /* tuiDisplayDataFrom */
241
242
243 /*
244 ** tuiRefreshDataWin()
245 ** Function to redisplay the contents of the data window.
246 */
247 void
248 tuiRefreshDataWin (void)
249 {
250 tuiEraseDataContent ((char *) NULL);
251 if (dataWin->generic.contentSize > 0)
252 {
253 int firstElement = tuiFirstDataItemDisplayed ();
254
255 if (firstElement >= 0) /* re-use existing windows */
256 tuiDisplayDataFrom (firstElement, TRUE);
257 }
258
259 return;
260 } /* tuiRefreshDataWin */
261
262
263 /*
264 ** tuiCheckDataValues().
265 ** Function to check the data values and hilite any that have changed
266 */
267 void
268 tuiCheckDataValues (struct frame_info *frame)
269 {
270 tuiCheckRegisterValues (frame);
271
272 /* Now check any other data values that there are */
273 if (m_winPtrNotNull (dataWin) && dataWin->generic.isVisible)
274 {
275 int i;
276
277 for (i = 0; dataWin->detail.dataDisplayInfo.dataContentCount; i++)
278 {
279 #ifdef LATER
280 TuiDataElementPtr dataElementPtr;
281 TuiGenWinInfoPtr dataItemWinPtr;
282 Opaque newValue;
283
284 dataItemPtr = &dataWin->detail.dataDisplayInfo.
285 dataContent[i]->whichElement.dataWindow;
286 dataElementPtr = &((TuiWinContent)
287 dataItemWinPtr->content)[0]->whichElement.data;
288 if value
289 has changed (dataElementPtr, frame, &newValue)
290 {
291 dataElementPtr->value = newValue;
292 update the display with the new value, hiliting it.
293 }
294 #endif
295 }
296 }
297 } /* tuiCheckDataValues */
298
299
300 /*
301 ** tuiVerticalDataScroll()
302 ** Scroll the data window vertically forward or backward.
303 */
304 void
305 tuiVerticalDataScroll (TuiScrollDirection scrollDirection, int numToScroll)
306 {
307 int firstElementNo;
308 int firstLine = (-1);
309
310 firstElementNo = tuiFirstDataItemDisplayed ();
311 if (firstElementNo < dataWin->detail.dataDisplayInfo.regsContentCount)
312 firstLine = tuiLineFromRegElementNo (firstElementNo);
313 else
314 { /* calculate the first line from the element number which is in
315 ** the general data content
316 */
317 }
318
319 if (firstLine >= 0)
320 {
321 int lastElementNo, lastLine;
322
323 if (scrollDirection == FORWARD_SCROLL)
324 firstLine += numToScroll;
325 else
326 firstLine -= numToScroll;
327 tuiEraseDataContent ((char *) NULL);
328 tuiDeleteDataContentWindows ();
329 tuiDisplayDataFromLine (firstLine);
330 }
331
332 return;
333 } /* tuiVerticalDataScroll */
334
335
336 /*****************************************
337 ** STATIC LOCAL FUNCTIONS **
338 ******************************************/
This page took 0.037342 seconds and 4 git commands to generate.