arm, objdump: print obsolote warning when 26-bit set in instructions
[binutils-gdb.git] / gdb / tui / tui-wingeneral.c
blob369d1529f94a54547a56d1661fcf976e82c8f9b3
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
32 screen. */
34 static bool suppress_output;
36 /* See tui-data.h. */
38 tui_batch_rendering::tui_batch_rendering ()
39 : m_saved_suppress (suppress_output)
41 suppress_output = true;
44 /* See tui-data.h. */
46 tui_batch_rendering::~tui_batch_rendering ()
48 suppress_output = m_saved_suppress;
49 if (!suppress_output)
50 doupdate ();
53 /* See tui-data.h. */
55 void
56 tui_win_info::refresh_window ()
58 if (handle != NULL)
59 wnoutrefresh (handle.get ());
62 /* Draw a border around the window. */
63 static void
64 box_win (struct tui_win_info *win_info,
65 bool highlight_flag)
67 WINDOW *win;
68 int attrs;
70 win = win_info->handle.get ();
71 if (highlight_flag)
72 attrs = tui_active_border_attrs;
73 else
74 attrs = tui_border_attrs;
76 /* tui_apply_style resets the style entirely, so be sure to call it
77 before applying ATTRS. */
78 if (cli_styling)
79 tui_apply_style (win, (highlight_flag
80 ? tui_active_border_style.style ()
81 : tui_border_style.style ()));
82 wattron (win, attrs);
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
90 the left. */
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 ());
95 else
97 std::string truncated
98 = "..." + win_info->title ().substr (win_info->title ().size ()
99 - max_len + 3);
100 mvwaddstr (win, 0, 2, truncated.c_str ());
103 wattroff (win, attrs);
104 tui_apply_style (win, ui_file_style ());
108 void
109 tui_unhighlight_win (struct tui_win_info *win_info)
111 if (win_info != NULL
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);
122 void
123 tui_highlight_win (struct tui_win_info *win_info)
125 if (win_info != NULL
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);
135 void
136 tui_win_info::check_and_display_highlight_if_needed ()
138 if (can_box ())
140 if (is_highlighted)
141 tui_highlight_win (this);
142 else
143 tui_unhighlight_win (this);
147 void
148 tui_win_info::make_window ()
150 handle.reset (newwin (height, width, y, x));
151 if (handle != NULL)
153 scrollok (handle.get (), TRUE);
154 if (can_box ())
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. */
162 void
163 tui_win_info::make_visible (bool visible)
165 if (is_visible () == visible)
166 return;
168 if (visible)
169 make_window ();
170 else
171 handle.reset (nullptr);