1 /* General window behavior.
3 Copyright (C) 1998-2024 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/>. */
22 #include "tui/tui-data.h"
23 #include "tui/tui-io.h"
24 #include "tui/tui-wingeneral.h"
25 #include "tui/tui-win.h"
26 #include "cli/cli-style.h"
28 #include "gdb_curses.h"
30 /* This is true when there is a live instance of tui_batch_rendering.
31 The outermost tui_batch_rendering will cause a flush to the
34 static bool suppress_output
;
38 tui_batch_rendering::tui_batch_rendering ()
39 : m_saved_suppress (suppress_output
)
41 suppress_output
= true;
46 tui_batch_rendering::~tui_batch_rendering ()
48 suppress_output
= m_saved_suppress
;
56 tui_win_info::refresh_window ()
59 wnoutrefresh (handle
.get ());
62 /* Draw a border around the window. */
64 box_win (struct tui_win_info
*win_info
,
70 win
= win_info
->handle
.get ();
72 attrs
= tui_active_border_attrs
;
74 attrs
= tui_border_attrs
;
76 /* tui_apply_style resets the style entirely, so be sure to call it
77 before applying ATTRS. */
79 tui_apply_style (win
, (highlight_flag
80 ? tui_active_border_style
.style ()
81 : tui_border_style
.style ()));
83 wborder (win
, tui_border_vline
, tui_border_vline
,
84 tui_border_hline
, tui_border_hline
,
85 tui_border_ulcorner
, tui_border_urcorner
,
86 tui_border_llcorner
, tui_border_lrcorner
);
87 if (!win_info
->title ().empty ())
89 /* Emit "+-TITLE-+" -- so 2 characters on the right and 2 on
91 int max_len
= win_info
->width
- win_info
->box_size () - 2;
93 if (win_info
->title ().size () <= max_len
)
94 mvwaddstr (win
, 0, 2, win_info
->title ().c_str ());
98 = "..." + win_info
->title ().substr (win_info
->title ().size ()
100 mvwaddstr (win
, 0, 2, truncated
.c_str ());
103 wattroff (win
, attrs
);
104 tui_apply_style (win
, ui_file_style ());
109 tui_unhighlight_win (struct tui_win_info
*win_info
)
112 && win_info
->can_box ()
113 && win_info
->handle
!= NULL
)
115 box_win (win_info
, false);
116 win_info
->refresh_window ();
117 win_info
->set_highlight (false);
123 tui_highlight_win (struct tui_win_info
*win_info
)
126 && win_info
->can_box ()
127 && win_info
->handle
!= NULL
)
129 box_win (win_info
, true);
130 win_info
->refresh_window ();
131 win_info
->set_highlight (true);
136 tui_win_info::check_and_display_highlight_if_needed ()
141 tui_highlight_win (this);
143 tui_unhighlight_win (this);
148 tui_win_info::make_window ()
150 handle
.reset (newwin (height
, width
, y
, x
));
153 scrollok (handle
.get (), TRUE
);
155 box_win (this, false);
159 /* We can't really make windows visible, or invisible. So we have to
160 delete the entire window when making it invisible, and create it
161 again when making it visible. */
163 tui_win_info::make_visible (bool visible
)
165 if (is_visible () == visible
)
171 handle
.reset (nullptr);