Remove some TUI static allocations
[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
TT
39 if (handle != NULL)
40 wrefresh (handle);
41}
c906108c 42
5b81daba
TT
43/* See tui-data.h. */
44
45void
46tui_data_window::refresh_window ()
47{
48 if (content_size > 0)
49 {
50 for (int i = 0; i < content_size; i++)
c906108c 51 {
5b6fe301 52 struct tui_gen_win_info *data_item_win_ptr;
c906108c 53
5b81daba 54 data_item_win_ptr = content[i]->which_element.data_window;
6ba8e26f 55 if (data_item_win_ptr != NULL
cafb3438 56 && data_item_win_ptr->handle != NULL)
6ba8e26f 57 wrefresh (data_item_win_ptr->handle);
c906108c
SS
58 }
59 }
c906108c 60 else
5b81daba 61 tui_gen_win_info::refresh_window ();
ec7d9e56 62}
c906108c 63
1cc6d956 64/* Function to delete the curses window, checking for NULL. */
c906108c 65void
5b6fe301 66tui_delete_win (WINDOW *window)
c906108c 67{
cafb3438 68 if (window != NULL)
c906108c
SS
69 delwin (window);
70
71 return;
ec7d9e56 72}
c906108c
SS
73
74
af101512 75/* Draw a border arround the window. */
2c0b251b 76static void
08ef48c5
MS
77box_win (struct tui_gen_win_info *win_info,
78 int highlight_flag)
c906108c 79{
6d012f14 80 if (win_info && win_info->handle)
c906108c 81 {
af101512
SC
82 WINDOW *win;
83 int attrs;
84
6d012f14 85 win = win_info->handle;
6ba8e26f 86 if (highlight_flag == HILITE)
af101512 87 attrs = tui_active_border_attrs;
c906108c 88 else
af101512
SC
89 attrs = tui_border_attrs;
90
91 wattron (win, attrs);
8b9cf735 92#ifdef HAVE_WBORDER
af101512
SC
93 wborder (win, tui_border_vline, tui_border_vline,
94 tui_border_hline, tui_border_hline,
95 tui_border_ulcorner, tui_border_urcorner,
96 tui_border_llcorner, tui_border_lrcorner);
8b9cf735
MK
97#else
98 box (win, tui_border_vline, tui_border_hline);
99#endif
6d012f14 100 if (win_info->title)
63a33118 101 mvwaddstr (win, 0, 3, win_info->title);
af101512 102 wattroff (win, attrs);
c906108c 103 }
af101512 104}
c906108c
SS
105
106
c906108c 107void
5b6fe301 108tui_unhighlight_win (struct tui_win_info *win_info)
c906108c 109{
e5908723 110 if (win_info != NULL
cb2ce893 111 && win_info->handle != NULL)
c906108c 112 {
cb2ce893
TT
113 box_win (win_info, NO_HILITE);
114 wrefresh (win_info->handle);
214a5cbe 115 win_info->set_highlight (false);
c906108c 116 }
ec7d9e56 117}
c906108c
SS
118
119
c906108c 120void
5b6fe301 121tui_highlight_win (struct tui_win_info *win_info)
c906108c 122{
6d012f14
AC
123 if (win_info != NULL
124 && win_info->can_highlight
cb2ce893 125 && win_info->handle != NULL)
c906108c 126 {
cb2ce893
TT
127 box_win (win_info, HILITE);
128 wrefresh (win_info->handle);
214a5cbe 129 win_info->set_highlight (true);
c906108c 130 }
ec7d9e56 131}
c906108c 132
c906108c 133void
5b6fe301 134tui_check_and_display_highlight_if_needed (struct tui_win_info *win_info)
c906108c 135{
cb2ce893 136 if (win_info != NULL && win_info->type != CMD_WIN)
c906108c 137 {
6d012f14
AC
138 if (win_info->is_highlighted)
139 tui_highlight_win (win_info);
c906108c 140 else
6d012f14 141 tui_unhighlight_win (win_info);
c906108c
SS
142
143 }
144 return;
ec7d9e56 145}
c906108c
SS
146
147
c906108c 148void
5b6fe301 149tui_make_window (struct tui_gen_win_info *win_info, int box_it)
c906108c
SS
150{
151 WINDOW *handle;
152
6d012f14
AC
153 handle = newwin (win_info->height,
154 win_info->width,
155 win_info->origin.y,
156 win_info->origin.x);
157 win_info->handle = handle;
cafb3438 158 if (handle != NULL)
c906108c 159 {
6ba8e26f
AC
160 if (box_it == BOX_WINDOW)
161 box_win (win_info, NO_HILITE);
56122977 162 win_info->is_visible = true;
c906108c 163 scrollok (handle, TRUE);
c906108c 164 }
bc712bbf 165}
c906108c
SS
166
167
ec7d9e56
AC
168/* We can't really make windows visible, or invisible. So we have to
169 delete the entire window when making it visible, and create it
170 again when making it visible. */
48a3bd16
TT
171void
172tui_gen_win_info::make_visible (bool visible)
c906108c 173{
c906108c
SS
174 if (visible)
175 {
48a3bd16 176 if (!is_visible)
c906108c 177 {
48a3bd16
TT
178 tui_make_window (this, !tui_win_is_auxillary (type));
179 is_visible = true;
c906108c 180 }
c906108c 181 }
e5908723 182 else if (!visible
48a3bd16
TT
183 && is_visible
184 && handle != NULL)
c906108c 185 {
48a3bd16
TT
186 is_visible = false;
187 tui_delete_win (handle);
188 handle = NULL;
c906108c 189 }
ec7d9e56 190}
c906108c 191
ec7d9e56
AC
192void
193tui_make_visible (struct tui_gen_win_info *win_info)
194{
48a3bd16 195 win_info->make_visible (true);
ec7d9e56 196}
c906108c 197
c906108c 198void
ec7d9e56
AC
199tui_make_invisible (struct tui_gen_win_info *win_info)
200{
48a3bd16 201 win_info->make_visible (false);
cda37efb
TT
202}
203
204/* See tui-data.h. */
205
206void
56122977 207tui_source_window_base::make_visible (bool visible)
cda37efb 208{
48a3bd16
TT
209 if (execution_info != nullptr)
210 execution_info->make_visible (visible);
cda37efb
TT
211 tui_win_info::make_visible (visible);
212}
ec7d9e56 213
1cc6d956
MS
214/* Makes all windows invisible (except the command and locator
215 windows). */
ec7d9e56 216static void
56122977 217make_all_visible (bool visible)
c906108c
SS
218{
219 int i;
220
221 for (i = 0; i < MAX_MAJOR_WINDOWS; i++)
222 {
cda37efb
TT
223 if (tui_win_list[i] != NULL)
224 tui_win_list[i]->make_visible (visible);
c906108c
SS
225 }
226
227 return;
ec7d9e56
AC
228}
229
230void
231tui_make_all_visible (void)
232{
56122977 233 make_all_visible (true);
ec7d9e56
AC
234}
235
236void
237tui_make_all_invisible (void)
238{
56122977 239 make_all_visible (false);
ec7d9e56
AC
240}
241
2042b506
TT
242/* See tui-data.h. */
243
244void
245tui_win_info::refresh ()
246{
cb2ce893 247 touchwin (handle);
5b81daba 248 refresh_window ();
2042b506
TT
249}
250
251/* See tui-data.h. */
252
253void
254tui_source_window_base::refresh ()
255{
256 touchwin (execution_info->handle);
5b81daba 257 execution_info->refresh_window ();
2042b506
TT
258 tui_win_info::refresh ();
259}
260
ec7d9e56 261/* Function to refresh all the windows currently displayed. */
c906108c 262
c906108c 263void
5b6fe301 264tui_refresh_all (struct tui_win_info **list)
c906108c 265{
570dc176 266 int type;
5b6fe301 267 struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
c906108c
SS
268
269 for (type = SRC_WIN; (type < MAX_MAJOR_WINDOWS); type++)
270 {
cb2ce893 271 if (list[type] && list[type]->is_visible)
2042b506 272 list[type]->refresh ();
c906108c 273 }
6d012f14 274 if (locator->is_visible)
c906108c
SS
275 {
276 touchwin (locator->handle);
5b81daba 277 locator->refresh_window ();
c906108c 278 }
6ba8e26f 279}
c906108c
SS
280
281
282/*********************************
283** Local Static Functions
284*********************************/
This page took 3.102952 seconds and 4 git commands to generate.