* tuiWin.c, tuiWin.h, tui.c, tui.h, tuiCommand.c: Add FSF copyright.
[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 "tuiRegs.h"
26
27
28 /*****************************************
29 ** STATIC LOCAL FUNCTIONS FORWARD DECLS **
30 ******************************************/
31
32
33
34 /*****************************************
35 ** PUBLIC FUNCTIONS **
36 ******************************************/
37
38
39 /*
40 ** tuiFirstDataItemDisplayed()
41 ** Answer the index first element displayed.
42 ** If none are displayed, then return (-1).
43 */
44 int
45 #ifdef __STDC__
46 tuiFirstDataItemDisplayed (void)
47 #else
48 tuiFirstDataItemDisplayed ()
49 #endif
50 {
51 int elementNo = (-1);
52 int i;
53
54 for (i = 0; (i < dataWin->generic.contentSize && elementNo < 0); i++)
55 {
56 TuiGenWinInfoPtr dataItemWin;
57
58 dataItemWin = &((TuiWinContent)
59 dataWin->generic.content)[i]->whichElement.dataWindow;
60 if (dataItemWin->handle != (WINDOW *) NULL && dataItemWin->isVisible)
61 elementNo = i;
62 }
63
64 return elementNo;
65 } /* tuiFirstDataItemDisplayed */
66
67
68 /*
69 ** tuiFirstDataElementNoInLine()
70 ** Answer the index of the first element in lineNo. If lineNo is
71 ** past the data area (-1) is returned.
72 */
73 int
74 #ifdef __STDC__
75 tuiFirstDataElementNoInLine (
76 int lineNo)
77 #else
78 tuiFirstDataElementNoInLine (lineNo)
79 int lineNo;
80 #endif
81 {
82 int firstElementNo = (-1);
83
84 /*
85 ** First see if there is a register on lineNo, and if so, set the
86 ** first element number
87 */
88 if ((firstElementNo = tuiFirstRegElementNoInLine (lineNo)) == -1)
89 { /*
90 ** Looking at the general data, the 1st element on lineNo
91 */
92 }
93
94 return firstElementNo;
95 } /* tuiFirstDataElementNoInLine */
96
97
98 /*
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.
102 */
103 void
104 #ifdef __STDC__
105 tuiDeleteDataContentWindows (void)
106 #else
107 tuiDeleteDataContentWindows ()
108 #endif
109 {
110 int i;
111 TuiGenWinInfoPtr dataItemWinPtr;
112
113 for (i = 0; (i < dataWin->generic.contentSize); i++)
114 {
115 dataItemWinPtr = &((TuiWinContent)
116 dataWin->generic.content)[i]->whichElement.dataWindow;
117 tuiDelwin (dataItemWinPtr->handle);
118 dataItemWinPtr->handle = (WINDOW *) NULL;
119 dataItemWinPtr->isVisible = FALSE;
120 }
121
122 return;
123 } /* tuiDeleteDataContentWindows */
124
125
126 void
127 #ifdef __STDC__
128 tuiEraseDataContent (
129 char *prompt)
130 #else
131 tuiEraseDataContent (prompt)
132 char *prompt;
133 #endif
134 {
135 werase (dataWin->generic.handle);
136 checkAndDisplayHighlightIfNeeded (dataWin);
137 if (prompt != (char *) NULL)
138 {
139 int halfWidth = (dataWin->generic.width - 2) / 2;
140 int xPos;
141
142 if (strlen (prompt) >= halfWidth)
143 xPos = 1;
144 else
145 xPos = halfWidth - strlen (prompt);
146 mvwaddstr (dataWin->generic.handle,
147 (dataWin->generic.height / 2),
148 xPos,
149 prompt);
150 }
151 wrefresh (dataWin->generic.handle);
152
153 return;
154 } /* tuiEraseDataContent */
155
156
157 /*
158 ** tuiDisplayAllData().
159 ** This function displays the data that is in the data window's
160 ** content. It does not set the content.
161 */
162 void
163 #ifdef __STDC__
164 tuiDisplayAllData (void)
165 #else
166 tuiDisplayAllData ()
167 #endif
168 {
169 if (dataWin->generic.contentSize <= 0)
170 tuiEraseDataContent (NO_DATA_STRING);
171 else
172 {
173 tuiEraseDataContent ((char *) NULL);
174 tuiDeleteDataContentWindows ();
175 checkAndDisplayHighlightIfNeeded (dataWin);
176 tuiDisplayRegistersFrom (0);
177 /*
178 ** Then display the other data
179 */
180 if (dataWin->detail.dataDisplayInfo.dataContent !=
181 (TuiWinContent) NULL &&
182 dataWin->detail.dataDisplayInfo.dataContentCount > 0)
183 {
184 }
185 }
186 return;
187 } /* tuiDisplayAllData */
188
189
190 /*
191 ** tuiDisplayDataFromLine()
192 ** Function to display the data starting at line, lineNo, in the
193 ** data window.
194 */
195 void
196 #ifdef __STDC__
197 tuiDisplayDataFromLine (
198 int lineNo)
199 #else
200 tuiDisplayDataFromLine (lineNo)
201 int lineNo;
202 #endif
203 {
204 int _lineNo = lineNo;
205
206 if (lineNo < 0)
207 _lineNo = 0;
208
209 checkAndDisplayHighlightIfNeeded (dataWin);
210
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);
214 else
215 {
216 int elementNo, startLineNo;
217 int regsLastLine = tuiLastRegsLineNo ();
218
219
220 /* display regs if we can */
221 if (tuiDisplayRegistersFromLine (_lineNo, FALSE) < 0)
222 { /*
223 ** _lineNo is past the regs display, so calc where the
224 ** start data element is
225 */
226 if (regsLastLine < _lineNo)
227 { /* figure out how many lines each element is to obtain
228 the start elementNo */
229 }
230 }
231 else
232 { /*
233 ** calculate the starting element of the data display, given
234 ** regsLastLine and how many lines each element is, up to
235 ** _lineNo
236 */
237 }
238 /* Now display the data , starting at elementNo */
239 }
240
241 return;
242 } /* tuiDisplayDataFromLine */
243
244
245 /*
246 ** tuiDisplayDataFrom()
247 ** Display data starting at element elementNo
248 */
249 void
250 #ifdef __STDC__
251 tuiDisplayDataFrom (
252 int elementNo,
253 int reuseWindows)
254 #else
255 tuiDisplayDataFrom (elementNo, reuseWindows)
256 int elementNo;
257 int reuseWindows;
258 #endif
259 {
260 int firstLine = (-1);
261
262 if (elementNo < dataWin->detail.dataDisplayInfo.regsContentCount)
263 firstLine = tuiLineFromRegElementNo (elementNo);
264 else
265 { /* calculate the firstLine from the element number */
266 }
267
268 if (firstLine >= 0)
269 {
270 tuiEraseDataContent ((char *) NULL);
271 if (!reuseWindows)
272 tuiDeleteDataContentWindows ();
273 tuiDisplayDataFromLine (firstLine);
274 }
275
276 return;
277 } /* tuiDisplayDataFrom */
278
279
280 /*
281 ** tuiRefreshDataWin()
282 ** Function to redisplay the contents of the data window.
283 */
284 void
285 #ifdef __STDC__
286 tuiRefreshDataWin (void)
287 #else
288 tuiRefreshDataWin ()
289 #endif
290 {
291 tuiEraseDataContent ((char *) NULL);
292 if (dataWin->generic.contentSize > 0)
293 {
294 int firstElement = tuiFirstDataItemDisplayed ();
295
296 if (firstElement >= 0) /* re-use existing windows */
297 tuiDisplayDataFrom (firstElement, TRUE);
298 }
299
300 return;
301 } /* tuiRefreshDataWin */
302
303
304 /*
305 ** tuiCheckDataValues().
306 ** Function to check the data values and hilite any that have changed
307 */
308 void
309 #ifdef __STDC__
310 tuiCheckDataValues (
311 struct frame_info *frame)
312 #else
313 tuiCheckDataValues (frame)
314 struct frame_info *frame;
315 #endif
316 {
317 tuiCheckRegisterValues (frame);
318
319 /* Now check any other data values that there are */
320 if (m_winPtrNotNull (dataWin) && dataWin->generic.isVisible)
321 {
322 int i;
323
324 for (i = 0; dataWin->detail.dataDisplayInfo.dataContentCount; i++)
325 {
326 #ifdef LATER
327 TuiDataElementPtr dataElementPtr;
328 TuiGenWinInfoPtr dataItemWinPtr;
329 Opaque newValue;
330
331 dataItemPtr = &dataWin->detail.dataDisplayInfo.
332 dataContent[i]->whichElement.dataWindow;
333 dataElementPtr = &((TuiWinContent)
334 dataItemWinPtr->content)[0]->whichElement.data;
335 if value
336 has changed (dataElementPtr, frame, &newValue)
337 {
338 dataElementPtr->value = newValue;
339 update the display with the new value, hiliting it.
340 }
341 #endif
342 }
343 }
344 } /* tuiCheckDataValues */
345
346
347 /*
348 ** tui_vCheckDataValues().
349 ** Function to check the data values and hilite any that have
350 ** changed with args in a va_list
351 */
352 void
353 #ifdef __STDC__
354 tui_vCheckDataValues (
355 va_list args)
356 #else
357 tui_vCheckDataValues (args)
358 va_list args;
359 #endif
360 {
361 struct frame_info *frame = va_arg (args, struct frame_info *);
362
363 tuiCheckDataValues (frame);
364
365 return;
366 } /* tui_vCheckDataValues */
367
368
369 /*
370 ** tuiVerticalDataScroll()
371 ** Scroll the data window vertically forward or backward.
372 */
373 void
374 #ifdef __STDC__
375 tuiVerticalDataScroll (
376 TuiScrollDirection scrollDirection,
377 int numToScroll)
378 #else
379 tuiVerticalDataScroll (scrollDirection, numToScroll)
380 TuiScrollDirection scrollDirection;
381 int numToScroll;
382 #endif
383 {
384 int firstElementNo;
385 int firstLine = (-1);
386
387 firstElementNo = tuiFirstDataItemDisplayed ();
388 if (firstElementNo < dataWin->detail.dataDisplayInfo.regsContentCount)
389 firstLine = tuiLineFromRegElementNo (firstElementNo);
390 else
391 { /* calculate the first line from the element number which is in
392 ** the general data content
393 */
394 }
395
396 if (firstLine >= 0)
397 {
398 int lastElementNo, lastLine;
399
400 if (scrollDirection == FORWARD_SCROLL)
401 firstLine += numToScroll;
402 else
403 firstLine -= numToScroll;
404 tuiEraseDataContent ((char *) NULL);
405 tuiDeleteDataContentWindows ();
406 tuiDisplayDataFromLine (firstLine);
407 }
408
409 return;
410 } /* tuiVerticalDataScroll */
411
412
413 /*****************************************
414 ** STATIC LOCAL FUNCTIONS **
415 ******************************************/
This page took 0.038917 seconds and 5 git commands to generate.