From 2c64e896411a131b708ee49da2972da8d7045cc2 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Tue, 12 Feb 2013 18:20:06 +0000 Subject: 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. --- desktop/textarea.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'desktop') 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; -- cgit v1.2.3