diff --git a/juci/notebook.cc b/juci/notebook.cc index 3fdd7a7..04eb689 100644 --- a/juci/notebook.cc +++ b/juci/notebook.cc @@ -82,6 +82,11 @@ void Notebook::Controller::CreateKeybindings() { open_file(location.first); CurrentSourceView()->get_buffer()->place_cursor(CurrentSourceView()->get_buffer()->get_iter_at_offset(location.second)); CurrentSourceView()->scroll_to(CurrentSourceView()->get_buffer()->get_insert(), 0.0, 1.0, 0.5); + + /*CurrentSourceView()->signal_size_allocate().connect([this](Gtk::Allocation& allocation){ + auto adj=scrolled_windows.at(CurrentPage())->get_vadjustment(); + cout << adj->get_upper() << ", " << adj->get_page_size() << endl; + });*/ } } } diff --git a/juci/source.cc b/juci/source.cc index cbdacef..187ffc6 100644 --- a/juci/source.cc +++ b/juci/source.cc @@ -49,9 +49,15 @@ file_path(file_path), project_path(project_path) { get_buffer()->place_cursor(get_buffer()->get_iter_at_offset(0)); signal_size_allocate().connect([this](Gtk::Allocation& allocation){ - if(!user_input_started) + if(!after_user_input) scroll_to(get_buffer()->get_insert(), 0.0, 1.0, 0.5); }); + + signal_event().connect([this](GdkEvent* event){ + if(event->type==GDK_KEY_PRESS || event->type==GDK_BUTTON_PRESS || event->type==GDK_SCROLL) + after_user_input=true; + return false; + }); } string Source::View::get_line(size_t line_number) { @@ -72,7 +78,6 @@ string Source::View::get_line_before_insert() { //Basic indentation bool Source::View::on_key_press_event(GdkEventKey* key) { - user_input_started=true; auto config=Singleton::Config::source(); const std::regex spaces_regex(std::string("^(")+config->tab_char+"*).*$"); //Indent as in next or previous line @@ -151,11 +156,6 @@ bool Source::View::on_key_press_event(GdkEventKey* key) { return Gsv::View::on_key_press_event(key); } -bool Source::View::on_button_press_event(GdkEventButton *event) { - user_input_started=true; - return Gsv::View::on_button_press_event(event); -} - ///////////////////////// //// ClangViewParse /// ///////////////////////// diff --git a/juci/source.h b/juci/source.h index c946c3e..53828cd 100644 --- a/juci/source.h +++ b/juci/source.h @@ -54,11 +54,9 @@ public: Gtk::TextIter search_start, search_end; std::function()> get_declaration_location; + bool after_user_input=false; protected: bool on_key_press_event(GdkEventKey* key); - bool on_button_press_event(GdkEventButton *event); - private: - bool user_input_started=false; }; // class View class GenericView : public View {