Browse Source

Improved scroll_to.

merge-requests/365/head
eidheim 11 years ago
parent
commit
2169158689
  1. 2
      juci/notebook.cc
  2. 9
      juci/source.cc
  3. 3
      juci/source.h

2
juci/notebook.cc

@ -81,7 +81,7 @@ void Notebook::Controller::CreateKeybindings() {
if(location.first.size()>0) { if(location.first.size()>0) {
open_file(location.first); open_file(location.first);
CurrentSourceView()->get_buffer()->place_cursor(CurrentSourceView()->get_buffer()->get_iter_at_offset(location.second)); 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);
} }
} }
} }

9
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)); get_buffer()->place_cursor(get_buffer()->get_iter_at_offset(0));
signal_size_allocate().connect([this](Gtk::Allocation& allocation){ 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 //Basic indentation
bool Source::View::on_key_press_event(GdkEventKey* key) { bool Source::View::on_key_press_event(GdkEventKey* key) {
user_input_started=true;
auto config=Singleton::Config::source(); auto config=Singleton::Config::source();
const std::regex spaces_regex(std::string("^(")+config->tab_char+"*).*$"); const std::regex spaces_regex(std::string("^(")+config->tab_char+"*).*$");
//Indent as in next or previous line //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); 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 /// //// ClangViewParse ///
///////////////////////// /////////////////////////

3
juci/source.h

@ -56,6 +56,9 @@ public:
std::function<std::pair<std::string, unsigned>()> get_declaration_location; std::function<std::pair<std::string, unsigned>()> get_declaration_location;
protected: protected:
bool on_key_press_event(GdkEventKey* key); bool on_key_press_event(GdkEventKey* key);
bool on_button_press_event(GdkEventButton *event);
private:
bool user_input_started=false;
}; // class View }; // class View
class GenericView : public View { class GenericView : public View {

Loading…
Cancel
Save