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