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