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 std::vector
<tui_source_window_base
*> source_windows
;
40 static struct tui_win_info
*win_with_focus
= NULL
;
42 static int win_resized
= FALSE
;
45 /*********************************
47 **********************************/
50 tui_win_is_auxiliary (enum tui_win_type win_type
)
52 return (win_type
> MAX_MAJOR_WINDOWS
);
55 /******************************************
56 ** ACCESSORS & MUTATORS FOR PRIVATE DATA
57 ******************************************/
59 /* Answer a whether the terminal window has been resized or not. */
61 tui_win_resized (void)
67 /* Set a whether the terminal window has been resized or not. */
69 tui_set_win_resized_to (int resized
)
71 win_resized
= resized
;
75 /* Answer the window with the logical focus. */
77 tui_win_with_focus (void)
79 return win_with_focus
;
83 /* Set the window that has the logical focus. */
85 tui_set_win_with_focus (struct tui_win_info
*win_info
)
87 win_with_focus
= win_info
;
91 /* Accessor for the current source window. Usually there is only one
92 source window (either source or disassembly), but both can be
93 displayed at the same time. */
94 std::vector
<tui_source_window_base
*> &
97 return source_windows
;
101 /* Clear the list of source windows. Usually there is only one source
102 window (either source or disassembly), but both can be displayed at
105 tui_clear_source_windows ()
107 source_windows
.clear ();
111 /* Clear the pertinent detail in the source windows. */
113 tui_clear_source_windows_detail ()
115 for (tui_source_window_base
*win
: tui_source_windows ())
116 win
->clear_detail ();
120 /* Add a window to the list of source windows. Usually there is only
121 one source window (either source or disassembly), but both can be
122 displayed at the same time. */
124 tui_add_to_source_windows (struct tui_source_window_base
*win_info
)
126 if (source_windows
.size () < 2)
127 source_windows
.push_back (win_info
);
130 /* Accessor for the term_height. */
132 tui_term_height (void)
138 /* Mutator for the term height. */
140 tui_set_term_height_to (int h
)
146 /* Accessor for the term_width. */
148 tui_term_width (void)
154 /* Mutator for the term_width. */
156 tui_set_term_width_to (int w
)
162 /*****************************
163 ** OTHER PUBLIC FUNCTIONS
164 *****************************/
167 /* Answer the next window in the list, cycling back to the top if
169 struct tui_win_info
*
170 tui_next_win (struct tui_win_info
*cur_win
)
172 int type
= cur_win
->type
;
173 struct tui_win_info
*next_win
= NULL
;
175 if (cur_win
->type
== CMD_WIN
)
178 type
= cur_win
->type
+ 1;
179 while (type
!= cur_win
->type
&& (next_win
== NULL
))
181 if (tui_win_list
[type
]
182 && tui_win_list
[type
]->is_visible
)
183 next_win
= tui_win_list
[type
];
197 /* Answer the prev window in the list, cycling back to the bottom if
199 struct tui_win_info
*
200 tui_prev_win (struct tui_win_info
*cur_win
)
202 int type
= cur_win
->type
;
203 struct tui_win_info
*prev
= NULL
;
205 if (cur_win
->type
== SRC_WIN
)
208 type
= cur_win
->type
- 1;
209 while (type
!= cur_win
->type
&& (prev
== NULL
))
211 if (tui_win_list
[type
]
212 && tui_win_list
[type
]->is_visible
)
213 prev
= tui_win_list
[type
];
227 /* Answer the window represented by name. */
228 struct tui_win_info
*
229 tui_partial_win_by_name (const char *name
)
233 for (tui_win_info
*item
: all_tui_windows ())
235 const char *cur_name
= item
->name ();
237 if (strlen (name
) <= strlen (cur_name
)
238 && startswith (cur_name
, name
))
246 /* See tui-data.h. */
249 tui_delete_invisible_windows ()
251 for (int win_type
= SRC_WIN
; (win_type
< MAX_MAJOR_WINDOWS
); win_type
++)
253 if (tui_win_list
[win_type
] != NULL
254 && !tui_win_list
[win_type
]->is_visible
)
256 /* This should always be made visible before a call to this
258 gdb_assert (win_type
!= CMD_WIN
);
260 if (win_with_focus
== tui_win_list
[win_type
])
261 win_with_focus
= nullptr;
263 delete tui_win_list
[win_type
];
264 tui_win_list
[win_type
] = NULL
;
269 tui_win_info::tui_win_info (enum tui_win_type type
)
270 : tui_gen_win_info (type
)
274 tui_gen_win_info::~tui_gen_win_info ()
276 tui_delete_win (handle
);
This page took 0.035565 seconds and 5 git commands to generate.