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