1 /* TUI data manipulation routines.
3 Copyright (C) 1998-2019 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/>. */
25 #include "tui/tui-data.h"
26 #include "tui/tui-wingeneral.h"
27 #include "tui/tui-winsource.h"
28 #include "gdb_curses.h"
30 /****************************
31 ** GLOBAL DECLARATIONS
32 ****************************/
33 struct tui_win_info
*tui_win_list
[MAX_MAJOR_WINDOWS
];
35 /***************************
37 ****************************/
38 static int term_height
, term_width
;
39 static struct tui_locator_window _locator
;
40 static std::vector
<tui_source_window_base
*> source_windows
;
41 static struct tui_win_info
*win_with_focus
= NULL
;
43 static int win_resized
= FALSE
;
46 /*********************************
48 **********************************/
51 tui_win_is_auxiliary (enum tui_win_type win_type
)
53 return (win_type
> MAX_MAJOR_WINDOWS
);
56 /******************************************
57 ** ACCESSORS & MUTATORS FOR PRIVATE DATA
58 ******************************************/
60 /* Answer a whether the terminal window has been resized or not. */
62 tui_win_resized (void)
68 /* Set a whether the terminal window has been resized or not. */
70 tui_set_win_resized_to (int resized
)
72 win_resized
= resized
;
76 /* Answer the window with the logical focus. */
78 tui_win_with_focus (void)
80 return win_with_focus
;
84 /* Set the window that has the logical focus. */
86 tui_set_win_with_focus (struct tui_win_info
*win_info
)
88 win_with_focus
= win_info
;
92 /* Accessor for the current source window. Usually there is only one
93 source window (either source or disassembly), but both can be
94 displayed at the same time. */
95 std::vector
<tui_source_window_base
*> &
98 return source_windows
;
102 /* Clear the list of source windows. Usually there is only one source
103 window (either source or disassembly), but both can be displayed at
106 tui_clear_source_windows ()
108 source_windows
.clear ();
112 /* Clear the pertinent detail in the source windows. */
114 tui_clear_source_windows_detail ()
116 for (tui_source_window_base
*win
: tui_source_windows ())
117 win
->clear_detail ();
121 /* Add a window to the list of source windows. Usually there is only
122 one source window (either source or disassembly), but both can be
123 displayed at the same time. */
125 tui_add_to_source_windows (struct tui_source_window_base
*win_info
)
127 if (source_windows
.size () < 2)
128 source_windows
.push_back (win_info
);
131 /* Accessor for the locator win info. Answers a pointer to the static
132 locator win info struct. */
133 struct tui_locator_window
*
134 tui_locator_win_info_ptr (void)
140 /* Accessor for the term_height. */
142 tui_term_height (void)
148 /* Mutator for the term height. */
150 tui_set_term_height_to (int h
)
156 /* Accessor for the term_width. */
158 tui_term_width (void)
164 /* Mutator for the term_width. */
166 tui_set_term_width_to (int w
)
172 /*****************************
173 ** OTHER PUBLIC FUNCTIONS
174 *****************************/
177 /* Answer the next window in the list, cycling back to the top if
179 struct tui_win_info
*
180 tui_next_win (struct tui_win_info
*cur_win
)
182 int type
= cur_win
->type
;
183 struct tui_win_info
*next_win
= NULL
;
185 if (cur_win
->type
== CMD_WIN
)
188 type
= cur_win
->type
+ 1;
189 while (type
!= cur_win
->type
&& (next_win
== NULL
))
191 if (tui_win_list
[type
]
192 && tui_win_list
[type
]->is_visible
)
193 next_win
= tui_win_list
[type
];
207 /* Answer the prev window in the list, cycling back to the bottom if
209 struct tui_win_info
*
210 tui_prev_win (struct tui_win_info
*cur_win
)
212 int type
= cur_win
->type
;
213 struct tui_win_info
*prev
= NULL
;
215 if (cur_win
->type
== SRC_WIN
)
218 type
= cur_win
->type
- 1;
219 while (type
!= cur_win
->type
&& (prev
== NULL
))
221 if (tui_win_list
[type
]
222 && tui_win_list
[type
]->is_visible
)
223 prev
= tui_win_list
[type
];
237 /* Answer the window represented by name. */
238 struct tui_win_info
*
239 tui_partial_win_by_name (const char *name
)
243 for (tui_win_info
*item
: all_tui_windows ())
245 const char *cur_name
= item
->name ();
247 if (strlen (name
) <= strlen (cur_name
)
248 && startswith (cur_name
, name
))
258 tui_initialize_static_data ()
260 tui_gen_win_info
*win
= tui_locator_win_info_ptr ();
265 win
->viewport_height
=
266 win
->last_visible_line
= 0;
268 win
->is_visible
= false;
273 tui_win_info::tui_win_info (enum tui_win_type type
)
274 : tui_gen_win_info (type
)
278 tui_gen_win_info::~tui_gen_win_info ()
280 tui_delete_win (handle
);