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

From:
Stefan Sperling <stsp@stsp.name>
Subject:
Re: [rfc] tog horizontal scroll (diff & blame view)
To:
Mark Jamsek <mark@jamsek.com>, gameoftrees@openbsd.org
Date:
Thu, 16 Jun 2022 09:35:43 +0200

Download raw body.

Thread
On Thu, Jun 16, 2022 at 09:15:24AM +0200, Stefan Sperling wrote:
> In the blame view, in an 80x24 terminal, horizontal scrolling has a rendering
> issue where separate lines get merged together. Even commit annotations are
> move up and get merged to the end of the previous line.

The code forgot to subtract the leading part, before view->x, from
the rendered line's width. Fix below works for me. ok?

diff b4996beee4ab59f339d2b4de7cfc401ba2f22c4e /home/stsp/src/got
blob - a3599eb66772cacb41dd2c51115381919d25c083
file + tog/tog.c
--- tog/tog.c
+++ tog/tog.c
@@ -4190,7 +4190,7 @@ draw_blame(struct tog_view *view)
 	struct tog_blame *blame = &s->blame;
 	regmatch_t *regmatch = &view->regmatch;
 	const struct got_error *err;
-	int lineno = 0, nprinted = 0;
+	int lineno = 0, nprinted = 0, i;
 	char *line = NULL;
 	size_t linesize = 0;
 	ssize_t linelen;
@@ -4332,14 +4332,18 @@ draw_blame(struct tog_view *view)
 		} else {
 			err = format_line(&wline, &width, line,
 			    view->x + view->ncols - 9, 9, 1);
-			if (!err && view->x < width - 1) {
+			if (err) {
+				free(line);
+				return err;
+			}
+			if (view->x < width - 1) {
 				waddwstr(view->window, wline + view->x);
-				width += 9;
+				for (i = 0; i < view->x; i++) 
+					width -= wcwidth(wline[i]);
 			}
+			width += 9;
 			free(wline);
 			wline = NULL;
-			if (err)
-				return err;
 		}
 
 		if (width <= view->ncols - 1)