From 90d3bf483cb4abebc32554fbc8e3bc8ccadd3a27 Mon Sep 17 00:00:00 2001 From: Boris Faure Date: Sun, 3 Nov 2013 18:43:07 +0100 Subject: [PATCH] fix stretching selection --- src/bin/termio.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/src/bin/termio.c b/src/bin/termio.c index b3aafcec..368b2b1d 100644 --- a/src/bin/termio.c +++ b/src/bin/termio.c @@ -3072,8 +3072,55 @@ _smart_cb_mouse_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUS if (sd->pty->selection.is_active && (sd->top_left || sd->bottom_right)) { + /* stretch selection */ + 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; _sel_set(data, EINA_TRUE); sd->pty->selection.makesel = EINA_TRUE; + if (sd->pty->selection.is_box) + { + if (sd->top_left) + { + 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) + INT_SWAP(start_y, end_y); + if (start_x > end_x) + INT_SWAP(start_x, end_x); + } + } + else + { + if (sd->top_left) + { + 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); + } + } + 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); + } + } + } + sd->pty->selection.start.x = start_x; + sd->pty->selection.start.y = start_y; sd->pty->selection.end.x = cx; sd->pty->selection.end.y = cy - sd->scroll; _selection_dbl_fix(data);