"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Mark Jamsek <mark@jamsek.com>
Subject:
tog: fix some OB1s in view rendering
To:
Game of Trees <gameoftrees@openbsd.org>
Date:
Wed, 1 Feb 2023 18:09:05 +1100

Download raw body.

Thread
I noticed an off-by-one error by chance when perusing old backup refs.
To reproduce, reduce the width of your terminal to a width that is just
one column greater than a given ref entry string (this can be lengthened
by toggling 'i' and 'm'), and notice we don't insert '\n' at the end of
the ref string so the next entry begins on the same line and wraps
around.

I figured there's a good chance we do this elsewhere, and found the same
problem in our tree view. Reduce screen width to 30 columns and
navigate to:

  "/gotwebd/files/htdocs/gotwebd/android-chrome-192x192.png"

and observe how the next file (android-chrome-384x384.png) starts at the
end of this entry and wraps to the next line.

While not quite the same problem, I noticed we weren't drawing to the
last column in our help view, so the diff makes a small change here too.

ok?

-----------------------------------------------
commit fa64fb25c20a748986758db1d7c9a333c2e71d0b (main)
from: Mark Jamsek <mark@jamsek.dev>
date: Wed Feb  1 06:26:29 2023 UTC
 
 fix OB1 in tog ref and tree views causing wrapped lines
 
 While here, draw to the last column in tog help.
 
diff 466be1387519f6af17726af568d8943cbcf0e66c fa64fb25c20a748986758db1d7c9a333c2e71d0b
commit - 466be1387519f6af17726af568d8943cbcf0e66c
commit + fa64fb25c20a748986758db1d7c9a333c2e71d0b
blob - c1730a93d0f5558332b281e3b842aea06d9748f0
blob + 18fd85d80ae64e33a4203855e707a424341027e8
--- tog/tog.c
+++ tog/tog.c
@@ -6921,7 +6921,7 @@ draw_tree_entries(struct tog_view *view, const char *p
 		if (tc)
 			wattr_off(view->window,
 			    COLOR_PAIR(tc->colorpair), NULL);
-		if (width < view->ncols - 1)
+		if (width < view->ncols)
 			waddch(view->window, '\n');
 		if (n == s->selected && view->focussed)
 			wstandend(view->window);
@@ -8183,7 +8183,7 @@ show_ref_view(struct tog_view *view)
 		if (tc)
 			wattr_off(view->window,
 			    COLOR_PAIR(tc->colorpair), NULL);
-		if (width < view->ncols - 1)
+		if (width < view->ncols)
 			waddch(view->window, '\n');
 		if (n == s->selected && view->focussed)
 			wstandend(view->window);
@@ -8829,22 +8829,20 @@ show_help_view(struct tog_view *view)
 			int skip;
 
 			err = format_line(&wline, &width, &skip, line,
-			    view->x, view->ncols - 1, 0, view->x ? 1 : 0);
+			    view->x, view->ncols, 0, view->x ? 1 : 0);
 			if (err) {
 				free(line);
 				return err;
 			}
-			rc = waddwstr(view->window, &wline[skip]);
+			waddwstr(view->window, &wline[skip]);
 			free(wline);
 			wline = NULL;
-			if (rc == ERR)
-				return got_error_msg(GOT_ERR_IO, "waddwstr");
 		}
 		if (s->lineno == view->hiline) {
 			while (width++ < view->ncols)
 				waddch(view->window, ' ');
 		} else {
-			if (width <= view->ncols)
+			if (width < view->ncols)
 				waddch(view->window, '\n');
 		}
 		if (attr)


-- 
Mark Jamsek <fnc.bsdbox.org>
GPG: F2FF 13DE 6A06 C471 CA80  E6E2 2930 DC66 86EE CF68