]> git.mdlowis.com Git - projs/tide.git/commitdiff
dirty fix for view_limitrows. Definitely needs to be refactored
authorMichael D. Lowis <mike.lowis@gentex.com>
Mon, 10 Sep 2018 20:05:46 +0000 (16:05 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Mon, 10 Sep 2018 20:05:46 +0000 (16:05 -0400)
lib/view.c

index 13e4939c6331ee456f036114767bc7fb1eb2d653..ca44e2ed3b39012f683fbe6ae9795e9ba8d8d043 100644 (file)
@@ -100,12 +100,17 @@ size_t view_limitrows(View* view, size_t maxrows) {
     while (nrows < maxrows && off < buf_end(&(view->buffer))) {
         Rune rune = buf_getrat(&(view->buffer), off);
         xpos += rune_width(rune, xpos, view->width);
-        if (rune == '\n') nrows++;
-        if (xpos <= view->width)
-            off = buf_byrune(&(view->buffer), off, RIGHT);
-        else
+        if (rune == '\n') {
             xpos = 0, nrows++;
+            off = buf_byrune(&(view->buffer), off, RIGHT);
+        } else {
+            if (xpos <= view->width)
+                off = buf_byrune(&(view->buffer), off, RIGHT);
+            else
+                xpos = 0, nrows++;
+        }
     }
+    printf("rows: %lu\n", nrows);
     return nrows;
 }