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