GDB (xrefs)
Loading...
Searching...
No Matches
tui-data.c
Go to the documentation of this file.
1/* TUI data manipulation routines.
2
3 Copyright (C) 1998-2023 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 "symtab.h"
24#include "tui/tui.h"
25#include "tui/tui-data.h"
26#include "tui/tui-win.h"
27#include "tui/tui-wingeneral.h"
28#include "tui/tui-winsource.h"
29#include "gdb_curses.h"
30#include <algorithm>
31
33
35static struct tui_win_info *win_with_focus = NULL;
36
37static bool win_resized = false;
38
39/* Answer a whether the terminal window has been resized or not. */
40bool
42{
43 return win_resized;
44}
45
46
47/* Set a whether the terminal window has been resized or not. */
48void
50{
51 win_resized = resized;
52}
53
54
55/* Answer the window with the logical focus. */
56struct tui_win_info *
58{
59 return win_with_focus;
60}
61
62
63/* Set the logical focus to win_info. */
64void
66{
67 if (win_info != NULL)
68 {
70 win_with_focus = win_info;
71 tui_highlight_win (win_info);
72 }
73}
74
75
76/* Accessor for the term_height. */
77int
79{
80 return term_height;
81}
82
83
84/* Mutator for the term height. */
85void
87{
88 term_height = h;
89}
90
91
92/* Accessor for the term_width. */
93int
95{
96 return term_width;
97}
98
99
100/* Mutator for the term_width. */
101void
103{
104 term_width = w;
105}
106
107
108/* Answer the next window in the list, cycling back to the top if
109 necessary. */
110struct tui_win_info *
111tui_next_win (struct tui_win_info *cur_win)
112{
113 auto iter = std::find (tui_windows.begin (), tui_windows.end (), cur_win);
114 gdb_assert (iter != tui_windows.end ());
115
116 gdb_assert (cur_win->can_focus ());
117 /* This won't loop forever since we can't have just an un-focusable
118 window. */
119 while (true)
120 {
121 ++iter;
122 if (iter == tui_windows.end ())
123 iter = tui_windows.begin ();
124 if ((*iter)->can_focus ())
125 break;
126 }
127
128 return *iter;
129}
130
131
132/* Answer the prev window in the list, cycling back to the bottom if
133 necessary. */
134struct tui_win_info *
135tui_prev_win (struct tui_win_info *cur_win)
136{
137 auto iter = std::find (tui_windows.rbegin (), tui_windows.rend (), cur_win);
138 gdb_assert (iter != tui_windows.rend ());
139
140 gdb_assert (cur_win->can_focus ());
141 /* This won't loop forever since we can't have just an un-focusable
142 window. */
143 while (true)
144 {
145 ++iter;
146 if (iter == tui_windows.rend ())
147 iter = tui_windows.rbegin ();
148 if ((*iter)->can_focus ())
149 break;
150 }
151
152 return *iter;
153}
154
155/* See tui-data.h. */
156
157void
158tui_win_info::set_title (std::string &&new_title)
159{
160 if (m_title != new_title)
161 {
162 m_title = new_title;
164 }
165}
166
167void
virtual bool can_focus() const
Definition tui-data.h:103
void check_and_display_highlight_if_needed()
std::string m_title
Definition tui-data.h:182
virtual void rerender()
Definition tui-data.c:168
void set_title(std::string &&new_title)
Definition tui-data.c:158
void tui_set_win_focus_to(struct tui_win_info *win_info)
Definition tui-data.c:65
int tui_term_height(void)
Definition tui-data.c:78
int tui_term_width(void)
Definition tui-data.c:94
void tui_set_term_width_to(int w)
Definition tui-data.c:102
static int term_height
Definition tui-data.c:34
struct tui_win_info * tui_prev_win(struct tui_win_info *cur_win)
Definition tui-data.c:135
void tui_set_win_resized_to(bool resized)
Definition tui-data.c:49
static int term_width
Definition tui-data.c:34
static struct tui_win_info * win_with_focus
Definition tui-data.c:35
struct tui_win_info * tui_win_list[MAX_MAJOR_WINDOWS]
Definition tui-data.c:32
struct tui_win_info * tui_next_win(struct tui_win_info *cur_win)
Definition tui-data.c:111
bool tui_win_resized()
Definition tui-data.c:41
static bool win_resized
Definition tui-data.c:37
void tui_set_term_height_to(int h)
Definition tui-data.c:86
struct tui_win_info * tui_win_with_focus(void)
Definition tui-data.c:57
std::vector< tui_win_info * > tui_windows
Definition tui-layout.c:65
void tui_unhighlight_win(struct tui_win_info *win_info)
void tui_highlight_win(struct tui_win_info *win_info)
@ MAX_MAJOR_WINDOWS
Definition tui.h:60