]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/tui/tui-wingeneral.c
Remove separate visibility flag
[thirdparty/binutils-gdb.git] / gdb / tui / tui-wingeneral.c
1 /* General window behavior.
2
3 Copyright (C) 1998-2019 Free Software Foundation, Inc.
4
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
11 the Free Software Foundation; either version 3 of the License, or
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
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21
22 #include "defs.h"
23 #include "tui/tui.h"
24 #include "tui/tui-data.h"
25 #include "tui/tui-wingeneral.h"
26 #include "tui/tui-win.h"
27 #include "tui/tui-stack.h"
28
29 #include "gdb_curses.h"
30
31 /***********************
32 ** PUBLIC FUNCTIONS
33 ***********************/
34
35 /* See tui-data.h. */
36
37 void
38 tui_gen_win_info::refresh_window ()
39 {
40 if (handle != NULL)
41 {
42 touchwin (handle);
43 wrefresh (handle);
44 }
45 }
46
47 /* Function to delete the curses window, checking for NULL. */
48 void
49 tui_delete_win (WINDOW *window)
50 {
51 if (window != NULL)
52 delwin (window);
53 }
54
55
56 /* Draw a border arround the window. */
57 static void
58 box_win (struct tui_gen_win_info *win_info,
59 int highlight_flag)
60 {
61 if (win_info && win_info->handle)
62 {
63 WINDOW *win;
64 int attrs;
65
66 win = win_info->handle;
67 if (highlight_flag == HILITE)
68 attrs = tui_active_border_attrs;
69 else
70 attrs = tui_border_attrs;
71
72 wattron (win, attrs);
73 #ifdef HAVE_WBORDER
74 wborder (win, tui_border_vline, tui_border_vline,
75 tui_border_hline, tui_border_hline,
76 tui_border_ulcorner, tui_border_urcorner,
77 tui_border_llcorner, tui_border_lrcorner);
78 #else
79 box (win, tui_border_vline, tui_border_hline);
80 #endif
81 if (win_info->title)
82 mvwaddstr (win, 0, 3, win_info->title);
83 wattroff (win, attrs);
84 }
85 }
86
87
88 void
89 tui_unhighlight_win (struct tui_win_info *win_info)
90 {
91 if (win_info != NULL
92 && win_info->can_highlight
93 && win_info->handle != NULL)
94 {
95 box_win (win_info, NO_HILITE);
96 win_info->refresh_window ();
97 win_info->set_highlight (false);
98 }
99 }
100
101
102 void
103 tui_highlight_win (struct tui_win_info *win_info)
104 {
105 if (win_info != NULL
106 && win_info->can_highlight
107 && win_info->handle != NULL)
108 {
109 box_win (win_info, HILITE);
110 win_info->refresh_window ();
111 win_info->set_highlight (true);
112 }
113 }
114
115 void
116 tui_win_info::check_and_display_highlight_if_needed ()
117 {
118 if (can_highlight)
119 {
120 if (is_highlighted)
121 tui_highlight_win (this);
122 else
123 tui_unhighlight_win (this);
124 }
125 }
126
127
128 void
129 tui_make_window (struct tui_gen_win_info *win_info)
130 {
131 WINDOW *handle;
132
133 handle = newwin (win_info->height,
134 win_info->width,
135 win_info->origin.y,
136 win_info->origin.x);
137 win_info->handle = handle;
138 if (handle != NULL)
139 {
140 if (win_info->can_box ())
141 box_win (win_info, NO_HILITE);
142 scrollok (handle, TRUE);
143 }
144 }
145
146
147 /* We can't really make windows visible, or invisible. So we have to
148 delete the entire window when making it visible, and create it
149 again when making it visible. */
150 void
151 tui_gen_win_info::make_visible (bool visible)
152 {
153 if (is_visible () == visible)
154 return;
155
156 if (visible)
157 tui_make_window (this);
158 else
159 {
160 tui_delete_win (handle);
161 handle = NULL;
162 }
163 }
164
165 /* See tui-wingeneral.h. */
166
167 void
168 tui_make_all_invisible (void)
169 {
170 for (tui_win_info *win_info : all_tui_windows ())
171 win_info->make_visible (false);
172 }
173
174 /* Function to refresh all the windows currently displayed. */
175
176 void
177 tui_refresh_all ()
178 {
179 struct tui_locator_window *locator = tui_locator_win_info_ptr ();
180
181 for (tui_win_info *win_info : all_tui_windows ())
182 {
183 if (win_info->is_visible ())
184 win_info->refresh_window ();
185 }
186 if (locator->is_visible ())
187 locator->refresh_window ();
188 }
189
190
191 /*********************************
192 ** Local Static Functions
193 *********************************/