From: Stefan Sperling Subject: Re: tog: handle Home/End for log and diff views To: Jasper Lievisse Adriaanse , gameoftrees@openbsd.org Date: Mon, 30 Aug 2021 21:21:57 +0200 On Mon, Aug 30, 2021 at 07:36:15PM +0200, Stefan Sperling wrote: > This is a patch I came up with in order to solve the immediate usability > issue. It allows for cancellation with backspace in case the user triggers > the load operation by accident. > The above patch has been committed. As a follow-up change,I propose to block keys other than backspace in the log view's input handler while commits are loading. Tracey found that typing Ctrl-l or B would make the view's state somewhat inconsistent and break tog's expected behaviour. Since other keys als have side effects it should be better to block them for now. We could still enable other keys on a case-by-case basis in the future, once they are known to work fine. ok? diff 751490770ba7a1fe3669a4a604d7412ba8cba776 /home/stsp/src/got blob - 06ff7cdc6e39eab3ef6dd7f651bd12066ef3b237 file + tog/tog.c --- tog/tog.c +++ tog/tog.c @@ -2389,16 +2389,20 @@ input_log_view(struct tog_view **new_view, struct tog_ struct tog_view *ref_view = NULL; int begin_x = 0; - switch (ch) { - case ERR: /* no user input from wgetch() */ - if (s->thread_args.load_all && s->thread_args.log_complete) { + if (s->thread_args.load_all) { + if (ch == KEY_BACKSPACE) s->thread_args.load_all = 0; + else if (s->thread_args.log_complete) { + s->thread_args.load_all = 0; log_scroll_down(view, s->commits.ncommits); s->selected = MIN(view->nlines - 2, s->commits.ncommits - 1); select_commit(s); } - break; + return NULL; + } + + switch (ch) { case 'q': s->quit = 1; break; @@ -2542,11 +2546,6 @@ input_log_view(struct tog_view **new_view, struct tog_ case KEY_BACKSPACE: case CTRL('l'): case 'B': - if (s->thread_args.load_all) { - if (ch == KEY_BACKSPACE) - s->thread_args.load_all = 0; - break; - } if (ch == KEY_BACKSPACE && got_path_is_root_dir(s->in_repo_path)) break;