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