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