Remove tui_show_disassem
[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"
a2a7af0c 25#include "tui/tui-io.h"
d7b2e967
AC
26#include "tui/tui-wingeneral.h"
27#include "tui/tui-win.h"
f2dda477 28#include "tui/tui-stack.h"
a2a7af0c 29#include "cli/cli-style.h"
f33c6cbf 30
6a83354a 31#include "gdb_curses.h"
4e8f7a8b 32
5b81daba
TT
33/* See tui-data.h. */
34
c906108c 35void
5b81daba 36tui_gen_win_info::refresh_window ()
c906108c 37{
5b81daba 38 if (handle != NULL)
7523da63 39 wrefresh (handle.get ());
5b81daba 40}
c906108c 41
af101512 42/* Draw a border arround the window. */
2c0b251b 43static void
ab0e1f1a 44box_win (struct tui_win_info *win_info,
072272ce 45 bool highlight_flag)
c906108c 46{
108e13ab
TT
47 WINDOW *win;
48 int attrs;
af101512 49
7523da63 50 win = win_info->handle.get ();
108e13ab
TT
51 if (highlight_flag)
52 attrs = tui_active_border_attrs;
53 else
54 attrs = tui_border_attrs;
af101512 55
a2a7af0c
TT
56 /* tui_apply_style resets the style entirely, so be sure to call it
57 before applying ATTRS. */
58 tui_apply_style (win, (highlight_flag
59 ? tui_active_border_style.style ()
60 : tui_border_style.style ()));
108e13ab 61 wattron (win, attrs);
8b9cf735 62#ifdef HAVE_WBORDER
108e13ab
TT
63 wborder (win, tui_border_vline, tui_border_vline,
64 tui_border_hline, tui_border_hline,
65 tui_border_ulcorner, tui_border_urcorner,
66 tui_border_llcorner, tui_border_lrcorner);
8b9cf735 67#else
108e13ab 68 box (win, tui_border_vline, tui_border_hline);
8b9cf735 69#endif
108e13ab 70 if (!win_info->title.empty ())
8634b462
TT
71 {
72 /* Emit "+-TITLE-+" -- so 2 characters on the right and 2 on
73 the left. */
74 int max_len = win_info->width - 2 - 2;
75
76 if (win_info->title.size () <= max_len)
77 mvwaddstr (win, 0, 3, win_info->title.c_str ());
78 else
79 {
80 std::string truncated
81 = "..." + win_info->title.substr (win_info->title.size ()
82 - max_len + 3);
83 mvwaddstr (win, 0, 3, truncated.c_str ());
84 }
85 }
108e13ab 86 wattroff (win, attrs);
a2a7af0c 87 tui_apply_style (win, ui_file_style ());
af101512 88}
c906108c
SS
89
90
c906108c 91void
5b6fe301 92tui_unhighlight_win (struct tui_win_info *win_info)
c906108c 93{
e5908723 94 if (win_info != NULL
0b026263 95 && win_info->can_box ()
cb2ce893 96 && win_info->handle != NULL)
c906108c 97 {
072272ce 98 box_win (win_info, false);
cf82af05 99 win_info->refresh_window ();
214a5cbe 100 win_info->set_highlight (false);
c906108c 101 }
ec7d9e56 102}
c906108c
SS
103
104
c906108c 105void
5b6fe301 106tui_highlight_win (struct tui_win_info *win_info)
c906108c 107{
6d012f14 108 if (win_info != NULL
0b026263 109 && win_info->can_box ()
cb2ce893 110 && win_info->handle != NULL)
c906108c 111 {
072272ce 112 box_win (win_info, true);
cf82af05 113 win_info->refresh_window ();
214a5cbe 114 win_info->set_highlight (true);
c906108c 115 }
ec7d9e56 116}
c906108c 117
c906108c 118void
b4ef5aeb 119tui_win_info::check_and_display_highlight_if_needed ()
c906108c 120{
0b026263 121 if (can_box ())
c906108c 122 {
b4ef5aeb
TT
123 if (is_highlighted)
124 tui_highlight_win (this);
c906108c 125 else
b4ef5aeb 126 tui_unhighlight_win (this);
c906108c 127 }
ec7d9e56 128}
c906108c
SS
129
130
c906108c 131void
ab0e1f1a 132tui_gen_win_info::make_window ()
c906108c 133{
fb3184d8 134 handle.reset (newwin (height, width, y, x));
cafb3438 135 if (handle != NULL)
7523da63 136 scrollok (handle.get (), TRUE);
bc712bbf 137}
c906108c 138
ab0e1f1a
TT
139void
140tui_win_info::make_window ()
141{
142 tui_gen_win_info::make_window ();
143 if (handle != NULL && can_box ())
072272ce 144 box_win (this, false);
ab0e1f1a 145}
c906108c 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)
ab0e1f1a 157 make_window ();
8e3cfd09 158 else
7523da63 159 handle.reset (nullptr);
ec7d9e56 160}
c906108c 161
3f3ffe54 162/* See tui-wingeneral.h. */
ec7d9e56 163
ec7d9e56
AC
164void
165tui_make_all_invisible (void)
166{
3f3ffe54
TT
167 for (tui_win_info *win_info : all_tui_windows ())
168 win_info->make_visible (false);
ec7d9e56
AC
169}
170
171/* Function to refresh all the windows currently displayed. */
c906108c 172
c906108c 173void
1ce3e844 174tui_refresh_all ()
c906108c 175{
3add462f 176 struct tui_locator_window *locator = tui_locator_win_info_ptr ();
c906108c 177
1ce3e844 178 for (tui_win_info *win_info : all_tui_windows ())
c906108c 179 {
2d83e710 180 if (win_info->is_visible ())
fd6c75ee 181 win_info->refresh_window ();
c906108c 182 }
2d83e710 183 if (locator->is_visible ())
fd6c75ee 184 locator->refresh_window ();
6ba8e26f 185}
This page took 1.972373 seconds and 4 git commands to generate.