Browse Source

Fixed double click to select whole variable in Linux.

merge-requests/365/head
eidheim 10 years ago
parent
commit
d9a1f7805b
  1. 22
      src/source.cc
  2. 1
      src/source.h

22
src/source.cc

@ -390,6 +390,28 @@ bool Source::View::on_key_press_event(GdkEventKey* key) {
return stop; 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<char, unsigned> Source::View::find_tab_char_and_size() { std::pair<char, unsigned> Source::View::find_tab_char_and_size() {
const std::regex indent_regex("^([ \t]+).*$"); const std::regex indent_regex("^([ \t]+).*$");
auto size=get_buffer()->get_line_count(); auto size=get_buffer()->get_line_count();

1
src/source.h

@ -80,6 +80,7 @@ namespace Source {
std::string get_line_before_insert(); std::string get_line_before_insert();
bool on_key_press_event(GdkEventKey* key); bool on_key_press_event(GdkEventKey* key);
bool on_button_press_event(GdkEventButton *event);
std::pair<char, unsigned> find_tab_char_and_size(); std::pair<char, unsigned> find_tab_char_and_size();
unsigned tab_size; unsigned tab_size;

Loading…
Cancel
Save