diff --git a/src/source.cc b/src/source.cc index 24c3d1a..eb2b65e 100644 --- a/src/source.cc +++ b/src/source.cc @@ -390,6 +390,28 @@ bool Source::View::on_key_press_event(GdkEventKey* key) { return stop; } +bool Source::View::on_button_press_event(GdkEventButton *event) { + if(event->type==GDK_2BUTTON_PRESS) { + Gtk::TextIter start, end; + if(get_buffer()->get_selection_bounds(start, end)) { + auto iter=start; + while((*iter>=48 && *iter<=57) || (*iter>=65 && *iter<=90) || (*iter>=97 && *iter<=122) || *iter==95) { + start=iter; + if(!iter.backward_char()) + break; + } + while((*end>=48 && *end<=57) || (*end>=65 && *end<=90) || (*end>=97 && *end<=122) || *end==95) { + if(!end.forward_char()) + break; + } + get_buffer()->select_range(start, end); + return true; + } + } + + return Gsv::View::on_button_press_event(event); +} + std::pair Source::View::find_tab_char_and_size() { const std::regex indent_regex("^([ \t]+).*$"); auto size=get_buffer()->get_line_count(); diff --git a/src/source.h b/src/source.h index c374dfc..e51ff3d 100644 --- a/src/source.h +++ b/src/source.h @@ -80,6 +80,7 @@ namespace Source { std::string get_line_before_insert(); bool on_key_press_event(GdkEventKey* key); + bool on_button_press_event(GdkEventButton *event); std::pair find_tab_char_and_size(); unsigned tab_size;