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

From:
Mark Jamsek <mark@jamsek.com>
Subject:
Re: [rfc] tog horizontal scroll (diff & blame view)
To:
gameoftrees@openbsd.org
Date:
Thu, 16 Jun 2022 17:48:03 +1000

Download raw body.

Thread
On 22-06-16 09:35am, Stefan Sperling wrote:
> 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?

Good catch! I forgot to offset the scrolled columns.

Because we've already passed the string to format_line(), this could
probably be simplified by just subtracting view->x:

		if (width - view->x <= view->ncols - 1)

But your fix definitely works. Thanks, Stefan :)

> 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)
> 

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