diff options
author | Michael Drake <tlsa@netsurf-browser.org> | 2013-02-12 18:20:06 +0000 |
---|---|---|
committer | Michael Drake <tlsa@netsurf-browser.org> | 2013-02-12 18:20:06 +0000 |
commit | 2c64e896411a131b708ee49da2972da8d7045cc2 (patch) | |
tree | a81fd383ece67f696e3001b86912bc124b2d5581 | |
parent | a846e9811ec99cb6f259d6c59bd5b042fa1b7bc9 (diff) | |
download | netsurf-2c64e896411a131b708ee49da2972da8d7045cc2.tar.gz netsurf-2c64e896411a131b708ee49da2972da8d7045cc2.tar.bz2 |
Implement selection modification. Clicks and drags with button 2 alter the nearest end of the selection. Button 2 when there is no selection selects from caret pos to click pos.
-rw-r--r-- | desktop/textarea.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/desktop/textarea.c b/desktop/textarea.c index 15ef80169..ad9c8f25a 100644 --- a/desktop/textarea.c +++ b/desktop/textarea.c @@ -2274,7 +2274,25 @@ bool textarea_mouse_action(struct textarea *ta, browser_mouse_state mouse, ta->callback(ta->data, &msg); } - } else if (mouse & BROWSER_MOUSE_DRAG_1) { + } else if (mouse & BROWSER_MOUSE_PRESS_2) { + c_start = textarea_get_caret(ta); + textarea_get_xy_offset(ta, x, y, &c_off); + + if (ta->sel_start != -1) { + /* Adjust selection */ + c_start = (ta->sel_end - ta->sel_start) / 2 + + ta->sel_start; + c_start = ((unsigned)c_start > c_off) ? + ta->sel_end : ta->sel_start; + ta->drag_start_char = c_start; + return textarea_select(ta, c_start, c_off, false); + } else { + /* Select to caret */ + ta->drag_start_char = c_start; + return textarea_select(ta, c_start, c_off, false); + } + + } else if (mouse & (BROWSER_MOUSE_DRAG_1 | BROWSER_MOUSE_DRAG_2)) { /* Selection start */ textarea_get_xy_offset(ta, x, y, &c_off); c_start = ta->drag_start_char; @@ -2289,7 +2307,8 @@ bool textarea_mouse_action(struct textarea *ta, browser_mouse_state mouse, return textarea_select(ta, c_start, c_end, false); - } else if (mouse & BROWSER_MOUSE_HOLDING_1 && + } else if (mouse & + (BROWSER_MOUSE_HOLDING_1 | BROWSER_MOUSE_HOLDING_2) && ta->drag_info.type == TEXTAREA_DRAG_SELECTION) { /* Selection track */ int scrx = 0; |