billiob pushed a commit to branch master.

http://git.enlightenment.org/apps/terminology.git/commit/?id=6a2b3ae871a44e15873ba670551d2666029d6c23

commit 6a2b3ae871a44e15873ba670551d2666029d6c23
Author: Boris Faure <bill...@gmail.com>
Date:   Mon Jan 19 22:55:22 2015 +0100

    selection: add click then shift-click
---
 src/bin/termio.c  | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++--
 src/bin/termpty.h |  1 +
 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
                   sd->pty->selection.end.y = cy - sd->scroll;
                   _selection_dbl_fix(data);
                }
-             else if (!shift || !sd->pty->selection.is_active)
+             else if (!shift && !sd->pty->selection.is_active)
                {
                   /* New selection */
                   sd->moved = EINA_FALSE;
@@ -3476,11 +3476,78 @@ _smart_cb_mouse_down(void *data, Evas *e EINA_UNUSED, 
Evas_Object *obj EINA_UNUS
                   sd->pty->selection.makesel = EINA_TRUE;
                   _selection_dbl_fix(data);
                }
+             else if (shift &&
+                      (time(NULL) - sd->pty->selection.last_click) <= 60)
+               {
+                  int start_x, start_y, end_x, end_y, cy_rel;
+
+                  if (!sd->pty->selection.is_active)
+                    sd->pty->selection.is_box = ctrl;
+
+                  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;
+
+                  cy_rel = cy - sd->scroll;
+
+                  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);
+                       if (cy_rel < start_y)
+                         start_y = cy;
+                       else if (cy_rel > end_y)
+                         end_y = cy;
+                       if (cx < start_x)
+                         start_x = cx;
+                       else if (cx > end_x)
+                         end_x = cx;
+                    }
+                  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);
+                         }
+                       if ((cy_rel < start_y) ||
+                           (cy_rel == start_y && cx <= start_x))
+                         {
+                            start_y = cy_rel;
+                            start_x = cx;
+                         }
+                       else if ((cy_rel > end_y) ||
+                                (cy_rel == end_y && cx >= end_x))
+                         {
+                            end_y = cy_rel;
+                            end_x = cx;
+                         }
+                       else
+                         {
+                            sd->pty->selection.makesel = EINA_FALSE;
+                            _sel_set(sd, EINA_FALSE);
+                            _smart_update_queue(data, sd);
+                            return;
+                         }
+                    }
+                  sd->pty->selection.start.x = start_x;
+                  sd->pty->selection.start.y = start_y;
+                  sd->pty->selection.end.x = end_x;
+                  sd->pty->selection.end.y = end_y;
+                  sd->pty->selection.is_active = EINA_TRUE;
+                  _selection_dbl_fix(data);
+               }
              else
                {
+                  sd->pty->selection.start.x = sd->pty->selection.end.x = cx;
+                  sd->pty->selection.start.y = sd->pty->selection.end.y = cy - 
sd->scroll;
                   sd->pty->selection.makesel = EINA_FALSE;
+                  sd->didclick = !sd->pty->selection.is_active;
                   sd->pty->selection.is_active = EINA_FALSE;
-                  sd->didclick = EINA_TRUE;
                }
           }
         _smart_update_queue(data, sd);
@@ -3529,6 +3596,7 @@ _smart_cb_mouse_up(void *data, Evas *e EINA_UNUSED, 
Evas_Object *obj EINA_UNUSED
           {
              _sel_set(sd, EINA_FALSE);
              sd->didclick = EINA_FALSE;
+             sd->pty->selection.last_click = time(NULL);
              _smart_update_queue(data, sd);
              return;
           }
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
       struct {
          int x, y;
       } start, end, start_backup, end_backup;
+      time_t last_click;
       unsigned char is_active : 1;
       unsigned char is_box    : 1;
       unsigned char makesel   : 1;

-- 


Reply via email to