From: Michael D. Lowis Date: Tue, 11 Sep 2018 01:37:31 +0000 (-0400) Subject: refactored logic for limiting size of tags region X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=3f3feaa8e40eaf9167e0bfa4a1d0cd2813536395;p=projs%2Ftide.git refactored logic for limiting size of tags region --- diff --git a/lib/view.c b/lib/view.c index ca44e2e..08db6f6 100644 --- a/lib/view.c +++ b/lib/view.c @@ -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; }