1 /* General window behavior.
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-win.h"
28 #include "gdb_curses.h"
30 /***********************
32 ***********************/
37 tui_gen_win_info::refresh_window ()
46 tui_data_window::refresh_window ()
48 if (!regs_content.empty ())
50 for (auto &&win : regs_content)
52 if (win != NULL && win->handle != NULL)
53 wrefresh (win->handle);
57 tui_gen_win_info::refresh_window ();
60 /* Function to delete the curses window, checking for NULL. */
62 tui_delete_win (WINDOW *window)
69 /* Draw a border arround the window. */
71 box_win (struct tui_gen_win_info *win_info,
74 if (win_info && win_info->handle)
79 win = win_info->handle;
80 if (highlight_flag == HILITE)
81 attrs = tui_active_border_attrs;
83 attrs = tui_border_attrs;
87 wborder (win, tui_border_vline, tui_border_vline,
88 tui_border_hline, tui_border_hline,
89 tui_border_ulcorner, tui_border_urcorner,
90 tui_border_llcorner, tui_border_lrcorner);
92 box (win, tui_border_vline, tui_border_hline);
95 mvwaddstr (win, 0, 3, win_info->title);
96 wattroff (win, attrs);
102 tui_unhighlight_win (struct tui_win_info *win_info)
105 && win_info->can_highlight
106 && win_info->handle != NULL)
108 box_win (win_info, NO_HILITE);
109 wrefresh (win_info->handle);
110 win_info->set_highlight (false);
116 tui_highlight_win (struct tui_win_info *win_info)
119 && win_info->can_highlight
120 && win_info->handle != NULL)
122 box_win (win_info, HILITE);
123 wrefresh (win_info->handle);
124 win_info->set_highlight (true);
129 tui_check_and_display_highlight_if_needed (struct tui_win_info *win_info)
131 if (win_info != NULL && win_info->can_highlight)
133 if (win_info->is_highlighted)
134 tui_highlight_win (win_info);
136 tui_unhighlight_win (win_info);
144 tui_make_window (struct tui_gen_win_info *win_info, enum tui_box box_it)
148 handle = newwin (win_info->height,
152 win_info->handle = handle;
155 if (box_it == BOX_WINDOW)
156 box_win (win_info, NO_HILITE);
157 win_info->is_visible = true;
158 scrollok (handle, TRUE);
163 /* We can't really make windows visible, or invisible. So we have to
164 delete the entire window when making it visible, and create it
165 again when making it visible. */
167 tui_gen_win_info::make_visible (bool visible)
173 tui_make_window (this, (tui_win_is_auxiliary (type)
174 ? DONT_BOX_WINDOW : BOX_WINDOW));
183 tui_delete_win (handle);
189 tui_make_visible (struct tui_gen_win_info *win_info)
191 win_info->make_visible (true);
195 tui_make_invisible (struct tui_gen_win_info *win_info)
197 win_info->make_visible (false);
200 /* See tui-data.h. */
203 tui_source_window_base::make_visible (bool visible)
205 if (execution_info != nullptr)
206 execution_info->make_visible (visible);
207 tui_win_info::make_visible (visible);
210 /* Makes all windows invisible (except the command and locator
213 make_all_visible (bool visible)
215 for (tui_win_info *win_info : all_tui_windows ())
216 win_info->make_visible (visible);
220 tui_make_all_visible (void)
222 make_all_visible (true);
226 tui_make_all_invisible (void)
228 make_all_visible (false);
231 /* See tui-data.h. */
234 tui_win_info::refresh ()
240 /* See tui-data.h. */
243 tui_source_window_base::refresh ()
245 touchwin (execution_info->handle);
246 execution_info->refresh_window ();
247 tui_win_info::refresh ();
250 /* Function to refresh all the windows currently displayed. */
255 struct tui_locator_window *locator = tui_locator_win_info_ptr ();
257 for (tui_win_info *win_info : all_tui_windows ())
259 if (win_info->is_visible)
260 win_info->refresh ();
262 if (locator->is_visible)
264 touchwin (locator->handle);
265 locator->refresh_window ();
270 /*********************************
271 ** Local Static Functions
272 *********************************/