summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBoris Faure <billiob@gmail.com>2015-01-19 22:55:22 +0100
committerBoris Faure <billiob@gmail.com>2015-02-06 20:48:03 +0100
commit6a2b3ae871a44e15873ba670551d2666029d6c23 (patch)
treea2d6712bce7caa613b9d275c5b0d6051ab42e13a /src
parentd18a47c5c6e3a58994761bd6b0477f07c1db4c6c (diff)
selection: add click then shift-click
Diffstat (limited to 'src')
-rw-r--r--src/bin/termio.c72
-rw-r--r--src/bin/termpty.h1
2 files changed, 71 insertions, 2 deletions
diff --git a/src/bin/termio.c b/src/bin/termio.c
index e95f6a7..58c1a61 100644
--- a/src/bin/termio.c
+++ b/src/bin/termio.c
@@ -3461,7 +3461,7 @@ _smart_cb_mouse_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUS
3461 sd->pty->selection.end.y = cy - sd->scroll; 3461 sd->pty->selection.end.y = cy - sd->scroll;
3462 _selection_dbl_fix(data); 3462 _selection_dbl_fix(data);
3463 } 3463 }
3464 else if (!shift || !sd->pty->selection.is_active) 3464 else if (!shift && !sd->pty->selection.is_active)
3465 { 3465 {
3466 /* New selection */ 3466 /* New selection */
3467 sd->moved = EINA_FALSE; 3467 sd->moved = EINA_FALSE;
@@ -3476,11 +3476,78 @@ _smart_cb_mouse_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUS
3476 sd->pty->selection.makesel = EINA_TRUE; 3476 sd->pty->selection.makesel = EINA_TRUE;
3477 _selection_dbl_fix(data); 3477 _selection_dbl_fix(data);
3478 } 3478 }
3479 else if (shift &&
3480 (time(NULL) - sd->pty->selection.last_click) <= 60)
3481 {
3482 int start_x, start_y, end_x, end_y, cy_rel;
3483
3484 if (!sd->pty->selection.is_active)
3485 sd->pty->selection.is_box = ctrl;
3486
3487 start_x = sd->pty->selection.start.x;
3488 start_y = sd->pty->selection.start.y;
3489 end_x = sd->pty->selection.end.x;
3490 end_y = sd->pty->selection.end.y;
3491
3492 cy_rel = cy - sd->scroll;
3493
3494 if (sd->pty->selection.is_box)
3495 {
3496 if (start_y > end_y)
3497 INT_SWAP(start_y, end_y);
3498 if (start_x > end_x)
3499 INT_SWAP(start_x, end_x);
3500 if (cy_rel < start_y)
3501 start_y = cy;
3502 else if (cy_rel > end_y)
3503 end_y = cy;
3504 if (cx < start_x)
3505 start_x = cx;
3506 else if (cx > end_x)
3507 end_x = cx;
3508 }
3509 else
3510 {
3511 if ((start_y > end_y) ||
3512 ((start_y == end_y) && (end_x < start_x)))
3513 {
3514 INT_SWAP(start_y, end_y);
3515 INT_SWAP(start_x, end_x);
3516 }
3517 if ((cy_rel < start_y) ||
3518 (cy_rel == start_y && cx <= start_x))
3519 {
3520 start_y = cy_rel;
3521 start_x = cx;
3522 }
3523 else if ((cy_rel > end_y) ||
3524 (cy_rel == end_y && cx >= end_x))
3525 {
3526 end_y = cy_rel;
3527 end_x = cx;
3528 }
3529 else
3530 {
3531 sd->pty->selection.makesel = EINA_FALSE;
3532 _sel_set(sd, EINA_FALSE);
3533 _smart_update_queue(data, sd);
3534 return;
3535 }
3536 }
3537 sd->pty->selection.start.x = start_x;
3538 sd->pty->selection.start.y = start_y;
3539 sd->pty->selection.end.x = end_x;
3540 sd->pty->selection.end.y = end_y;
3541 sd->pty->selection.is_active = EINA_TRUE;
3542 _selection_dbl_fix(data);
3543 }
3479 else 3544 else
3480 { 3545 {
3546 sd->pty->selection.start.x = sd->pty->selection.end.x = cx;
3547 sd->pty->selection.start.y = sd->pty->selection.end.y = cy - sd->scroll;
3481 sd->pty->selection.makesel = EINA_FALSE; 3548 sd->pty->selection.makesel = EINA_FALSE;
3549 sd->didclick = !sd->pty->selection.is_active;
3482 sd->pty->selection.is_active = EINA_FALSE; 3550 sd->pty->selection.is_active = EINA_FALSE;
3483 sd->didclick = EINA_TRUE;
3484 } 3551 }
3485 } 3552 }
3486 _smart_update_queue(data, sd); 3553 _smart_update_queue(data, sd);
@@ -3529,6 +3596,7 @@ _smart_cb_mouse_up(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED
3529 { 3596 {
3530 _sel_set(sd, EINA_FALSE); 3597 _sel_set(sd, EINA_FALSE);
3531 sd->didclick = EINA_FALSE; 3598 sd->didclick = EINA_FALSE;
3599 sd->pty->selection.last_click = time(NULL);
3532 _smart_update_queue(data, sd); 3600 _smart_update_queue(data, sd);
3533 return; 3601 return;
3534 } 3602 }
diff --git a/src/bin/termpty.h b/src/bin/termpty.h
index f8361d5..619a7f7 100644
--- a/src/bin/termpty.h
+++ b/src/bin/termpty.h
@@ -148,6 +148,7 @@ struct _Termpty
148 struct { 148 struct {
149 int x, y; 149 int x, y;
150 } start, end, start_backup, end_backup; 150 } start, end, start_backup, end_backup;
151 time_t last_click;
151 unsigned char is_active : 1; 152 unsigned char is_active : 1;
152 unsigned char is_box : 1; 153 unsigned char is_box : 1;
153 unsigned char makesel : 1; 154 unsigned char makesel : 1;