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

From:
Stefan Sperling <stsp@stsp.name>
Subject:
Re: tog: handle Home/End for log and diff views
To:
Jasper Lievisse Adriaanse <j@jasper.la>
Cc:
gameoftrees@openbsd.org
Date:
Mon, 30 Aug 2021 12:53:29 +0200

Download raw body.

Thread
On Sun, Aug 29, 2021 at 10:14:38PM +0200, Jasper Lievisse Adriaanse wrote:
> Hi,
> 
> Here's a diff that allows one to quickly navigate to the first or last
> item of a particular view. Currently I've implemented it for the diff and
> log views as these are the ones I use most often.
> 
> The 'End' handling for the log view was the trickiest because of the
> way new commits are progressively discovered. I think the approach below
> might be the quickest way we currently can do.
> 
> Is this an acceptable approach or did I miss anything?

Adding an alias for the Home key would be nice for use with keyboards
which lack a Home key.

As we discussed over lunch, there should be a way for users to abort
loading in case they hit the key by accident. Backspace is already
bound for this purpose while searching. Perhaps we can generalize
Backspace to abort loading in general? In any case, if we want to
support cancellation it could be added in a follow-up patch.

> @@ -2432,6 +2440,23 @@ input_log_view(struct tog_view **new_view, struct tog_view *view, int ch)
>  		}
>  		select_commit(s);
>  		break;
> +	case 'G':
> +	case KEY_END: {
> +		/* We don't know yet how many commits, so we're forced to
> +		 * traverse them all. */
> +		while (1) {
> +			if (s->thread_args.log_complete)
> +				break;
> +
> +			s->thread_args.commits_needed++;
> +			trigger_log_thread(view, 1);

Does this run any faster if we ask the log thread for multiple commits?
I'd imagine that just loading one commit at a time could lead to a lot
of ping-pong between the two threads that could perhaps be avoided?