Commit | Line | Data |
---|---|---|
f377b406 | 1 | /* Data/register window display. |
f33c6cbf | 2 | |
42a4f53d | 3 | Copyright (C) 1998-2019 Free Software Foundation, Inc. |
f33c6cbf | 4 | |
f377b406 SC |
5 | Contributed by Hewlett-Packard Company. |
6 | ||
7 | This file is part of GDB. | |
8 | ||
9 | This program is free software; you can redistribute it and/or modify | |
10 | it under the terms of the GNU General Public License as published by | |
a9762ec7 | 11 | the Free Software Foundation; either version 3 of the License, or |
f377b406 SC |
12 | (at your option) any later version. |
13 | ||
14 | This program is distributed in the hope that it will be useful, | |
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | GNU General Public License for more details. | |
18 | ||
19 | You should have received a copy of the GNU General Public License | |
a9762ec7 | 20 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
c906108c | 21 | |
96ec9981 | 22 | #include "defs.h" |
d7b2e967 AC |
23 | #include "tui/tui.h" |
24 | #include "tui/tui-data.h" | |
25 | #include "tui/tui-wingeneral.h" | |
26 | #include "tui/tui-regs.h" | |
2c0b251b | 27 | #include "tui/tui-windata.h" |
6a83354a | 28 | #include "gdb_curses.h" |
4e8f7a8b | 29 | |
c906108c SS |
30 | |
31 | /***************************************** | |
32 | ** STATIC LOCAL FUNCTIONS FORWARD DECLS ** | |
33 | ******************************************/ | |
34 | ||
35 | ||
36 | ||
37 | /***************************************** | |
38 | ** PUBLIC FUNCTIONS ** | |
39 | ******************************************/ | |
40 | ||
41 | ||
6ba8e26f AC |
42 | /* Answer the index first element displayed. If none are displayed, |
43 | then return (-1). */ | |
c906108c | 44 | int |
6ba8e26f | 45 | tui_first_data_item_displayed (void) |
c906108c | 46 | { |
6ba8e26f | 47 | int element_no = (-1); |
c906108c SS |
48 | int i; |
49 | ||
e5908723 MS |
50 | for (i = 0; |
51 | i < TUI_DATA_WIN->generic.content_size && element_no < 0; | |
52 | i++) | |
c906108c | 53 | { |
5b6fe301 | 54 | struct tui_gen_win_info *data_item_win; |
c906108c | 55 | |
63a33118 | 56 | data_item_win |
dc2c33e4 | 57 | = TUI_DATA_WIN->generic.content[i]->which_element.data_window; |
d04b44a1 | 58 | if (data_item_win->handle != NULL |
e5908723 | 59 | && data_item_win->is_visible) |
6ba8e26f | 60 | element_no = i; |
c906108c SS |
61 | } |
62 | ||
6ba8e26f AC |
63 | return element_no; |
64 | } | |
c906108c SS |
65 | |
66 | ||
6ba8e26f AC |
67 | /* Function to delete all the item windows in the data window. This |
68 | is usually done when the data window is scrolled. */ | |
c906108c | 69 | void |
6ba8e26f | 70 | tui_delete_data_content_windows (void) |
c906108c SS |
71 | { |
72 | int i; | |
5b6fe301 | 73 | struct tui_gen_win_info *data_item_win_ptr; |
c906108c | 74 | |
6d012f14 | 75 | for (i = 0; (i < TUI_DATA_WIN->generic.content_size); i++) |
c906108c | 76 | { |
63a33118 | 77 | data_item_win_ptr |
dc2c33e4 | 78 | = TUI_DATA_WIN->generic.content[i]->which_element.data_window; |
6ba8e26f | 79 | tui_delete_win (data_item_win_ptr->handle); |
e65b5245 | 80 | data_item_win_ptr->handle = NULL; |
56122977 | 81 | data_item_win_ptr->is_visible = false; |
c906108c | 82 | } |
6ba8e26f | 83 | } |
c906108c SS |
84 | |
85 | ||
86 | void | |
a121b7c1 | 87 | tui_erase_data_content (const char *prompt) |
c906108c | 88 | { |
6d012f14 AC |
89 | werase (TUI_DATA_WIN->generic.handle); |
90 | tui_check_and_display_highlight_if_needed (TUI_DATA_WIN); | |
63a33118 | 91 | if (prompt != NULL) |
c906108c | 92 | { |
6ba8e26f AC |
93 | int half_width = (TUI_DATA_WIN->generic.width - 2) / 2; |
94 | int x_pos; | |
c906108c | 95 | |
6ba8e26f AC |
96 | if (strlen (prompt) >= half_width) |
97 | x_pos = 1; | |
c906108c | 98 | else |
6ba8e26f | 99 | x_pos = half_width - strlen (prompt); |
6d012f14 AC |
100 | mvwaddstr (TUI_DATA_WIN->generic.handle, |
101 | (TUI_DATA_WIN->generic.height / 2), | |
6ba8e26f | 102 | x_pos, |
7a6e7fcc | 103 | (char *) prompt); |
c906108c | 104 | } |
6d012f14 | 105 | wrefresh (TUI_DATA_WIN->generic.handle); |
edae1ccf | 106 | } |
c906108c SS |
107 | |
108 | ||
edae1ccf AC |
109 | /* This function displays the data that is in the data window's |
110 | content. It does not set the content. */ | |
c906108c | 111 | void |
edae1ccf | 112 | tui_display_all_data (void) |
c906108c | 113 | { |
6d012f14 | 114 | if (TUI_DATA_WIN->generic.content_size <= 0) |
edae1ccf | 115 | tui_erase_data_content (NO_DATA_STRING); |
c906108c SS |
116 | else |
117 | { | |
63a33118 | 118 | tui_erase_data_content (NULL); |
6ba8e26f | 119 | tui_delete_data_content_windows (); |
6d012f14 | 120 | tui_check_and_display_highlight_if_needed (TUI_DATA_WIN); |
55fb0713 | 121 | tui_display_registers_from (0); |
ef5eab5a MS |
122 | |
123 | /* Then display the other data. */ | |
238eb706 TT |
124 | if (TUI_DATA_WIN->data_content != NULL |
125 | && TUI_DATA_WIN->data_content_count > 0) | |
c906108c SS |
126 | { |
127 | } | |
128 | } | |
edae1ccf | 129 | } |
c906108c SS |
130 | |
131 | ||
6ba8e26f AC |
132 | /* Function to display the data starting at line, line_no, in the data |
133 | window. */ | |
c906108c | 134 | void |
6ba8e26f | 135 | tui_display_data_from_line (int line_no) |
c906108c | 136 | { |
6ba8e26f | 137 | int _line_no = line_no; |
c906108c | 138 | |
6ba8e26f AC |
139 | if (line_no < 0) |
140 | _line_no = 0; | |
c906108c | 141 | |
6d012f14 | 142 | tui_check_and_display_highlight_if_needed (TUI_DATA_WIN); |
c906108c | 143 | |
1cc6d956 MS |
144 | /* There is no general data, force regs to display (if there are |
145 | any). */ | |
238eb706 | 146 | if (TUI_DATA_WIN->data_content_count <= 0) |
6ba8e26f | 147 | tui_display_registers_from_line (_line_no, TRUE); |
c906108c SS |
148 | else |
149 | { | |
6ba8e26f | 150 | int regs_last_line = tui_last_regs_line_no (); |
c906108c SS |
151 | |
152 | ||
1cc6d956 | 153 | /* Display regs if we can. */ |
6ba8e26f | 154 | if (tui_display_registers_from_line (_line_no, FALSE) < 0) |
ef5eab5a MS |
155 | { /* _line_no is past the regs display, so calc where the |
156 | start data element is. */ | |
6ba8e26f | 157 | if (regs_last_line < _line_no) |
ef5eab5a MS |
158 | { /* Figure out how many lines each element is to obtain |
159 | the start element_no. */ | |
c906108c SS |
160 | } |
161 | } | |
162 | else | |
ef5eab5a MS |
163 | { /* Calculate the starting element of the data display, given |
164 | regs_last_line and how many lines each element is, up to | |
165 | _line_no. */ | |
c906108c | 166 | } |
1cc6d956 | 167 | /* Now display the data , starting at element_no. */ |
c906108c | 168 | } |
6ba8e26f | 169 | } |
c906108c SS |
170 | |
171 | ||
1cc6d956 | 172 | /* Display data starting at element element_no. */ |
c906108c | 173 | void |
6ba8e26f | 174 | tui_display_data_from (int element_no, int reuse_windows) |
c906108c | 175 | { |
6ba8e26f | 176 | int first_line = (-1); |
c906108c | 177 | |
238eb706 | 178 | if (element_no < TUI_DATA_WIN->regs_content_count) |
6ba8e26f | 179 | first_line = tui_line_from_reg_element_no (element_no); |
c906108c | 180 | else |
1cc6d956 | 181 | { /* Calculate the first_line from the element number. */ |
c906108c SS |
182 | } |
183 | ||
6ba8e26f | 184 | if (first_line >= 0) |
c906108c | 185 | { |
63a33118 | 186 | tui_erase_data_content (NULL); |
6ba8e26f AC |
187 | if (!reuse_windows) |
188 | tui_delete_data_content_windows (); | |
189 | tui_display_data_from_line (first_line); | |
c906108c | 190 | } |
6ba8e26f | 191 | } |
c906108c SS |
192 | |
193 | ||
edae1ccf | 194 | /* Function to redisplay the contents of the data window. */ |
c906108c | 195 | void |
1825f487 | 196 | tui_data_window::refresh_all () |
c906108c | 197 | { |
63a33118 | 198 | tui_erase_data_content (NULL); |
1825f487 | 199 | if (generic.content_size > 0) |
c906108c | 200 | { |
6ba8e26f | 201 | int first_element = tui_first_data_item_displayed (); |
c906108c | 202 | |
1cc6d956 | 203 | if (first_element >= 0) /* Re-use existing windows. */ |
6ba8e26f | 204 | tui_display_data_from (first_element, TRUE); |
c906108c | 205 | } |
edae1ccf | 206 | } |
c906108c SS |
207 | |
208 | ||
1cc6d956 MS |
209 | /* Function to check the data values and hilite any that have |
210 | changed. */ | |
c906108c | 211 | void |
edae1ccf | 212 | tui_check_data_values (struct frame_info *frame) |
c906108c | 213 | { |
55fb0713 | 214 | tui_check_register_values (frame); |
c906108c | 215 | |
1cc6d956 | 216 | /* Now check any other data values that there are. */ |
6d012f14 | 217 | if (TUI_DATA_WIN != NULL && TUI_DATA_WIN->generic.is_visible) |
c906108c SS |
218 | { |
219 | int i; | |
220 | ||
238eb706 | 221 | for (i = 0; TUI_DATA_WIN->data_content_count; i++) |
c906108c SS |
222 | { |
223 | #ifdef LATER | |
6ba8e26f | 224 | tui_data_element_ptr data_element_ptr; |
5b6fe301 | 225 | struct tui_gen_win_info *data_item_win_ptr; |
6ba8e26f | 226 | Opaque new_value; |
c906108c | 227 | |
238eb706 | 228 | data_item_ptr = &TUI_DATA_WIN-> |
6d012f14 | 229 | data_content[i]->which_element.data_window; |
6ba8e26f | 230 | data_element_ptr = &((tui_win_content) |
9a2b4c1b | 231 | data_item_win_ptr->content)[0]->which_element.data; |
c906108c | 232 | if value |
6ba8e26f | 233 | has changed (data_element_ptr, frame, &new_value) |
c906108c | 234 | { |
6ba8e26f | 235 | data_element_ptr->value = new_value; |
fe978cb0 | 236 | update the display with the newobj value, hiliting it. |
c906108c SS |
237 | } |
238 | #endif | |
239 | } | |
240 | } | |
edae1ccf | 241 | } |
c906108c SS |
242 | |
243 | ||
1cc6d956 | 244 | /* Scroll the data window vertically forward or backward. */ |
c906108c | 245 | void |
13446e05 TT |
246 | tui_data_window::do_scroll_vertical |
247 | (enum tui_scroll_direction scroll_direction, int num_to_scroll) | |
c906108c | 248 | { |
6ba8e26f AC |
249 | int first_element_no; |
250 | int first_line = (-1); | |
c906108c | 251 | |
6ba8e26f | 252 | first_element_no = tui_first_data_item_displayed (); |
238eb706 | 253 | if (first_element_no < regs_content_count) |
6ba8e26f | 254 | first_line = tui_line_from_reg_element_no (first_element_no); |
c906108c | 255 | else |
1cc6d956 MS |
256 | { /* Calculate the first line from the element number which is in |
257 | the general data content. */ | |
c906108c SS |
258 | } |
259 | ||
6ba8e26f | 260 | if (first_line >= 0) |
c906108c | 261 | { |
6ba8e26f AC |
262 | if (scroll_direction == FORWARD_SCROLL) |
263 | first_line += num_to_scroll; | |
c906108c | 264 | else |
6ba8e26f | 265 | first_line -= num_to_scroll; |
63a33118 | 266 | tui_erase_data_content (NULL); |
6ba8e26f AC |
267 | tui_delete_data_content_windows (); |
268 | tui_display_data_from_line (first_line); | |
c906108c | 269 | } |
6ba8e26f | 270 | } |
c906108c SS |
271 | |
272 | ||
273 | /***************************************** | |
274 | ** STATIC LOCAL FUNCTIONS ** | |
275 | ******************************************/ |