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