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

From:
Christian Weisgerber <naddy@mips.inka.de>
Subject:
Re: tog: nG key map like vi(1) and less(1)
To:
gameoftrees@openbsd.org
Date:
Wed, 20 Jul 2022 22:36:00 +0200

Download raw body.

Thread
Mark Jamsek:

> We might have found a reasonable solution: keep centering line n in the
> nG case, but highlight line n till the next key press. This way, as stsp
> suggested, we keep the leading and following context, and provide
> a visual, albeit ephemeral, clue of the desired line.

Makes sense.
I'm terribly old-fashioned and prefer if terminal highlighting
limits itself to A_STANDOUT, although I readily admit that the
hardware terminals where this mattered have been dead for decades.

nG works in all views. Yay!
There is the cosmetic issue in the blame view that the line number
in the header is only updated with a noticeable delay.

The implementation seems weird in that it largely bypasses the
existing g/G code instead of handling all cases in the same code.
This...

> @@ -6712,6 +6894,16 @@ input_tree_view(struct tog_view **new_view, struct tog
>  	struct got_tree_entry *te;
>  	int begin_y = 0, begin_x = 0, n, nscroll = view->nlines - 3;
> 
> +	if (view->gline) {
> +		if (view->gline == 1)
> +			ch = 'g';
> +		else if (view->gline > got_object_tree_get_nentries(s->tree))
> +			ch = 'G';
> +		else
> +			return tree_goto_line(view, nscroll);
> +		view->gline = 0;
> +	}
> +

... is particularly weird.  Couldn't tree_goto_line() be used for
all cases?

I would have thought we'd end up with something like

	n = view->count;
	...
	case 'g':
		if (n == 0)
			n = 1;
		/* FALLTHROUGH */
	case 'G':
		if (n == 0)
			n = ...;
		... do stuff (n) ...;
		break;

Okay, I'll stop with the backseat driving.

-- 
Christian "naddy" Weisgerber                          naddy@mips.inka.de