]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/tui/tui-windata.c
2007-08-14 Michael Snyder <msnyder@access-company.com>
[thirdparty/binutils-gdb.git] / gdb / tui / tui-windata.c
1 /* Data/register window display.
2
3 Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2007
4 Free Software 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., 51 Franklin Street, Fifth Floor,
23 Boston, MA 02110-1301, 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 #include "gdb_string.h"
32 #include "gdb_curses.h"
33
34
35 /*****************************************
36 ** STATIC LOCAL FUNCTIONS FORWARD DECLS **
37 ******************************************/
38
39
40
41 /*****************************************
42 ** PUBLIC FUNCTIONS **
43 ******************************************/
44
45
46 /* Answer the index first element displayed. If none are displayed,
47 then return (-1). */
48 int
49 tui_first_data_item_displayed (void)
50 {
51 int element_no = (-1);
52 int i;
53
54 for (i = 0; (i < TUI_DATA_WIN->generic.content_size && element_no < 0); i++)
55 {
56 struct tui_gen_win_info *data_item_win;
57
58 data_item_win = &((tui_win_content)
59 TUI_DATA_WIN->generic.content)[i]->which_element.data_window;
60 if (data_item_win->handle != (WINDOW *) NULL && data_item_win->is_visible)
61 element_no = i;
62 }
63
64 return element_no;
65 }
66
67
68 /* Answer the index of the first element in line_no. If line_no is
69 past the data area (-1) is returned. */
70 int
71 tui_first_data_element_no_in_line (int line_no)
72 {
73 int first_element_no = (-1);
74
75 /* First see if there is a register on line_no, and if so, set the
76 first element number. */
77 if ((first_element_no = tui_first_reg_element_no_inline (line_no)) == -1)
78 { /* Looking at the general data, the 1st element on line_no. */
79 }
80
81 return first_element_no;
82 }
83
84
85 /* Function to delete all the item windows in the data window. This
86 is usually done when the data window is scrolled. */
87 void
88 tui_delete_data_content_windows (void)
89 {
90 int i;
91 struct tui_gen_win_info *data_item_win_ptr;
92
93 for (i = 0; (i < TUI_DATA_WIN->generic.content_size); i++)
94 {
95 data_item_win_ptr = &((tui_win_content)
96 TUI_DATA_WIN->generic.content)[i]->which_element.data_window;
97 tui_delete_win (data_item_win_ptr->handle);
98 data_item_win_ptr->handle = (WINDOW *) NULL;
99 data_item_win_ptr->is_visible = FALSE;
100 }
101 }
102
103
104 void
105 tui_erase_data_content (char *prompt)
106 {
107 werase (TUI_DATA_WIN->generic.handle);
108 tui_check_and_display_highlight_if_needed (TUI_DATA_WIN);
109 if (prompt != (char *) NULL)
110 {
111 int half_width = (TUI_DATA_WIN->generic.width - 2) / 2;
112 int x_pos;
113
114 if (strlen (prompt) >= half_width)
115 x_pos = 1;
116 else
117 x_pos = half_width - strlen (prompt);
118 mvwaddstr (TUI_DATA_WIN->generic.handle,
119 (TUI_DATA_WIN->generic.height / 2),
120 x_pos,
121 prompt);
122 }
123 wrefresh (TUI_DATA_WIN->generic.handle);
124 }
125
126
127 /* This function displays the data that is in the data window's
128 content. It does not set the content. */
129 void
130 tui_display_all_data (void)
131 {
132 if (TUI_DATA_WIN->generic.content_size <= 0)
133 tui_erase_data_content (NO_DATA_STRING);
134 else
135 {
136 tui_erase_data_content ((char *) NULL);
137 tui_delete_data_content_windows ();
138 tui_check_and_display_highlight_if_needed (TUI_DATA_WIN);
139 tui_display_registers_from (0);
140
141 /* Then display the other data. */
142 if (TUI_DATA_WIN->detail.data_display_info.data_content !=
143 (tui_win_content) NULL &&
144 TUI_DATA_WIN->detail.data_display_info.data_content_count > 0)
145 {
146 }
147 }
148 }
149
150
151 /* Function to display the data starting at line, line_no, in the data
152 window. */
153 void
154 tui_display_data_from_line (int line_no)
155 {
156 int _line_no = line_no;
157
158 if (line_no < 0)
159 _line_no = 0;
160
161 tui_check_and_display_highlight_if_needed (TUI_DATA_WIN);
162
163 /* There is no general data, force regs to display (if there are
164 any). */
165 if (TUI_DATA_WIN->detail.data_display_info.data_content_count <= 0)
166 tui_display_registers_from_line (_line_no, TRUE);
167 else
168 {
169 int element_no, start_line_no;
170 int regs_last_line = tui_last_regs_line_no ();
171
172
173 /* Display regs if we can. */
174 if (tui_display_registers_from_line (_line_no, FALSE) < 0)
175 { /* _line_no is past the regs display, so calc where the
176 start data element is. */
177 if (regs_last_line < _line_no)
178 { /* Figure out how many lines each element is to obtain
179 the start element_no. */
180 }
181 }
182 else
183 { /* Calculate the starting element of the data display, given
184 regs_last_line and how many lines each element is, up to
185 _line_no. */
186 }
187 /* Now display the data , starting at element_no. */
188 }
189 }
190
191
192 /* Display data starting at element element_no. */
193 void
194 tui_display_data_from (int element_no, int reuse_windows)
195 {
196 int first_line = (-1);
197
198 if (element_no < TUI_DATA_WIN->detail.data_display_info.regs_content_count)
199 first_line = tui_line_from_reg_element_no (element_no);
200 else
201 { /* Calculate the first_line from the element number. */
202 }
203
204 if (first_line >= 0)
205 {
206 tui_erase_data_content ((char *) NULL);
207 if (!reuse_windows)
208 tui_delete_data_content_windows ();
209 tui_display_data_from_line (first_line);
210 }
211 }
212
213
214 /* Function to redisplay the contents of the data window. */
215 void
216 tui_refresh_data_win (void)
217 {
218 tui_erase_data_content ((char *) NULL);
219 if (TUI_DATA_WIN->generic.content_size > 0)
220 {
221 int first_element = tui_first_data_item_displayed ();
222
223 if (first_element >= 0) /* Re-use existing windows. */
224 tui_display_data_from (first_element, TRUE);
225 }
226 }
227
228
229 /* Function to check the data values and hilite any that have
230 changed. */
231 void
232 tui_check_data_values (struct frame_info *frame)
233 {
234 tui_check_register_values (frame);
235
236 /* Now check any other data values that there are. */
237 if (TUI_DATA_WIN != NULL && TUI_DATA_WIN->generic.is_visible)
238 {
239 int i;
240
241 for (i = 0; TUI_DATA_WIN->detail.data_display_info.data_content_count; i++)
242 {
243 #ifdef LATER
244 tui_data_element_ptr data_element_ptr;
245 struct tui_gen_win_info *data_item_win_ptr;
246 Opaque new_value;
247
248 data_item_ptr = &TUI_DATA_WIN->detail.data_display_info.
249 data_content[i]->which_element.data_window;
250 data_element_ptr = &((tui_win_content)
251 data_item_win_ptr->content)[0]->which_element.data;
252 if value
253 has changed (data_element_ptr, frame, &new_value)
254 {
255 data_element_ptr->value = new_value;
256 update the display with the new value, hiliting it.
257 }
258 #endif
259 }
260 }
261 }
262
263
264 /* Scroll the data window vertically forward or backward. */
265 void
266 tui_vertical_data_scroll (enum tui_scroll_direction scroll_direction,
267 int num_to_scroll)
268 {
269 int first_element_no;
270 int first_line = (-1);
271
272 first_element_no = tui_first_data_item_displayed ();
273 if (first_element_no < TUI_DATA_WIN->detail.data_display_info.regs_content_count)
274 first_line = tui_line_from_reg_element_no (first_element_no);
275 else
276 { /* Calculate the first line from the element number which is in
277 the general data content. */
278 }
279
280 if (first_line >= 0)
281 {
282 int last_element_no, last_line;
283
284 if (scroll_direction == FORWARD_SCROLL)
285 first_line += num_to_scroll;
286 else
287 first_line -= num_to_scroll;
288 tui_erase_data_content ((char *) NULL);
289 tui_delete_data_content_windows ();
290 tui_display_data_from_line (first_line);
291 }
292 }
293
294
295 /*****************************************
296 ** STATIC LOCAL FUNCTIONS **
297 ******************************************/