1 /* Data/register window display.
3 Copyright (C) 1998-2019 Free Software Foundation, Inc.
5 Contributed by Hewlett-Packard Company.
7 This file is part of GDB.
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
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
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.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
24 #include "tui/tui-data.h"
25 #include "tui/tui-wingeneral.h"
26 #include "tui/tui-regs.h"
27 #include "tui/tui-windata.h"
28 #include "gdb_curses.h"
31 /*****************************************
32 ** STATIC LOCAL FUNCTIONS FORWARD DECLS **
33 ******************************************/
37 /*****************************************
38 ** PUBLIC FUNCTIONS **
39 ******************************************/
42 /* Answer the index first element displayed. If none are displayed,
45 tui_data_window::first_data_item_displayed ()
47 for (int i
= 0; i
< regs_content
.size (); i
++)
49 struct tui_gen_win_info
*data_item_win
;
51 data_item_win
= regs_content
[i
].get ();
52 if (data_item_win
->handle
!= NULL
&& data_item_win
->is_visible
)
60 /* Function to delete all the item windows in the data window. This
61 is usually done when the data window is scrolled. */
63 tui_delete_data_content_windows (void)
65 for (auto &&win
: TUI_DATA_WIN
->regs_content
)
67 tui_delete_win (win
->handle
);
69 win
->is_visible
= false;
75 tui_erase_data_content (const char *prompt
)
77 werase (TUI_DATA_WIN
->handle
);
78 tui_check_and_display_highlight_if_needed (TUI_DATA_WIN
);
81 int half_width
= (TUI_DATA_WIN
->width
- 2) / 2;
84 if (strlen (prompt
) >= half_width
)
87 x_pos
= half_width
- strlen (prompt
);
88 mvwaddstr (TUI_DATA_WIN
->handle
,
89 (TUI_DATA_WIN
->height
/ 2),
93 wrefresh (TUI_DATA_WIN
->handle
);
97 /* This function displays the data that is in the data window's
98 content. It does not set the content. */
100 tui_display_all_data (void)
102 if (TUI_DATA_WIN
->regs_content
.empty ())
103 tui_erase_data_content (NO_DATA_STRING
);
106 tui_erase_data_content (NULL
);
107 tui_delete_data_content_windows ();
108 tui_check_and_display_highlight_if_needed (TUI_DATA_WIN
);
109 tui_display_registers_from (0);
114 /* Function to display the data starting at line, line_no, in the data
117 tui_display_data_from_line (int line_no
)
119 int _line_no
= line_no
;
124 tui_check_and_display_highlight_if_needed (TUI_DATA_WIN
);
126 tui_display_registers_from_line (_line_no
, TRUE
);
130 /* Display data starting at element element_no. */
132 tui_display_data_from (int element_no
, int reuse_windows
)
134 int first_line
= (-1);
136 if (element_no
< TUI_DATA_WIN
->regs_content
.size ())
137 first_line
= tui_line_from_reg_element_no (element_no
);
139 { /* Calculate the first_line from the element number. */
144 tui_erase_data_content (NULL
);
146 tui_delete_data_content_windows ();
147 tui_display_data_from_line (first_line
);
152 /* Function to redisplay the contents of the data window. */
154 tui_data_window::refresh_all ()
156 tui_erase_data_content (NULL
);
157 if (!regs_content
.empty ())
159 int first_element
= first_data_item_displayed ();
161 if (first_element
>= 0) /* Re-use existing windows. */
162 tui_display_data_from (first_element
, TRUE
);
167 /* Scroll the data window vertically forward or backward. */
169 tui_data_window::do_scroll_vertical (int num_to_scroll
)
171 int first_element_no
;
172 int first_line
= (-1);
174 first_element_no
= first_data_item_displayed ();
175 if (first_element_no
< regs_content
.size ())
176 first_line
= tui_line_from_reg_element_no (first_element_no
);
178 { /* Calculate the first line from the element number which is in
179 the general data content. */
184 first_line
+= num_to_scroll
;
185 tui_erase_data_content (NULL
);
186 tui_delete_data_content_windows ();
187 tui_display_data_from_line (first_line
);
192 /*****************************************
193 ** STATIC LOCAL FUNCTIONS **
194 ******************************************/
This page took 0.032939 seconds and 4 git commands to generate.