diff --git a/juci/notebook.cc b/juci/notebook.cc index 51093dc..3fdd7a7 100644 --- a/juci/notebook.cc +++ b/juci/notebook.cc @@ -81,7 +81,7 @@ void Notebook::Controller::CreateKeybindings() { if(location.first.size()>0) { 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()); + CurrentSourceView()->scroll_to(CurrentSourceView()->get_buffer()->get_insert(), 0.0, 1.0, 0.5); } } } diff --git a/juci/source.cc b/juci/source.cc index 86c72fb..cbdacef 100644 --- a/juci/source.cc +++ b/juci/source.cc @@ -49,7 +49,8 @@ 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){ - scroll_to(get_buffer()->get_insert()); + if(!user_input_started) + scroll_to(get_buffer()->get_insert(), 0.0, 1.0, 0.5); }); } @@ -71,6 +72,7 @@ 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 @@ -149,6 +151,11 @@ 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 14cc2a6..c946c3e 100644 --- a/juci/source.h +++ b/juci/source.h @@ -56,6 +56,9 @@ public: std::function()> get_declaration_location; 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 {