From: Mike Lowis Date: Tue, 25 Oct 2016 20:39:03 +0000 (-0400) Subject: Fix bigword click selection X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=afef5d455a374213cb6b2b8ee2d514e2c4d56dfa;p=projs%2Ftide.git Fix bigword click selection --- diff --git a/buf.c b/buf.c index cb3ae83..67b85d5 100644 --- 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 b4262f8..0a4ddd0 100644 --- 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 615c625..d8ef254 100644 --- 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 f8d6c13..5fd2278 100644 --- 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); +}