]> git.mdlowis.com Git - projs/tide.git/commitdiff
checkpoint commit
authorMichael D. Lowis <mike.lowis@gentex.com>
Sat, 19 Oct 2019 03:15:17 +0000 (23:15 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Sat, 19 Oct 2019 03:15:17 +0000 (23:15 -0400)
TODO.md
src/lib/buf.c
src/lib/view.c

diff --git a/TODO.md b/TODO.md
index e3525b2e020eb0c8e9fdd832d7ef24cf1a5c6425..e04e3251035f8b1c46552a4557f7340e4315b90b 100644 (file)
--- a/TODO.md
+++ b/TODO.md
@@ -4,6 +4,7 @@
 
 ## STAGING
 
+* tide: refactor selection handling and column tracking out of view.c
 * all: eliminate multiple return statements and other lint
 * tide: byrune, byword, byline functions should be hidden in buf.c
 * tide: column tracking should be hidden in buf.c
index 7ee3da5310dd1950b82771c213c0c73f5b74ac36..ba42c209de46cc086b8702b75feda2ef8f24106c 100644 (file)
@@ -41,6 +41,13 @@ static Sel selget(Buf* buf)
     return (sel.end < sel.beg ? selswap(sel) : sel);
 }
 
+static void selset(Buf* buf, Sel sel)
+{
+    buf->selection = sel;
+    buf_getcol(buf);
+}
+
+
 static void putch(Buf* buf, char b, Sel* p_sel)
 {
     if (b != '\r')
@@ -159,7 +166,7 @@ static void trim_whitespace(Buf* buf)
     {
         sel = selswap(sel);
     }
-    buf->selection = sel;
+    selset(buf, sel);
 }
 
 int buf_save(Buf* buf, char* path)
@@ -337,7 +344,7 @@ static void selline(Buf* 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;
+    selset(buf, sel);
 }
 
 static void selblock(Buf* buf, Rune first, Rune last)
@@ -530,7 +537,6 @@ void buf_selctx(Buf* buf, bool (*isword)(Rune))
     {
         selline(buf);
     }
-
     else if (selquote(buf, '"') || selquote(buf, '`') || selquote(buf, '\''))
     {
         ; /* condition performs selection */
@@ -777,7 +783,7 @@ void buf_selln(Buf* buf)
         sel.end = buf_eol(buf, sel.end);
         sel.end = buf_byrune(buf, sel.end, RIGHT);
     }
-    buf->selection = sel;
+    selset(buf, sel);
 }
 
 void buf_selclr(Buf* buf, int dir)
@@ -792,7 +798,7 @@ void buf_selclr(Buf* buf, int dir)
     {
         sel.end = sel.beg;
     }
-    buf->selection = sel;
+    selset(buf, sel);
 }
 
 bool buf_insel(Buf* buf, size_t off)
index c1d8678243d76afee5257e01090d170a4ca63321..10990cc34ee9740638ff4f21dc8ffff45ec3687f 100644 (file)
@@ -33,7 +33,6 @@ static void move_selection(View* view, bool extsel, int move, movefn_t bything)
     if (buf_selsz(BUF) && !extsel)
     {
         buf_selclr(BUF, move);
-        buf_getcol(BUF);
         if (bything == buf_byline)
         {
             CSRPOS = bything(BUF, CSRPOS, move);
@@ -56,12 +55,6 @@ static void move_selection(View* view, bool extsel, int move, movefn_t bything)
         {
             buf_selclr(BUF, (move < 0 ? LEFT : RIGHT));
         }
-
-        /* only update column if not moving vertically */
-        if (bything != buf_byline)
-        {
-            buf_getcol(BUF);
-        }
     }
 }