Remove tui_data_window::display_regs
[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"
f2dda477 27#include "tui/tui-stack.h"
f33c6cbf 28
6a83354a 29#include "gdb_curses.h"
4e8f7a8b 30
c906108c
SS
31/***********************
32** PUBLIC FUNCTIONS
33***********************/
ec7d9e56 34
5b81daba
TT
35/* See tui-data.h. */
36
c906108c 37void
5b81daba 38tui_gen_win_info::refresh_window ()
c906108c 39{
5b81daba 40 if (handle != NULL)
fd6c75ee
TT
41 {
42 touchwin (handle);
43 wrefresh (handle);
44 }
5b81daba 45}
c906108c 46
1cc6d956 47/* Function to delete the curses window, checking for NULL. */
c906108c 48void
5b6fe301 49tui_delete_win (WINDOW *window)
c906108c 50{
cafb3438 51 if (window != NULL)
c906108c 52 delwin (window);
ec7d9e56 53}
c906108c
SS
54
55
af101512 56/* Draw a border arround the window. */
2c0b251b 57static void
08ef48c5
MS
58box_win (struct tui_gen_win_info *win_info,
59 int highlight_flag)
c906108c 60{
6d012f14 61 if (win_info && win_info->handle)
c906108c 62 {
af101512
SC
63 WINDOW *win;
64 int attrs;
65
6d012f14 66 win = win_info->handle;
6ba8e26f 67 if (highlight_flag == HILITE)
af101512 68 attrs = tui_active_border_attrs;
c906108c 69 else
af101512
SC
70 attrs = tui_border_attrs;
71
72 wattron (win, attrs);
8b9cf735 73#ifdef HAVE_WBORDER
af101512
SC
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);
8b9cf735
MK
78#else
79 box (win, tui_border_vline, tui_border_hline);
80#endif
6d012f14 81 if (win_info->title)
63a33118 82 mvwaddstr (win, 0, 3, win_info->title);
af101512 83 wattroff (win, attrs);
c906108c 84 }
af101512 85}
c906108c
SS
86
87
c906108c 88void
5b6fe301 89tui_unhighlight_win (struct tui_win_info *win_info)
c906108c 90{
e5908723 91 if (win_info != NULL
bbc228ee 92 && win_info->can_highlight
cb2ce893 93 && win_info->handle != NULL)
c906108c 94 {
cb2ce893 95 box_win (win_info, NO_HILITE);
cf82af05 96 win_info->refresh_window ();
214a5cbe 97 win_info->set_highlight (false);
c906108c 98 }
ec7d9e56 99}
c906108c
SS
100
101
c906108c 102void
5b6fe301 103tui_highlight_win (struct tui_win_info *win_info)
c906108c 104{
6d012f14
AC
105 if (win_info != NULL
106 && win_info->can_highlight
cb2ce893 107 && win_info->handle != NULL)
c906108c 108 {
cb2ce893 109 box_win (win_info, HILITE);
cf82af05 110 win_info->refresh_window ();
214a5cbe 111 win_info->set_highlight (true);
c906108c 112 }
ec7d9e56 113}
c906108c 114
c906108c 115void
b4ef5aeb 116tui_win_info::check_and_display_highlight_if_needed ()
c906108c 117{
b4ef5aeb 118 if (can_highlight)
c906108c 119 {
b4ef5aeb
TT
120 if (is_highlighted)
121 tui_highlight_win (this);
c906108c 122 else
b4ef5aeb 123 tui_unhighlight_win (this);
c906108c 124 }
ec7d9e56 125}
c906108c
SS
126
127
c906108c 128void
65962b20 129tui_make_window (struct tui_gen_win_info *win_info)
c906108c
SS
130{
131 WINDOW *handle;
132
6d012f14
AC
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;
cafb3438 138 if (handle != NULL)
c906108c 139 {
65962b20 140 if (win_info->can_box ())
6ba8e26f 141 box_win (win_info, NO_HILITE);
c906108c 142 scrollok (handle, TRUE);
c906108c 143 }
bc712bbf 144}
c906108c
SS
145
146
ec7d9e56
AC
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. */
48a3bd16
TT
150void
151tui_gen_win_info::make_visible (bool visible)
c906108c 152{
2d83e710 153 if (is_visible () == visible)
8e3cfd09 154 return;
8e3cfd09 155
c906108c 156 if (visible)
65962b20 157 tui_make_window (this);
8e3cfd09 158 else
c906108c 159 {
48a3bd16
TT
160 tui_delete_win (handle);
161 handle = NULL;
c906108c 162 }
ec7d9e56 163}
c906108c 164
3f3ffe54 165/* See tui-wingeneral.h. */
ec7d9e56 166
ec7d9e56
AC
167void
168tui_make_all_invisible (void)
169{
3f3ffe54
TT
170 for (tui_win_info *win_info : all_tui_windows ())
171 win_info->make_visible (false);
ec7d9e56
AC
172}
173
174/* Function to refresh all the windows currently displayed. */
c906108c 175
c906108c 176void
1ce3e844 177tui_refresh_all ()
c906108c 178{
3add462f 179 struct tui_locator_window *locator = tui_locator_win_info_ptr ();
c906108c 180
1ce3e844 181 for (tui_win_info *win_info : all_tui_windows ())
c906108c 182 {
2d83e710 183 if (win_info->is_visible ())
fd6c75ee 184 win_info->refresh_window ();
c906108c 185 }
2d83e710 186 if (locator->is_visible ())
fd6c75ee 187 locator->refresh_window ();
6ba8e26f 188}
c906108c
SS
189
190
191/*********************************
192** Local Static Functions
193*********************************/
This page took 2.641821 seconds and 4 git commands to generate.