]> git.mdlowis.com Git - projs/tide.git/commitdiff
refactored logic for limiting size of tags region
authorMichael D. Lowis <mike@mdlowis.com>
Tue, 11 Sep 2018 01:37:31 +0000 (21:37 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Tue, 11 Sep 2018 01:37:31 +0000 (21:37 -0400)
lib/view.c

index ca44e2ed3b39012f683fbe6ae9795e9ba8d8d043..08db6f6cb69a74d8d9f0b1225783500bb94d612b 100644 (file)
@@ -100,17 +100,15 @@ 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') {
+        /* if the line is full, reset the line and increase row count */
+        if (xpos > view->width) {
             xpos = 0, nrows++;
-            off = buf_byrune(&(view->buffer), off, RIGHT);
         } else {
-            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);
         }
     }
-    printf("rows: %lu\n", nrows);
     return nrows;
 }