Commit c38a45eb authored by Ole Christian Eidheim's avatar Ole Christian Eidheim

Moved Source::View::scroll_to_cursor_delayed implementation to source.cc

parent bd3ca5b4
Pipeline #94361386 passed with stages
in 16 minutes and 17 seconds
......@@ -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<size_t>(-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();
......
......@@ -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
......
......@@ -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();
......
......@@ -52,7 +52,7 @@ namespace Source {
/// Safely places cursor at line index
void place_cursor_at_line_index(int line, int index);
std::function<void(bool center, bool show_tooltips)> scroll_to_cursor_delayed = [](bool center, bool show_tooltips) {};
virtual void scroll_to_cursor_delayed(bool center, bool show_tooltips) {}
std::function<void(BaseView *view)> update_tab_label;
std::function<void(BaseView *view)> update_status_location;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment