From c38a45eb2b03af663c9fcb335a8758c09b0c9e0a Mon Sep 17 00:00:00 2001 From: eidheim Date: Thu, 7 Nov 2019 14:34:03 +0100 Subject: [PATCH] Moved Source::View::scroll_to_cursor_delayed implementation to source.cc --- src/notebook.cc | 13 ------------- src/source.cc | 14 ++++++++++++++ src/source.h | 2 ++ src/source_base.h | 2 +- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/notebook.cc b/src/notebook.cc index 232862e..556f681 100644 --- a/src/notebook.cc +++ b/src/notebook.cc @@ -175,19 +175,6 @@ void Notebook::open(const boost::filesystem::path &file_path_, Position position view->configure(); - view->scroll_to_cursor_delayed = [this, view](bool center, bool show_tooltips) { - if(!show_tooltips) - view->hide_tooltips(); - Glib::signal_idle().connect([this, view, center] { - if(get_index(view) != static_cast(-1)) { - if(center) - view->scroll_to(view->get_buffer()->get_insert(), 0.0, 1.0, 0.5); - else - view->scroll_to(view->get_buffer()->get_insert()); - } - return false; - }); - }; view->update_status_location = [this](Source::BaseView *view) { if(get_current_view() == view) { auto iter = view->get_buffer()->get_insert()->get_iter(); diff --git a/src/source.cc b/src/source.cc index 6f021be..032c1ba 100644 --- a/src/source.cc +++ b/src/source.cc @@ -1035,6 +1035,20 @@ void Source::View::hide_dialogs() { CompletionDialog::get()->hide(); } +void Source::View::scroll_to_cursor_delayed(bool center, bool show_tooltips) { + if(!show_tooltips) + hide_tooltips(); + Glib::signal_idle().connect([this, center] { + if(views.find(this) != views.end()) { + if(center) + scroll_to(get_buffer()->get_insert(), 0.0, 1.0, 0.5); + else + scroll_to(get_buffer()->get_insert()); + } + return false; + }); +} + void Source::View::extend_selection() { // Have tried to generalize this function as much as possible due to the complexity of this task, // but some further workarounds for edge cases might be needed diff --git a/src/source.h b/src/source.h index e84f247..38fb506 100644 --- a/src/source.h +++ b/src/source.h @@ -84,6 +84,8 @@ namespace Source { void hide_tooltips() override; void hide_dialogs() override; + void scroll_to_cursor_delayed(bool center, bool show_tooltips) override; + void extend_selection(); void shrink_selection(); diff --git a/src/source_base.h b/src/source_base.h index 1c3848e..4901086 100644 --- a/src/source_base.h +++ b/src/source_base.h @@ -52,7 +52,7 @@ namespace Source { /// Safely places cursor at line index void place_cursor_at_line_index(int line, int index); - std::function scroll_to_cursor_delayed = [](bool center, bool show_tooltips) {}; + virtual void scroll_to_cursor_delayed(bool center, bool show_tooltips) {} std::function update_tab_label; std::function update_status_location;