1 /* Data/register window display.
3 Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software
6 Contributed by Hewlett-Packard Company.
8 This file is part of GDB.
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.
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.
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. */
27 #include "tui/tui-data.h"
28 #include "tui/tui-wingeneral.h"
29 #include "tui/tui-regs.h"
40 /*****************************************
41 ** STATIC LOCAL FUNCTIONS FORWARD DECLS **
42 ******************************************/
46 /*****************************************
47 ** PUBLIC FUNCTIONS **
48 ******************************************/
52 ** tuiFirstDataItemDisplayed()
53 ** Answer the index first element displayed.
54 ** If none are displayed, then return (-1).
57 tuiFirstDataItemDisplayed (void)
62 for (i = 0; (i < dataWin->generic.contentSize && elementNo < 0); i++)
64 TuiGenWinInfoPtr dataItemWin;
66 dataItemWin = &((TuiWinContent)
67 dataWin->generic.content)[i]->whichElement.dataWindow;
68 if (dataItemWin->handle != (WINDOW *) NULL && dataItemWin->isVisible)
73 } /* tuiFirstDataItemDisplayed */
77 ** tuiFirstDataElementNoInLine()
78 ** Answer the index of the first element in lineNo. If lineNo is
79 ** past the data area (-1) is returned.
82 tuiFirstDataElementNoInLine (int lineNo)
84 int firstElementNo = (-1);
87 ** First see if there is a register on lineNo, and if so, set the
88 ** first element number
90 if ((firstElementNo = tui_first_reg_element_no_inline (lineNo)) == -1)
92 ** Looking at the general data, the 1st element on lineNo
96 return firstElementNo;
97 } /* tuiFirstDataElementNoInLine */
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.
106 tuiDeleteDataContentWindows (void)
109 TuiGenWinInfoPtr dataItemWinPtr;
111 for (i = 0; (i < dataWin->generic.contentSize); i++)
113 dataItemWinPtr = &((TuiWinContent)
114 dataWin->generic.content)[i]->whichElement.dataWindow;
115 tui_delete_win (dataItemWinPtr->handle);
116 dataItemWinPtr->handle = (WINDOW *) NULL;
117 dataItemWinPtr->isVisible = FALSE;
121 } /* tuiDeleteDataContentWindows */
125 tui_erase_data_content (char *prompt)
127 werase (dataWin->generic.handle);
128 tui_check_and_display_highlight_if_needed (dataWin);
129 if (prompt != (char *) NULL)
131 int halfWidth = (dataWin->generic.width - 2) / 2;
134 if (strlen (prompt) >= halfWidth)
137 xPos = halfWidth - strlen (prompt);
138 mvwaddstr (dataWin->generic.handle,
139 (dataWin->generic.height / 2),
143 wrefresh (dataWin->generic.handle);
147 /* This function displays the data that is in the data window's
148 content. It does not set the content. */
150 tui_display_all_data (void)
152 if (dataWin->generic.contentSize <= 0)
153 tui_erase_data_content (NO_DATA_STRING);
156 tui_erase_data_content ((char *) NULL);
157 tuiDeleteDataContentWindows ();
158 tui_check_and_display_highlight_if_needed (dataWin);
159 tui_display_registers_from (0);
161 ** Then display the other data
163 if (dataWin->detail.dataDisplayInfo.dataContent !=
164 (TuiWinContent) NULL &&
165 dataWin->detail.dataDisplayInfo.dataContentCount > 0)
173 ** tuiDisplayDataFromLine()
174 ** Function to display the data starting at line, lineNo, in the
178 tuiDisplayDataFromLine (int lineNo)
180 int _lineNo = lineNo;
185 tui_check_and_display_highlight_if_needed (dataWin);
187 /* there is no general data, force regs to display (if there are any) */
188 if (dataWin->detail.dataDisplayInfo.dataContentCount <= 0)
189 tui_display_registers_from_line (_lineNo, TRUE);
192 int elementNo, startLineNo;
193 int regsLastLine = tui_last_regs_line_no ();
196 /* display regs if we can */
197 if (tui_display_registers_from_line (_lineNo, FALSE) < 0)
199 ** _lineNo is past the regs display, so calc where the
200 ** start data element is
202 if (regsLastLine < _lineNo)
203 { /* figure out how many lines each element is to obtain
204 the start elementNo */
209 ** calculate the starting element of the data display, given
210 ** regsLastLine and how many lines each element is, up to
214 /* Now display the data , starting at elementNo */
218 } /* tuiDisplayDataFromLine */
222 ** tuiDisplayDataFrom()
223 ** Display data starting at element elementNo
226 tuiDisplayDataFrom (int elementNo, int reuseWindows)
228 int firstLine = (-1);
230 if (elementNo < dataWin->detail.dataDisplayInfo.regsContentCount)
231 firstLine = tui_line_from_reg_element_no (elementNo);
233 { /* calculate the firstLine from the element number */
238 tui_erase_data_content ((char *) NULL);
240 tuiDeleteDataContentWindows ();
241 tuiDisplayDataFromLine (firstLine);
245 } /* tuiDisplayDataFrom */
248 /* Function to redisplay the contents of the data window. */
250 tui_refresh_data_win (void)
252 tui_erase_data_content ((char *) NULL);
253 if (dataWin->generic.contentSize > 0)
255 int firstElement = tuiFirstDataItemDisplayed ();
257 if (firstElement >= 0) /* re-use existing windows */
258 tuiDisplayDataFrom (firstElement, TRUE);
263 /* Function to check the data values and hilite any that have changed. */
265 tui_check_data_values (struct frame_info *frame)
267 tui_check_register_values (frame);
269 /* Now check any other data values that there are */
270 if (m_winPtrNotNull (dataWin) && dataWin->generic.isVisible)
274 for (i = 0; dataWin->detail.dataDisplayInfo.dataContentCount; i++)
277 TuiDataElementPtr dataElementPtr;
278 TuiGenWinInfoPtr dataItemWinPtr;
281 dataItemPtr = &dataWin->detail.dataDisplayInfo.
282 dataContent[i]->whichElement.dataWindow;
283 dataElementPtr = &((TuiWinContent)
284 dataItemWinPtr->content)[0]->whichElement.data;
286 has changed (dataElementPtr, frame, &newValue)
288 dataElementPtr->value = newValue;
289 update the display with the new value, hiliting it.
297 /* Scroll the data window vertically forward or backward. */
299 tui_vertical_data_scroll (TuiScrollDirection scrollDirection, int numToScroll)
302 int firstLine = (-1);
304 firstElementNo = tuiFirstDataItemDisplayed ();
305 if (firstElementNo < dataWin->detail.dataDisplayInfo.regsContentCount)
306 firstLine = tui_line_from_reg_element_no (firstElementNo);
308 { /* calculate the first line from the element number which is in
309 ** the general data content
315 int lastElementNo, lastLine;
317 if (scrollDirection == FORWARD_SCROLL)
318 firstLine += numToScroll;
320 firstLine -= numToScroll;
321 tui_erase_data_content ((char *) NULL);
322 tuiDeleteDataContentWindows ();
323 tuiDisplayDataFromLine (firstLine);
327 } /* tuiVerticalDataScroll */
330 /*****************************************
331 ** STATIC LOCAL FUNCTIONS **
332 ******************************************/