+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.
+
2020-02-22 Tom Tromey <tom@tromey.com>
PR tui/17850:
#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);
static tui_layout_split *src_regs_layout;
static tui_layout_split *asm_regs_layout;
+/* See tui-data.h. */
+std::vector<tui_win_info *> tui_windows;
+
/* See tui-layout.h. */
void
tui_apply_current_layout ()
{
+ tui_windows.clear ();
applied_layout->apply (0, 0, tui_term_width (), tui_term_height ());
}
height = height_;
gdb_assert (m_window != nullptr);
m_window->resize (height, width, x, y);
+ if (dynamic_cast<tui_win_info *> (m_window) != nullptr)
+ tui_windows.push_back ((tui_win_info *) m_window);
}
/* See tui-layout.h. */
{
public:
+ typedef std::vector<tui_win_info *>::iterator inner_iterator;
+
typedef tui_source_window_iterator self_type;
typedef struct tui_source_window_base *value_type;
typedef struct tui_source_window_base *&reference;
typedef std::forward_iterator_tag iterator_category;
typedef int difference_type;
- explicit tui_source_window_iterator (bool dummy)
- : m_iter (SRC_WIN)
+ explicit tui_source_window_iterator (const inner_iterator &it,
+ const inner_iterator &end)
+ : m_iter (it),
+ m_end (end)
{
advance ();
}
- tui_source_window_iterator ()
- : m_iter (tui_win_type (DISASSEM_WIN + 1))
+ explicit tui_source_window_iterator (const inner_iterator &it)
+ : m_iter (it)
{
}
value_type operator* () const
{
- return (value_type) *m_iter;
+ return dynamic_cast<tui_source_window_base *> (*m_iter);
}
self_type &operator++ ()
void advance ()
{
- tui_window_iterator end;
- while (m_iter != end && *m_iter == nullptr)
+ while (m_iter != m_end
+ && dynamic_cast<tui_source_window_base *> (*m_iter) == nullptr)
++m_iter;
}
- tui_window_iterator m_iter;
+ inner_iterator m_iter;
+ inner_iterator m_end;
};
/* A range adapter for source windows. */
{
tui_source_window_iterator begin () const
{
- return tui_source_window_iterator (true);
+ return tui_source_window_iterator (tui_windows.begin (),
+ tui_windows.end ());
}
tui_source_window_iterator end () const
{
- return tui_source_window_iterator ();
+ return tui_source_window_iterator (tui_windows.end ());
}
};