]> git.mdlowis.com Git - projs/tide.git/commitdiff
identified potentially unused functions in buf.c
authorMichael D. Lowis <mike.lowis@gentex.com>
Thu, 5 Apr 2018 20:27:26 +0000 (16:27 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Thu, 5 Apr 2018 20:27:26 +0000 (16:27 -0400)
inc/edit.h
lib/buf.c
lib/view.c

index ee9edb19c387bca2344e7c94125254acd2b599b3..3fcecce4e392322eee10b7cc2456320a678d483b 100644 (file)
@@ -53,19 +53,19 @@ void buf_del(Buf* buf);
 
 void buf_undo(Buf* buf);
 void buf_redo(Buf* buf);
-void buf_loglock(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);
+//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_selline(Buf* buf);
 void buf_selword(Buf* buf, bool (*isword)(Rune));
-void buf_selblock(Buf* buf, Rune beg, Rune end);
+//void buf_selblock(Buf* buf, Rune beg, Rune end);
 void buf_selall(Buf* buf);
 void buf_selctx(Buf* buf, bool (*isword)(Rune));
 
index cf47ea0ff0b579c4b7388fdc4f2cf25d7396765b..766501072a0b908041b177b80ab556beb7fb0d3c 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 selblock(Buf* buf, Rune first, Rune last);
 
 void buf_init(Buf* buf) {
     /* cleanup old data if there is any */
@@ -275,40 +276,6 @@ void buf_selword(Buf* buf, bool (*isword)(Rune)) {
     buf->selection = sel;
 }
 
-void buf_selblock(Buf* buf, Rune first, Rune last) {
-    Sel sel = getsel(buf);
-    int balance = 0, dir;
-    size_t beg, end = sel.end;
-
-    /* figure out which end of the block we're starting at */
-    if (buf_getrat(buf, end) == first)
-        dir = +1, balance++, beg = end++;
-    else if (buf_getrat(buf, end) == last)
-        dir = -1, balance--, beg = end--;
-    else
-        return;
-
-    /* scan for a blanced set of braces */
-    while (true) {
-        if (buf_getrat(buf, end) == first)
-            balance++;
-        else if (buf_getrat(buf, end) == last)
-            balance--;
-
-        if (balance == 0 || end >= buf_end(buf) || end == 0)
-            break;
-        else
-            end += dir;
-    }
-
-    /* bail if we failed to find a block */
-    if (balance != 0) return;
-
-    /* update the passed in selection */
-    if (end > beg) beg++; else end++;
-    buf->selection.beg = beg, buf->selection.end = end;
-}
-
 void buf_selall(Buf* buf) {
     buf->selection = (Sel){ .beg = 0, .end = buf_end(buf) };
 }
@@ -317,11 +284,11 @@ void buf_selctx(Buf* buf, bool (*isword)(Rune)) {
     size_t bol = buf_bol(buf, buf->selection.end);
     Rune r = buf_getc(buf);
     if (r == '(' || r == ')')
-        buf_selblock(buf, '(', ')');
+        selblock(buf, '(', ')');
     else if (r == '[' || r == ']')
-        buf_selblock(buf, '[', ']');
+        selblock(buf, '[', ']');
     else if (r == '{' || r == '}')
-        buf_selblock(buf, '{', '}');
+        selblock(buf, '{', '}');
     else if (buf->selection.end == bol || r == '\n')
         buf_selline(buf);
     else if (risword(r))
@@ -466,3 +433,41 @@ bool buf_insel(Buf* buf, size_t off) {
     Sel sel = getsel(buf);
     return (off >= sel.beg && off < sel.end);
 }
+
+/******************************************************************************/
+
+static void selblock(Buf* buf, Rune first, Rune last) {
+    Sel sel = getsel(buf);
+    int balance = 0, dir;
+    size_t beg, end = sel.end;
+
+    /* figure out which end of the block we're starting at */
+    if (buf_getrat(buf, end) == first)
+        dir = +1, balance++, beg = end++;
+    else if (buf_getrat(buf, end) == last)
+        dir = -1, balance--, beg = end--;
+    else
+        return;
+
+    /* scan for a blanced set of braces */
+    while (true) {
+        if (buf_getrat(buf, end) == first)
+            balance++;
+        else if (buf_getrat(buf, end) == last)
+            balance--;
+
+        if (balance == 0 || end >= buf_end(buf) || end == 0)
+            break;
+        else
+            end += dir;
+    }
+
+    /* bail if we failed to find a block */
+    if (balance != 0) return;
+
+    /* update the passed in selection */
+    if (end > beg) beg++; else end++;
+    buf->selection.beg = beg, buf->selection.end = end;
+}
+
+
index c19c90a1417a19257caf7be525b27f20e9711b37..16b5fd8e21259ccbd1f3fc2fa529ff987120b318 100644 (file)
@@ -142,7 +142,6 @@ char* view_fetch(View* view, size_t row, size_t col, bool (*isword)(Rune)) {
    char* str = NULL;
     size_t off = getoffset(view, row, col);
     if (off != SIZE_MAX) {
-        puts("fetch");
         /* str = buf_fetchat(buf, isword, off) */
 //        Sel sel = { .beg = off, .end = off };
 //        if (buf_insel(BUF, NULL, off))