aboutsummaryrefslogtreecommitdiff
path: root/gdb/tui/tui-winsource.h
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2019-07-06 21:19:45 -0600
committerTom Tromey <tom@tromey.com>2019-08-15 12:29:28 -0600
commit3891b65efe614fe2e2f7e75e7f5ec8964f7fd96b (patch)
tree963216261c95876c9e617f0c5f6f91f558cb5e13 /gdb/tui/tui-winsource.h
parentee556432c44dd5dbcf22c4086774bd29ded5b208 (diff)
downloadgdb-3891b65efe614fe2e2f7e75e7f5ec8964f7fd96b.zip
gdb-3891b65efe614fe2e2f7e75e7f5ec8964f7fd96b.tar.gz
gdb-3891b65efe614fe2e2f7e75e7f5ec8964f7fd96b.tar.bz2
Change TUI source window iteration
Currently the TUI does separate bookkeeping to track which source windows exist. It seems better to me to just refer to the list of windows for this, so this patch removes the special handling and instead adds a new iterator. gdb/ChangeLog 2019-08-15 Tom Tromey <tom@tromey.com> * tui/tui-winsource.h (struct tui_source_window_iterator): New. (struct tui_source_windows): New. * tui/tui-winsource.c (tui_display_main): Update. * tui/tui-win.c (tui_resize_all, tui_adjust_win_heights) (new_height_ok, parse_scrolling_args): Update. * tui/tui-layout.c (show_layout, show_data): Update. * tui/tui-data.h (tui_source_windows, tui_clear_source_windows) (tui_add_to_source_windows): Don't declare. * tui/tui-data.c (source_windows, tui_source_windows) (tui_clear_source_windows, tui_add_to_source_windows): Remove.
Diffstat (limited to 'gdb/tui/tui-winsource.h')
-rw-r--r--gdb/tui/tui-winsource.h70
1 files changed, 70 insertions, 0 deletions
diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h
index 6067408..9945e9f 100644
--- a/gdb/tui/tui-winsource.h
+++ b/gdb/tui/tui-winsource.h
@@ -156,6 +156,76 @@ public:
std::vector<tui_source_element> content;
};
+
+/* A wrapper for a TUI window iterator that only iterates over source
+ windows. */
+
+struct tui_source_window_iterator
+{
+public:
+
+ typedef tui_source_window_iterator self_type;
+ typedef struct tui_source_window_base *value_type;
+ typedef struct tui_source_window_base *&reference;
+ typedef struct tui_source_window_base **pointer;
+ typedef std::forward_iterator_tag iterator_category;
+ typedef int difference_type;
+
+ explicit tui_source_window_iterator (bool dummy)
+ : m_iter (SRC_WIN)
+ {
+ advance ();
+ }
+
+ tui_source_window_iterator ()
+ : m_iter (tui_win_type (DISASSEM_WIN + 1))
+ {
+ }
+
+ bool operator!= (const self_type &other) const
+ {
+ return m_iter != other.m_iter;
+ }
+
+ value_type operator* () const
+ {
+ return (value_type) *m_iter;
+ }
+
+ self_type &operator++ ()
+ {
+ ++m_iter;
+ advance ();
+ return *this;
+ }
+
+private:
+
+ void advance ()
+ {
+ tui_window_iterator end;
+ while (m_iter != end && *m_iter == nullptr)
+ ++m_iter;
+ }
+
+ tui_window_iterator m_iter;
+};
+
+/* A range adapter for source windows. */
+
+struct tui_source_windows
+{
+ tui_source_window_iterator begin () const
+ {
+ return tui_source_window_iterator (true);
+ }
+
+ tui_source_window_iterator end () const
+ {
+ return tui_source_window_iterator ();
+ }
+};
+
/* Update the execution windows to show the active breakpoints. This
is called whenever a breakpoint is inserted, removed or has its
state changed. Normally BEING_DELETED is nullptr; if not nullptr,