Remove tui_make_visible and tui_make_invisible
[deliverable/binutils-gdb.git] / gdb / tui / tui-wingeneral.c
CommitLineData
f377b406 1/* General window behavior.
f33c6cbf 2
42a4f53d 3 Copyright (C) 1998-2019 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-win.h"
f33c6cbf 27
6a83354a 28#include "gdb_curses.h"
4e8f7a8b 29
c906108c
SS
30/***********************
31** PUBLIC FUNCTIONS
32***********************/
ec7d9e56 33
5b81daba
TT
34/* See tui-data.h. */
35
c906108c 36void
5b81daba 37tui_gen_win_info::refresh_window ()
c906108c 38{
5b81daba 39 if (handle != NULL)
fd6c75ee
TT
40 {
41 touchwin (handle);
42 wrefresh (handle);
43 }
5b81daba 44}
c906108c 45
5b81daba
TT
46/* See tui-data.h. */
47
48void
49tui_data_window::refresh_window ()
50{
cf82af05
TT
51 tui_gen_win_info::refresh_window ();
52 for (auto &&win : regs_content)
5b81daba 53 {
cf82af05
TT
54 if (win != NULL)
55 win->refresh_window ();
c906108c 56 }
ec7d9e56 57}
c906108c 58
1cc6d956 59/* Function to delete the curses window, checking for NULL. */
c906108c 60void
5b6fe301 61tui_delete_win (WINDOW *window)
c906108c 62{
cafb3438 63 if (window != NULL)
c906108c 64 delwin (window);
ec7d9e56 65}
c906108c
SS
66
67
af101512 68/* Draw a border arround the window. */
2c0b251b 69static void
08ef48c5
MS
70box_win (struct tui_gen_win_info *win_info,
71 int highlight_flag)
c906108c 72{
6d012f14 73 if (win_info && win_info->handle)
c906108c 74 {
af101512
SC
75 WINDOW *win;
76 int attrs;
77
6d012f14 78 win = win_info->handle;
6ba8e26f 79 if (highlight_flag == HILITE)
af101512 80 attrs = tui_active_border_attrs;
c906108c 81 else
af101512
SC
82 attrs = tui_border_attrs;
83
84 wattron (win, attrs);
8b9cf735 85#ifdef HAVE_WBORDER
af101512
SC
86 wborder (win, tui_border_vline, tui_border_vline,
87 tui_border_hline, tui_border_hline,
88 tui_border_ulcorner, tui_border_urcorner,
89 tui_border_llcorner, tui_border_lrcorner);
8b9cf735
MK
90#else
91 box (win, tui_border_vline, tui_border_hline);
92#endif
6d012f14 93 if (win_info->title)
63a33118 94 mvwaddstr (win, 0, 3, win_info->title);
af101512 95 wattroff (win, attrs);
c906108c 96 }
af101512 97}
c906108c
SS
98
99
c906108c 100void
5b6fe301 101tui_unhighlight_win (struct tui_win_info *win_info)
c906108c 102{
e5908723 103 if (win_info != NULL
bbc228ee 104 && win_info->can_highlight
cb2ce893 105 && win_info->handle != NULL)
c906108c 106 {
cb2ce893 107 box_win (win_info, NO_HILITE);
cf82af05 108 win_info->refresh_window ();
214a5cbe 109 win_info->set_highlight (false);
c906108c 110 }
ec7d9e56 111}
c906108c
SS
112
113
c906108c 114void
5b6fe301 115tui_highlight_win (struct tui_win_info *win_info)
c906108c 116{
6d012f14
AC
117 if (win_info != NULL
118 && win_info->can_highlight
cb2ce893 119 && win_info->handle != NULL)
c906108c 120 {
cb2ce893 121 box_win (win_info, HILITE);
cf82af05 122 win_info->refresh_window ();
214a5cbe 123 win_info->set_highlight (true);
c906108c 124 }
ec7d9e56 125}
c906108c 126
c906108c 127void
5b6fe301 128tui_check_and_display_highlight_if_needed (struct tui_win_info *win_info)
c906108c 129{
00e264e7 130 if (win_info != NULL && win_info->can_highlight)
c906108c 131 {
6d012f14
AC
132 if (win_info->is_highlighted)
133 tui_highlight_win (win_info);
c906108c 134 else
6d012f14 135 tui_unhighlight_win (win_info);
c906108c
SS
136
137 }
138 return;
ec7d9e56 139}
c906108c
SS
140
141
c906108c 142void
17374de4 143tui_make_window (struct tui_gen_win_info *win_info, enum tui_box box_it)
c906108c
SS
144{
145 WINDOW *handle;
146
6d012f14
AC
147 handle = newwin (win_info->height,
148 win_info->width,
149 win_info->origin.y,
150 win_info->origin.x);
151 win_info->handle = handle;
cafb3438 152 if (handle != NULL)
c906108c 153 {
6ba8e26f
AC
154 if (box_it == BOX_WINDOW)
155 box_win (win_info, NO_HILITE);
56122977 156 win_info->is_visible = true;
c906108c 157 scrollok (handle, TRUE);
c906108c 158 }
bc712bbf 159}
c906108c
SS
160
161
ec7d9e56
AC
162/* We can't really make windows visible, or invisible. So we have to
163 delete the entire window when making it visible, and create it
164 again when making it visible. */
48a3bd16
TT
165void
166tui_gen_win_info::make_visible (bool visible)
c906108c 167{
8e3cfd09
TT
168 if (is_visible == visible)
169 return;
170 is_visible = visible;
171
c906108c 172 if (visible)
8e3cfd09
TT
173 tui_make_window (this, (tui_win_is_auxiliary (type)
174 ? DONT_BOX_WINDOW : BOX_WINDOW));
175 else
c906108c 176 {
48a3bd16
TT
177 tui_delete_win (handle);
178 handle = NULL;
c906108c 179 }
ec7d9e56 180}
c906108c 181
cda37efb
TT
182/* See tui-data.h. */
183
184void
56122977 185tui_source_window_base::make_visible (bool visible)
cda37efb 186{
098f9ed4 187 execution_info->make_visible (visible);
cda37efb
TT
188 tui_win_info::make_visible (visible);
189}
ec7d9e56 190
1cc6d956
MS
191/* Makes all windows invisible (except the command and locator
192 windows). */
ec7d9e56 193static void
56122977 194make_all_visible (bool visible)
c906108c 195{
1ce3e844
TT
196 for (tui_win_info *win_info : all_tui_windows ())
197 win_info->make_visible (visible);
ec7d9e56
AC
198}
199
200void
201tui_make_all_visible (void)
202{
56122977 203 make_all_visible (true);
ec7d9e56
AC
204}
205
206void
207tui_make_all_invisible (void)
208{
56122977 209 make_all_visible (false);
ec7d9e56
AC
210}
211
2042b506
TT
212/* See tui-data.h. */
213
214void
fd6c75ee 215tui_source_window_base::refresh_window ()
2042b506 216{
5b81daba 217 execution_info->refresh_window ();
fd6c75ee 218 tui_win_info::refresh_window ();
2042b506
TT
219}
220
ec7d9e56 221/* Function to refresh all the windows currently displayed. */
c906108c 222
c906108c 223void
1ce3e844 224tui_refresh_all ()
c906108c 225{
3add462f 226 struct tui_locator_window *locator = tui_locator_win_info_ptr ();
c906108c 227
1ce3e844 228 for (tui_win_info *win_info : all_tui_windows ())
c906108c 229 {
1ce3e844 230 if (win_info->is_visible)
fd6c75ee 231 win_info->refresh_window ();
c906108c 232 }
6d012f14 233 if (locator->is_visible)
fd6c75ee 234 locator->refresh_window ();
6ba8e26f 235}
c906108c
SS
236
237
238/*********************************
239** Local Static Functions
240*********************************/
This page took 1.871428 seconds and 4 git commands to generate.