]> git.mdlowis.com Git - projs/tide.git/commitdiff
added logic to select big words on triple click and non alpha-numeric chars
authorMichael D. Lowis <mike@mdlowis.com>
Sun, 23 Oct 2016 01:27:51 +0000 (21:27 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Sun, 23 Oct 2016 01:27:51 +0000 (21:27 -0400)
mouse.c

diff --git a/mouse.c b/mouse.c
index 5499058336449041c980095ee98df5477b28b21f..a246c9723dd17a46fadf4602e0557bcfd202356e 100644 (file)
--- a/mouse.c
+++ b/mouse.c
@@ -1,4 +1,5 @@
 #include "edit.h"
+#include <ctype.h>
 
 void unused(MouseEvent* mevnt) {
     (void)mevnt;
@@ -8,7 +9,14 @@ void move_cursor(MouseEvent* mevnt) {
     if (mevnt->y == 0) return;
     DotBeg = DotEnd = screen_getoff(&Buffer, DotEnd, mevnt->y-1, mevnt->x);
     TargetCol = buf_getcol(&Buffer, DotEnd);
-    //DotBeg = DotEnd;
+}
+
+void bigword(MouseEvent* mevnt) {
+    (void)mevnt;
+    unsigned mbeg = DotEnd, mend = DotEnd;
+    for (; !isblank(buf_get(&Buffer, mbeg-1)); mbeg--);
+    for (; !isblank(buf_get(&Buffer, mend)); mend++);
+    DotBeg = mbeg, DotEnd = mend-1;
 }
 
 void select(MouseEvent* mevnt) {
@@ -35,7 +43,7 @@ void select(MouseEvent* mevnt) {
         DotEnd = buf_rscan(&Buffer, DotEnd, '}');
         if (Buffer.insert_mode) DotEnd++;
     } else {
-        /* scan for big word */
+        bigword(mevnt);
     }
 }
 
@@ -74,7 +82,7 @@ void (*Actions[5][3])(MouseEvent* mevnt) = {
     [MOUSE_LEFT] = {
         [SINGLE_CLICK] = move_cursor,
         [DOUBLE_CLICK] = select,
-        [TRIPLE_CLICK] = unused,
+        [TRIPLE_CLICK] = bigword,
     },
     [MOUSE_MIDDLE] = {
         [SINGLE_CLICK] = unused,