From 4a9e61cb2eb58876801f39bb65d5928d1580b260 Mon Sep 17 00:00:00 2001 From: Boris Faure Date: Thu, 10 Oct 2013 22:27:16 +0200 Subject: [PATCH] fix selection going up/left --- src/bin/termio.c | 45 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/src/bin/termio.c b/src/bin/termio.c index 5a0067f3..d695e0ae 100644 --- a/src/bin/termio.c +++ b/src/bin/termio.c @@ -1541,8 +1541,8 @@ _smart_apply(Evas_Object *obj) start_x = sd->pty->selection.start.x; start_y = sd->pty->selection.start.y; - end_x = sd->pty->selection.end.x; - end_y = sd->pty->selection.end.y; + end_x = sd->pty->selection.end.x; + end_y = sd->pty->selection.end.y; if (sd->pty->selection.is_box) { @@ -3254,11 +3254,50 @@ _smart_cb_mouse_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUS sd->pty->selection.start.x = cx; sd->pty->selection.start.y = cy - sd->scroll; } - else + else if (sd->bottom_right) { sd->pty->selection.end.x = cx; sd->pty->selection.end.y = cy - sd->scroll; } + else + { + int start_x, start_y, end_x, end_y; + + start_x = sd->pty->selection.start.x; + start_y = sd->pty->selection.start.y; + end_x = sd->pty->selection.end.x; + end_y = sd->pty->selection.end.y; + + if (sd->pty->selection.is_box) + { + if (start_y > end_y) + { + INT_SWAP(start_y, end_y); + } + if (start_x > end_x) + INT_SWAP(start_x, end_x); + } + else + { + if ((start_y > end_y) || + ((start_y == end_y) && (end_x < start_x))) + { + INT_SWAP(start_y, end_y); + INT_SWAP(start_x, end_x); + } + } + cy -= sd->scroll; + + if (cy < start_y || (cy == start_y && cx <= start_x)) { + sd->top_left = EINA_TRUE; + sd->pty->selection.start.x = cx; + sd->pty->selection.start.y = cy; + } else if (cy > end_y || (cy == end_y && cx > end_x)) { + sd->bottom_right = EINA_TRUE; + sd->pty->selection.end.x = cx; + sd->pty->selection.end.y = cy; + } + } #if defined(SUPPORT_DBLWIDTH) _selection_dbl_fix(data); #endif