Rename a private data member in tui_source_window
[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)
772f3f03 41 wrefresh (handle);
5b81daba 42}
c906108c 43
1cc6d956 44/* Function to delete the curses window, checking for NULL. */
c906108c 45void
5b6fe301 46tui_delete_win (WINDOW *window)
c906108c 47{
cafb3438 48 if (window != NULL)
c906108c 49 delwin (window);
ec7d9e56 50}
c906108c
SS
51
52
af101512 53/* Draw a border arround the window. */
2c0b251b 54static void
ab0e1f1a 55box_win (struct tui_win_info *win_info,
072272ce 56 bool highlight_flag)
c906108c 57{
108e13ab
TT
58 WINDOW *win;
59 int attrs;
af101512 60
108e13ab
TT
61 win = win_info->handle;
62 if (highlight_flag)
63 attrs = tui_active_border_attrs;
64 else
65 attrs = tui_border_attrs;
af101512 66
108e13ab 67 wattron (win, attrs);
8b9cf735 68#ifdef HAVE_WBORDER
108e13ab
TT
69 wborder (win, tui_border_vline, tui_border_vline,
70 tui_border_hline, tui_border_hline,
71 tui_border_ulcorner, tui_border_urcorner,
72 tui_border_llcorner, tui_border_lrcorner);
8b9cf735 73#else
108e13ab 74 box (win, tui_border_vline, tui_border_hline);
8b9cf735 75#endif
108e13ab 76 if (!win_info->title.empty ())
8634b462
TT
77 {
78 /* Emit "+-TITLE-+" -- so 2 characters on the right and 2 on
79 the left. */
80 int max_len = win_info->width - 2 - 2;
81
82 if (win_info->title.size () <= max_len)
83 mvwaddstr (win, 0, 3, win_info->title.c_str ());
84 else
85 {
86 std::string truncated
87 = "..." + win_info->title.substr (win_info->title.size ()
88 - max_len + 3);
89 mvwaddstr (win, 0, 3, truncated.c_str ());
90 }
91 }
108e13ab 92 wattroff (win, attrs);
af101512 93}
c906108c
SS
94
95
c906108c 96void
5b6fe301 97tui_unhighlight_win (struct tui_win_info *win_info)
c906108c 98{
e5908723 99 if (win_info != NULL
bbc228ee 100 && win_info->can_highlight
cb2ce893 101 && win_info->handle != NULL)
c906108c 102 {
072272ce 103 box_win (win_info, false);
cf82af05 104 win_info->refresh_window ();
214a5cbe 105 win_info->set_highlight (false);
c906108c 106 }
ec7d9e56 107}
c906108c
SS
108
109
c906108c 110void
5b6fe301 111tui_highlight_win (struct tui_win_info *win_info)
c906108c 112{
6d012f14
AC
113 if (win_info != NULL
114 && win_info->can_highlight
cb2ce893 115 && win_info->handle != NULL)
c906108c 116 {
072272ce 117 box_win (win_info, true);
cf82af05 118 win_info->refresh_window ();
214a5cbe 119 win_info->set_highlight (true);
c906108c 120 }
ec7d9e56 121}
c906108c 122
c906108c 123void
b4ef5aeb 124tui_win_info::check_and_display_highlight_if_needed ()
c906108c 125{
b4ef5aeb 126 if (can_highlight)
c906108c 127 {
b4ef5aeb
TT
128 if (is_highlighted)
129 tui_highlight_win (this);
c906108c 130 else
b4ef5aeb 131 tui_unhighlight_win (this);
c906108c 132 }
ec7d9e56 133}
c906108c
SS
134
135
c906108c 136void
ab0e1f1a 137tui_gen_win_info::make_window ()
c906108c 138{
ab0e1f1a 139 handle = newwin (height, width, origin.y, origin.x);
cafb3438 140 if (handle != NULL)
ab0e1f1a 141 scrollok (handle, TRUE);
bc712bbf 142}
c906108c 143
ab0e1f1a
TT
144void
145tui_win_info::make_window ()
146{
147 tui_gen_win_info::make_window ();
148 if (handle != NULL && can_box ())
072272ce 149 box_win (this, false);
ab0e1f1a 150}
c906108c 151
ec7d9e56
AC
152/* We can't really make windows visible, or invisible. So we have to
153 delete the entire window when making it visible, and create it
154 again when making it visible. */
48a3bd16
TT
155void
156tui_gen_win_info::make_visible (bool visible)
c906108c 157{
2d83e710 158 if (is_visible () == visible)
8e3cfd09 159 return;
8e3cfd09 160
c906108c 161 if (visible)
ab0e1f1a 162 make_window ();
8e3cfd09 163 else
c906108c 164 {
48a3bd16
TT
165 tui_delete_win (handle);
166 handle = NULL;
c906108c 167 }
ec7d9e56 168}
c906108c 169
3f3ffe54 170/* See tui-wingeneral.h. */
ec7d9e56 171
ec7d9e56
AC
172void
173tui_make_all_invisible (void)
174{
3f3ffe54
TT
175 for (tui_win_info *win_info : all_tui_windows ())
176 win_info->make_visible (false);
ec7d9e56
AC
177}
178
179/* Function to refresh all the windows currently displayed. */
c906108c 180
c906108c 181void
1ce3e844 182tui_refresh_all ()
c906108c 183{
3add462f 184 struct tui_locator_window *locator = tui_locator_win_info_ptr ();
c906108c 185
1ce3e844 186 for (tui_win_info *win_info : all_tui_windows ())
c906108c 187 {
2d83e710 188 if (win_info->is_visible ())
fd6c75ee 189 win_info->refresh_window ();
c906108c 190 }
2d83e710 191 if (locator->is_visible ())
fd6c75ee 192 locator->refresh_window ();
6ba8e26f 193}
c906108c
SS
194
195
196/*********************************
197** Local Static Functions
198*********************************/
This page took 2.094697 seconds and 4 git commands to generate.