Rename a private data member in tui_source_window
[deliverable/binutils-gdb.git] / gdb / tui / tui-wingeneral.c
... / ...
CommitLineData
1/* General window behavior.
2
3 Copyright (C) 1998-2019 Free Software Foundation, Inc.
4
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
11 the Free Software Foundation; either version 3 of the License, or
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
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21
22#include "defs.h"
23#include "tui/tui.h"
24#include "tui/tui-data.h"
25#include "tui/tui-wingeneral.h"
26#include "tui/tui-win.h"
27#include "tui/tui-stack.h"
28
29#include "gdb_curses.h"
30
31/***********************
32** PUBLIC FUNCTIONS
33***********************/
34
35/* See tui-data.h. */
36
37void
38tui_gen_win_info::refresh_window ()
39{
40 if (handle != NULL)
41 wrefresh (handle);
42}
43
44/* Function to delete the curses window, checking for NULL. */
45void
46tui_delete_win (WINDOW *window)
47{
48 if (window != NULL)
49 delwin (window);
50}
51
52
53/* Draw a border arround the window. */
54static void
55box_win (struct tui_win_info *win_info,
56 bool highlight_flag)
57{
58 WINDOW *win;
59 int attrs;
60
61 win = win_info->handle;
62 if (highlight_flag)
63 attrs = tui_active_border_attrs;
64 else
65 attrs = tui_border_attrs;
66
67 wattron (win, attrs);
68#ifdef HAVE_WBORDER
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);
73#else
74 box (win, tui_border_vline, tui_border_hline);
75#endif
76 if (!win_info->title.empty ())
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 }
92 wattroff (win, attrs);
93}
94
95
96void
97tui_unhighlight_win (struct tui_win_info *win_info)
98{
99 if (win_info != NULL
100 && win_info->can_highlight
101 && win_info->handle != NULL)
102 {
103 box_win (win_info, false);
104 win_info->refresh_window ();
105 win_info->set_highlight (false);
106 }
107}
108
109
110void
111tui_highlight_win (struct tui_win_info *win_info)
112{
113 if (win_info != NULL
114 && win_info->can_highlight
115 && win_info->handle != NULL)
116 {
117 box_win (win_info, true);
118 win_info->refresh_window ();
119 win_info->set_highlight (true);
120 }
121}
122
123void
124tui_win_info::check_and_display_highlight_if_needed ()
125{
126 if (can_highlight)
127 {
128 if (is_highlighted)
129 tui_highlight_win (this);
130 else
131 tui_unhighlight_win (this);
132 }
133}
134
135
136void
137tui_gen_win_info::make_window ()
138{
139 handle = newwin (height, width, origin.y, origin.x);
140 if (handle != NULL)
141 scrollok (handle, TRUE);
142}
143
144void
145tui_win_info::make_window ()
146{
147 tui_gen_win_info::make_window ();
148 if (handle != NULL && can_box ())
149 box_win (this, false);
150}
151
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. */
155void
156tui_gen_win_info::make_visible (bool visible)
157{
158 if (is_visible () == visible)
159 return;
160
161 if (visible)
162 make_window ();
163 else
164 {
165 tui_delete_win (handle);
166 handle = NULL;
167 }
168}
169
170/* See tui-wingeneral.h. */
171
172void
173tui_make_all_invisible (void)
174{
175 for (tui_win_info *win_info : all_tui_windows ())
176 win_info->make_visible (false);
177}
178
179/* Function to refresh all the windows currently displayed. */
180
181void
182tui_refresh_all ()
183{
184 struct tui_locator_window *locator = tui_locator_win_info_ptr ();
185
186 for (tui_win_info *win_info : all_tui_windows ())
187 {
188 if (win_info->is_visible ())
189 win_info->refresh_window ();
190 }
191 if (locator->is_visible ())
192 locator->refresh_window ();
193}
194
195
196/*********************************
197** Local Static Functions
198*********************************/
This page took 0.023395 seconds and 4 git commands to generate.