aboutsummaryrefslogtreecommitdiff
path: root/gdb/tui/tui-data.h
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2020-02-22 11:48:26 -0700
committerTom Tromey <tom@tromey.com>2020-02-22 11:48:34 -0700
commit7eed1a8e8386e1b93c51768855c32ddae6f088ae (patch)
tree674c7c3a76e3a1f2f1eb1a1ce6d29467d5a03009 /gdb/tui/tui-data.h
parent7c043ba695a3cee067554b1e871e60f7934512b4 (diff)
downloadfsf-binutils-gdb-7eed1a8e8386e1b93c51768855c32ddae6f088ae.zip
fsf-binutils-gdb-7eed1a8e8386e1b93c51768855c32ddae6f088ae.tar.gz
fsf-binutils-gdb-7eed1a8e8386e1b93c51768855c32ddae6f088ae.tar.bz2
Change TUI window iteration
This changes the TUI to track all the instantiated windows in a new global vector. After this, iteration over TUI windows is done by simply iterating over this vector. This approach makes it simpler to define new window types. In particular, a subsequent patch will add the ability to define a TUI window from Python. Note that this series will not remove tui_win_list. This will continue to exist in parallel, only because it was simpler to leave this alone. Perhaps it could still be removed in the future. gdb/ChangeLog 2020-02-22 Tom Tromey <tom@tromey.com> * tui/tui-winsource.h (struct tui_source_window_iterator) <inner_iterator>: New etytypedef. <tui_source_window_iterator>: Take "end" parameter. <tui_source_window_iterator>: Take iterator. <operator*, advance>: Update. <m_iter>: Change type. <m_end>: New field. (struct tui_source_windows) <begin, end>: Update. * tui/tui-layout.c (tui_windows): New global. (tui_apply_current_layout): Clear tui_windows. (tui_layout_window::apply): Update tui_windows. * tui/tui-data.h (tui_windows): Declare. (all_tui_windows): Now inline function. (class tui_window_iterator, struct all_tui_windows): Remove. Change-Id: I6ab77976d6326f427178f725434f8f82046e0bbf
Diffstat (limited to 'gdb/tui/tui-data.h')
-rw-r--r--gdb/tui/tui-data.h74
1 files changed, 8 insertions, 66 deletions
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index e15ac58..a460137 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -238,74 +238,16 @@ extern struct tui_win_info *tui_win_list[MAX_MAJOR_WINDOWS];
#define TUI_DATA_WIN ((tui_data_window *) tui_win_list[DATA_WIN])
#define TUI_CMD_WIN ((tui_cmd_window *) tui_win_list[CMD_WIN])
-/* An iterator that iterates over all windows. */
+/* All the windows that are currently instantiated, in layout
+ order. */
+extern std::vector<tui_win_info *> tui_windows;
-class tui_window_iterator
+/* Return a range adapter for iterating over TUI windows. */
+static inline std::vector<tui_win_info *> &
+all_tui_windows ()
{
-public:
-
- typedef tui_window_iterator self_type;
- typedef struct tui_win_info *value_type;
- typedef struct tui_win_info *&reference;
- typedef struct tui_win_info **pointer;
- typedef std::forward_iterator_tag iterator_category;
- typedef int difference_type;
-
- explicit tui_window_iterator (enum tui_win_type type)
- : m_type (type)
- {
- advance ();
- }
-
- tui_window_iterator ()
- : m_type (MAX_MAJOR_WINDOWS)
- {
- }
-
- bool operator!= (const self_type &other) const
- {
- return m_type != other.m_type;
- }
-
- value_type operator* () const
- {
- gdb_assert (m_type < MAX_MAJOR_WINDOWS);
- return tui_win_list[m_type];
- }
-
- self_type &operator++ ()
- {
- ++m_type;
- advance ();
- return *this;
- }
-
-private:
-
- void advance ()
- {
- while (m_type < MAX_MAJOR_WINDOWS && tui_win_list[m_type] == nullptr)
- ++m_type;
- }
-
- int m_type;
-};
-
-/* A range adapter for iterating over TUI windows. */
-
-struct all_tui_windows
-{
- tui_window_iterator begin () const
- {
- return tui_window_iterator (SRC_WIN);
- }
-
- tui_window_iterator end () const
- {
- return tui_window_iterator ();
- }
-};
-
+ return tui_windows;
+}
/* Data Manipulation Functions. */
extern int tui_term_height (void);