]> git.mdlowis.com Git - projs/tide.git/commitdiff
Fix bigword click selection
authorMike Lowis <mike.lowis@gentex.com>
Tue, 25 Oct 2016 20:39:03 +0000 (16:39 -0400)
committerMike Lowis <mike.lowis@gentex.com>
Tue, 25 Oct 2016 20:39:03 +0000 (16:39 -0400)
buf.c
edit.h
mouse.c
utils.c

diff --git a/buf.c b/buf.c
index cb3ae83078056e1616e583f776071ef291f2e29b..67b85d5e86cdc78a46c6873eccd025ce4aaad1bd 100644 (file)
--- a/buf.c
+++ b/buf.c
@@ -139,13 +139,13 @@ unsigned buf_eol(Buf* buf, unsigned off) {
 
 unsigned buf_bow(Buf* buf, unsigned off)
 {
-    for (; isword(buf_get(buf, off-1)); off--);
+    for (; risword(buf_get(buf, off-1)); off--);
     return off;
 }
 
 unsigned buf_eow(Buf* buf, unsigned off)
 {
-    for (; isword(buf_get(buf, off)); off++);
+    for (; risword(buf_get(buf, off)); off++);
     return off-1;
 }
 
diff --git a/edit.h b/edit.h
index b4262f821240d6d90cbaee2e39c4072ba0b8c268..0a4ddd05d75a85869d12568d34d062bfd470c3a3 100644 (file)
--- a/edit.h
+++ b/edit.h
@@ -36,8 +36,8 @@ FMap fmap(char* path);
 void funmap(FMap file);
 void die(const char* fmt, ...);
 uint32_t getmillis(void);
-bool isword(Rune r);
-
+bool risword(Rune r);
+bool risblank(Rune r);
 
 /* Buffer management functions
  *****************************************************************************/
diff --git a/mouse.c b/mouse.c
index 615c62571792e3fffd4274210c27c361f03d589e..d8ef254957a49097fc3939c1f546b2a398c5883c 100644 (file)
--- a/mouse.c
+++ b/mouse.c
@@ -14,8 +14,8 @@ void move_cursor(MouseEvent* mevnt) {
 void bigword(MouseEvent* mevnt) {
     (void)mevnt;
     unsigned mbeg = SelEnd, mend = SelEnd;
-    for (; !isblank(buf_get(&Buffer, mbeg-1)); mbeg--);
-    for (; !isblank(buf_get(&Buffer, mend)); mend++);
+    for (; !risblank(buf_get(&Buffer, mbeg-1)); mbeg--);
+    for (; !risblank(buf_get(&Buffer, mend));   mend++);
     SelBeg = mbeg, SelEnd = mend-1;
 }
 
@@ -26,7 +26,7 @@ void selection(MouseEvent* mevnt) {
     if (SelEnd == bol || r == '\n' || r == RUNE_CRLF) {
         SelBeg = bol;
         SelEnd = buf_eol(&Buffer, SelEnd);
-    } else if (isword(r)) {
+    } else if (risword(r)) {
         SelBeg = buf_bow(&Buffer, SelEnd);
         SelEnd = buf_eow(&Buffer, SelEnd);
         if (Buffer.insert_mode) SelEnd++;
diff --git a/utils.c b/utils.c
index f8d6c13984ab0a0664f84905319fbc3f0a2b0b9f..5fd2278a92fb1559d494993d863ecb61c6d7f61d 100644 (file)
--- a/utils.c
+++ b/utils.c
@@ -59,7 +59,10 @@ void funmap(FMap file) {
         munmap(file.buf, file.len);
 }
 
-bool isword(Rune r) {
+bool risword(Rune r) {
     return (r < 127 && (isalnum(r) || r == '_'));
 }
 
+bool risblank(Rune r) {
+    return (r == ' ' || r == '\t' || r == '\n' || r == '\r' || r == RUNE_CRLF);
+}