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