summaryrefslogtreecommitdiff
path: root/gdb/tui/tui-source.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2019-06-28 14:48:45 -0600
committerTom Tromey <tom@tromey.com>2019-07-17 12:19:04 -0600
commitb73dd8779c0530e91c6e5067eab4cb7ca3f794d5 (patch)
treee717d03900daf50b3c3644b10d40b2927bdce635 /gdb/tui/tui-source.c
parentae2b53806d3ce384e349c722b21a7ad246102d5b (diff)
downloadbinutils-gdb-b73dd8779c0530e91c6e5067eab4cb7ca3f794d5.tar.gz
Make source windows be self-updating
This changes the TUI source window to register itself on the source_styling_changed observable, and removes a bit of code from tui-hooks.c. This reduces the number of uses of the TUI_SRC_WIN global. gdb/ChangeLog 2019-07-17 Tom Tromey <tom@tromey.com> * tui/tui-source.c (tui_source_window): New constructor. Add observer. (~tui_source_window): New destructor. (tui_source_window::style_changed): New method. * tui/tui-hooks.c (tui_redisplay_source): Remove. (tui_attach_detach_observers): Update. * tui/tui-data.h (struct tui_source_window): Make constructor not inline. Add destructor. (struct tui_source_window) <style_changed>: New method. <m_observable>: New member.
Diffstat (limited to 'gdb/tui/tui-source.c')
-rw-r--r--gdb/tui/tui-source.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c
index e62ee4ea5f9..34cb38b31af 100644
--- a/gdb/tui/tui-source.c
+++ b/gdb/tui/tui-source.c
@@ -325,3 +325,23 @@ tui_source_window::do_scroll_vertical (int num_to_scroll)
print_source_lines (s, l.u.line_no, l.u.line_no + 1, 0);
}
}
+
+tui_source_window::tui_source_window ()
+ : tui_source_window_base (SRC_WIN)
+{
+ gdb::observers::source_styling_changed.attach
+ (std::bind (&tui_source_window::style_changed, this),
+ m_observable);
+}
+
+tui_source_window::~tui_source_window ()
+{
+ gdb::observers::source_styling_changed.detach (m_observable);
+}
+
+void
+tui_source_window::style_changed ()
+{
+ if (tui_active && is_visible)
+ refill ();
+}