]> git.mdlowis.com Git - projs/tide.git/commitdiff
fixed cursor movement with arrow keys
authorMichael D. Lowis <mike.lowis@gentex.com>
Fri, 6 Apr 2018 12:45:13 +0000 (08:45 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Fri, 6 Apr 2018 12:45:13 +0000 (08:45 -0400)
inc/edit.h
lib/buf.c
lib/view.c

index 3fcecce4e392322eee10b7cc2456320a678d483b..acd96e85b0896fcb1d7aa988b4a5f54a623d25e6 100644 (file)
@@ -53,19 +53,14 @@ void buf_del(Buf* buf);
 
 void buf_undo(Buf* buf);
 void buf_redo(Buf* buf);
-//void buf_loglock(Buf* buf);
 void buf_logclear(Buf* buf);
 void buf_lastins(Buf* buf);
 
 bool buf_iseol(Buf* buf, size_t pos);
 size_t buf_bol(Buf* buf, size_t pos);
 size_t buf_eol(Buf* buf, size_t pos);
-//size_t buf_bow(Buf* buf, size_t pos);
-//size_t buf_eow(Buf* buf, size_t pos);
 
-//void buf_selline(Buf* buf);
 void buf_selword(Buf* buf, bool (*isword)(Rune));
-//void buf_selblock(Buf* buf, Rune beg, Rune end);
 void buf_selall(Buf* buf);
 void buf_selctx(Buf* buf, bool (*isword)(Rune));
 
@@ -154,7 +149,6 @@ void view_selectobj(View* view, bool (*istype)(Rune));
 
 /* Command Executions
  *****************************************************************************/
-
 typedef struct Job Job;
 
 typedef void (*jobfn_t)(Job* job);
index 766501072a0b908041b177b80ab556beb7fb0d3c..222d238b226c1beb24ccfe4e9cca63ce6bab5c94 100644 (file)
--- a/lib/buf.c
+++ b/lib/buf.c
@@ -12,6 +12,7 @@ static void log_clear(Log** list);
 static void syncgap(Buf* buf, size_t off);
 static int bytes_match(Buf* buf, size_t mbeg, size_t mend, char* str);
 static Rune nextrune(Buf* buf, size_t off, int move, bool (*testfn)(Rune));
+static void selline(Buf* buf);
 static void selblock(Buf* buf, Rune first, Rune last);
 
 void buf_init(Buf* buf) {
@@ -251,24 +252,6 @@ size_t buf_eol(Buf* buf, size_t off) {
     return off;
 }
 
-size_t buf_bow(Buf* buf, size_t off) {
-    for (; risword(buf_getrat(buf, off-1)); off--);
-    return off;
-}
-
-size_t buf_eow(Buf* buf, size_t off) {
-    for (; risword(buf_getrat(buf, off)); off++);
-    return off;
-}
-
-void buf_selline(Buf* buf) {
-    Sel sel = getsel(buf);
-    sel.beg = buf_bol(buf, sel.end);
-    sel.end = buf_eol(buf, sel.end);
-    sel.end = buf_byrune(buf, sel.end, RIGHT);
-    buf->selection = sel;
-}
-
 void buf_selword(Buf* buf, bool (*isword)(Rune)) {
     Sel sel = getsel(buf);
     for (; isword(buf_getrat(buf, sel.beg-1)); sel.beg--);
@@ -290,7 +273,7 @@ void buf_selctx(Buf* buf, bool (*isword)(Rune)) {
     else if (r == '{' || r == '}')
         selblock(buf, '{', '}');
     else if (buf->selection.end == bol || r == '\n')
-        buf_selline(buf);
+        selline(buf);
     else if (risword(r))
         buf_selword(buf, isword);
     else
@@ -436,6 +419,14 @@ bool buf_insel(Buf* buf, size_t off) {
 
 /******************************************************************************/
 
+static void selline(Buf* buf) {
+    Sel sel = getsel(buf);
+    sel.beg = buf_bol(buf, sel.end);
+    sel.end = buf_eol(buf, sel.end);
+    sel.end = buf_byrune(buf, sel.end, RIGHT);
+    buf->selection = sel;
+}
+
 static void selblock(Buf* buf, Rune first, Rune last) {
     Sel sel = getsel(buf);
     int balance = 0, dir;
index 16b5fd8e21259ccbd1f3fc2fa529ff987120b318..3182eb2034310a88868939057ce00dfc021d46b1 100644 (file)
@@ -298,7 +298,7 @@ static void move_selection(View* view, bool extsel, int move, movefn_t bything)
         if (bything == buf_byline)
             buf_setcol(BUF);
         if (!extsel)
-            buf_selclr(BUF, move);
+            buf_selclr(BUF, RIGHT);
     }
     /* only update column if not moving vertically */
     if (bything != buf_byline)