2004-02-06 Andrew Cagney <cagney@redhat.com>
[deliverable/binutils-gdb.git] / gdb / tui / tui-windata.c
CommitLineData
f377b406 1/* Data/register window display.
f33c6cbf 2
55fb0713
AC
3 Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software
4 Foundation, Inc.
f33c6cbf 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
96ec9981 25#include "defs.h"
d7b2e967
AC
26#include "tui/tui.h"
27#include "tui/tui-data.h"
28#include "tui/tui-wingeneral.h"
29#include "tui/tui-regs.h"
f33c6cbf 30
4e8f7a8b
DJ
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
c906108c
SS
39
40/*****************************************
41** STATIC LOCAL FUNCTIONS FORWARD DECLS **
42******************************************/
43
44
45
46/*****************************************
47** PUBLIC FUNCTIONS **
48******************************************/
49
50
51/*
c5aa993b
JM
52 ** tuiFirstDataItemDisplayed()
53 ** Answer the index first element displayed.
54 ** If none are displayed, then return (-1).
55 */
c906108c 56int
c906108c 57tuiFirstDataItemDisplayed (void)
c906108c
SS
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/*
c5aa993b
JM
77 ** tuiFirstDataElementNoInLine()
78 ** Answer the index of the first element in lineNo. If lineNo is
79 ** past the data area (-1) is returned.
80 */
c906108c 81int
eca6576c 82tuiFirstDataElementNoInLine (int lineNo)
c906108c
SS
83{
84 int firstElementNo = (-1);
85
86 /*
c5aa993b
JM
87 ** First see if there is a register on lineNo, and if so, set the
88 ** first element number
89 */
55fb0713 90 if ((firstElementNo = tui_first_reg_element_no_inline (lineNo)) == -1)
c906108c 91 { /*
c5aa993b
JM
92 ** Looking at the general data, the 1st element on lineNo
93 */
c906108c
SS
94 }
95
96 return firstElementNo;
97} /* tuiFirstDataElementNoInLine */
98
99
100/*
c5aa993b
JM
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 */
c906108c 105void
c906108c 106tuiDeleteDataContentWindows (void)
c906108c
SS
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;
ec7d9e56 115 tui_delete_win (dataItemWinPtr->handle);
c906108c
SS
116 dataItemWinPtr->handle = (WINDOW *) NULL;
117 dataItemWinPtr->isVisible = FALSE;
118 }
119
120 return;
121} /* tuiDeleteDataContentWindows */
122
123
124void
edae1ccf 125tui_erase_data_content (char *prompt)
c906108c
SS
126{
127 werase (dataWin->generic.handle);
ec7d9e56 128 tui_check_and_display_highlight_if_needed (dataWin);
c906108c
SS
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);
edae1ccf 144}
c906108c
SS
145
146
edae1ccf
AC
147/* This function displays the data that is in the data window's
148 content. It does not set the content. */
c906108c 149void
edae1ccf 150tui_display_all_data (void)
c906108c
SS
151{
152 if (dataWin->generic.contentSize <= 0)
edae1ccf 153 tui_erase_data_content (NO_DATA_STRING);
c906108c
SS
154 else
155 {
edae1ccf 156 tui_erase_data_content ((char *) NULL);
c906108c 157 tuiDeleteDataContentWindows ();
ec7d9e56 158 tui_check_and_display_highlight_if_needed (dataWin);
55fb0713 159 tui_display_registers_from (0);
c906108c 160 /*
c5aa993b
JM
161 ** Then display the other data
162 */
c906108c
SS
163 if (dataWin->detail.dataDisplayInfo.dataContent !=
164 (TuiWinContent) NULL &&
165 dataWin->detail.dataDisplayInfo.dataContentCount > 0)
166 {
167 }
168 }
edae1ccf 169}
c906108c
SS
170
171
172/*
c5aa993b
JM
173 ** tuiDisplayDataFromLine()
174 ** Function to display the data starting at line, lineNo, in the
175 ** data window.
176 */
c906108c 177void
eca6576c 178tuiDisplayDataFromLine (int lineNo)
c906108c
SS
179{
180 int _lineNo = lineNo;
181
182 if (lineNo < 0)
183 _lineNo = 0;
184
ec7d9e56 185 tui_check_and_display_highlight_if_needed (dataWin);
c906108c
SS
186
187 /* there is no general data, force regs to display (if there are any) */
188 if (dataWin->detail.dataDisplayInfo.dataContentCount <= 0)
55fb0713 189 tui_display_registers_from_line (_lineNo, TRUE);
c906108c
SS
190 else
191 {
192 int elementNo, startLineNo;
55fb0713 193 int regsLastLine = tui_last_regs_line_no ();
c906108c
SS
194
195
196 /* display regs if we can */
55fb0713 197 if (tui_display_registers_from_line (_lineNo, FALSE) < 0)
c906108c 198 { /*
c5aa993b
JM
199 ** _lineNo is past the regs display, so calc where the
200 ** start data element is
201 */
c906108c
SS
202 if (regsLastLine < _lineNo)
203 { /* figure out how many lines each element is to obtain
c5aa993b 204 the start elementNo */
c906108c
SS
205 }
206 }
207 else
208 { /*
c5aa993b
JM
209 ** calculate the starting element of the data display, given
210 ** regsLastLine and how many lines each element is, up to
211 ** _lineNo
212 */
c906108c
SS
213 }
214 /* Now display the data , starting at elementNo */
215 }
216
217 return;
218} /* tuiDisplayDataFromLine */
219
220
221/*
c5aa993b
JM
222 ** tuiDisplayDataFrom()
223 ** Display data starting at element elementNo
224 */
c906108c 225void
eca6576c 226tuiDisplayDataFrom (int elementNo, int reuseWindows)
c906108c
SS
227{
228 int firstLine = (-1);
229
230 if (elementNo < dataWin->detail.dataDisplayInfo.regsContentCount)
55fb0713 231 firstLine = tui_line_from_reg_element_no (elementNo);
c906108c
SS
232 else
233 { /* calculate the firstLine from the element number */
234 }
235
236 if (firstLine >= 0)
237 {
edae1ccf 238 tui_erase_data_content ((char *) NULL);
c906108c
SS
239 if (!reuseWindows)
240 tuiDeleteDataContentWindows ();
241 tuiDisplayDataFromLine (firstLine);
242 }
243
244 return;
245} /* tuiDisplayDataFrom */
246
247
edae1ccf 248/* Function to redisplay the contents of the data window. */
c906108c 249void
edae1ccf 250tui_refresh_data_win (void)
c906108c 251{
edae1ccf 252 tui_erase_data_content ((char *) NULL);
c906108c
SS
253 if (dataWin->generic.contentSize > 0)
254 {
255 int firstElement = tuiFirstDataItemDisplayed ();
256
257 if (firstElement >= 0) /* re-use existing windows */
258 tuiDisplayDataFrom (firstElement, TRUE);
259 }
edae1ccf 260}
c906108c
SS
261
262
edae1ccf 263/* Function to check the data values and hilite any that have changed. */
c906108c 264void
edae1ccf 265tui_check_data_values (struct frame_info *frame)
c906108c 266{
55fb0713 267 tui_check_register_values (frame);
c906108c
SS
268
269 /* Now check any other data values that there are */
270 if (m_winPtrNotNull (dataWin) && dataWin->generic.isVisible)
271 {
272 int i;
273
274 for (i = 0; dataWin->detail.dataDisplayInfo.dataContentCount; i++)
275 {
276#ifdef LATER
277 TuiDataElementPtr dataElementPtr;
278 TuiGenWinInfoPtr dataItemWinPtr;
279 Opaque newValue;
280
281 dataItemPtr = &dataWin->detail.dataDisplayInfo.
282 dataContent[i]->whichElement.dataWindow;
283 dataElementPtr = &((TuiWinContent)
284 dataItemWinPtr->content)[0]->whichElement.data;
285 if value
286 has changed (dataElementPtr, frame, &newValue)
287 {
288 dataElementPtr->value = newValue;
289 update the display with the new value, hiliting it.
290 }
291#endif
292 }
293 }
edae1ccf 294}
c906108c
SS
295
296
edae1ccf 297/* Scroll the data window vertically forward or backward. */
c906108c 298void
edae1ccf 299tui_vertical_data_scroll (TuiScrollDirection scrollDirection, int numToScroll)
c906108c
SS
300{
301 int firstElementNo;
302 int firstLine = (-1);
303
304 firstElementNo = tuiFirstDataItemDisplayed ();
305 if (firstElementNo < dataWin->detail.dataDisplayInfo.regsContentCount)
55fb0713 306 firstLine = tui_line_from_reg_element_no (firstElementNo);
c906108c
SS
307 else
308 { /* calculate the first line from the element number which is in
c5aa993b
JM
309 ** the general data content
310 */
c906108c
SS
311 }
312
313 if (firstLine >= 0)
314 {
315 int lastElementNo, lastLine;
316
317 if (scrollDirection == FORWARD_SCROLL)
318 firstLine += numToScroll;
319 else
320 firstLine -= numToScroll;
edae1ccf 321 tui_erase_data_content ((char *) NULL);
c906108c
SS
322 tuiDeleteDataContentWindows ();
323 tuiDisplayDataFromLine (firstLine);
324 }
325
326 return;
327} /* tuiVerticalDataScroll */
328
329
330/*****************************************
331** STATIC LOCAL FUNCTIONS **
332******************************************/
This page took 0.423693 seconds and 4 git commands to generate.