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 enum tui_layout_type current_layout
= UNDEFINED_LAYOUT
;
39 static int term_height
, term_width
;
40 static struct tui_locator_window _locator
;
41 static std::vector
<tui_source_window_base
*> source_windows
;
42 static struct tui_win_info
*win_with_focus
= NULL
;
44 static int win_resized
= FALSE
;
47 /*********************************
49 **********************************/
52 tui_win_is_auxiliary (enum tui_win_type win_type
)
54 return (win_type
> MAX_MAJOR_WINDOWS
);
57 /******************************************
58 ** ACCESSORS & MUTATORS FOR PRIVATE DATA
59 ******************************************/
61 /* Answer a whether the terminal window has been resized or not. */
63 tui_win_resized (void)
69 /* Set a whether the terminal window has been resized or not. */
71 tui_set_win_resized_to (int resized
)
73 win_resized
= resized
;
77 /* Answer the window with the logical focus. */
79 tui_win_with_focus (void)
81 return win_with_focus
;
85 /* Set the window that has the logical focus. */
87 tui_set_win_with_focus (struct tui_win_info
*win_info
)
89 win_with_focus
= win_info
;
93 /* Accessor for the current source window. Usually there is only one
94 source window (either source or disassembly), but both can be
95 displayed at the same time. */
96 std::vector
<tui_source_window_base
*> &
99 return source_windows
;
103 /* Clear the list of source windows. Usually there is only one source
104 window (either source or disassembly), but both can be displayed at
107 tui_clear_source_windows ()
109 source_windows
.clear ();
113 /* Clear the pertinent detail in the source windows. */
115 tui_clear_source_windows_detail ()
117 for (tui_source_window_base
*win
: tui_source_windows ())
118 win
->clear_detail ();
122 /* Add a window to the list of source windows. Usually there is only
123 one source window (either source or disassembly), but both can be
124 displayed at the same time. */
126 tui_add_to_source_windows (struct tui_source_window_base
*win_info
)
128 if (source_windows
.size () < 2)
129 source_windows
.push_back (win_info
);
132 /* Accessor for the locator win info. Answers a pointer to the static
133 locator win info struct. */
134 struct tui_locator_window
*
135 tui_locator_win_info_ptr (void)
141 /* Accessor for the term_height. */
143 tui_term_height (void)
149 /* Mutator for the term height. */
151 tui_set_term_height_to (int h
)
157 /* Accessor for the term_width. */
159 tui_term_width (void)
165 /* Mutator for the term_width. */
167 tui_set_term_width_to (int w
)
173 /* Accessor for the current layout. */
175 tui_current_layout (void)
177 return current_layout
;
181 /* Mutator for the current layout. */
183 tui_set_current_layout_to (enum tui_layout_type new_layout
)
185 current_layout
= new_layout
;
189 /*****************************
190 ** OTHER PUBLIC FUNCTIONS
191 *****************************/
194 /* Answer the next window in the list, cycling back to the top if
196 struct tui_win_info
*
197 tui_next_win (struct tui_win_info
*cur_win
)
199 int type
= cur_win
->type
;
200 struct tui_win_info
*next_win
= NULL
;
202 if (cur_win
->type
== CMD_WIN
)
205 type
= cur_win
->type
+ 1;
206 while (type
!= cur_win
->type
&& (next_win
== NULL
))
208 if (tui_win_list
[type
]
209 && tui_win_list
[type
]->is_visible
)
210 next_win
= tui_win_list
[type
];
224 /* Answer the prev window in the list, cycling back to the bottom if
226 struct tui_win_info
*
227 tui_prev_win (struct tui_win_info
*cur_win
)
229 int type
= cur_win
->type
;
230 struct tui_win_info
*prev
= NULL
;
232 if (cur_win
->type
== SRC_WIN
)
235 type
= cur_win
->type
- 1;
236 while (type
!= cur_win
->type
&& (prev
== NULL
))
238 if (tui_win_list
[type
]
239 && tui_win_list
[type
]->is_visible
)
240 prev
= tui_win_list
[type
];
254 /* Answer the window represented by name. */
255 struct tui_win_info
*
256 tui_partial_win_by_name (const char *name
)
260 for (tui_win_info
*item
: all_tui_windows ())
262 const char *cur_name
= item
->name ();
264 if (strlen (name
) <= strlen (cur_name
)
265 && startswith (cur_name
, name
))
275 tui_initialize_static_data ()
277 tui_gen_win_info
*win
= tui_locator_win_info_ptr ();
282 win
->viewport_height
=
283 win
->last_visible_line
= 0;
285 win
->is_visible
= false;
290 tui_win_info::tui_win_info (enum tui_win_type type
)
291 : tui_gen_win_info (type
)
295 tui_gen_win_info::~tui_gen_win_info ()
297 tui_delete_win (handle
);