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