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

From:
Stefan Sperling <stsp@stsp.name>
Subject:
Re: tog: child views don't resize properly
To:
Christian Weisgerber <naddy@mips.inka.de>, gameoftrees@openbsd.org
Date:
Sun, 6 Dec 2020 23:33:16 +0100

Download raw body.

Thread
On Sun, Dec 06, 2020 at 11:20:25PM +0100, Stefan Sperling wrote:
> "It's noticeable when you move the selection to the bottom,
> then shrink the window, and the selection remains invisible."
> 
> Shrinking the window doesn't update selection in many cases.
> This occurs even if the view isn't a child view. For instance, in 'tog tree'
> if you move to the bottom entry and then shrink the window such that the
> bottom entry is no longer visible, then the selection won't be updated.
> If we want to fix that, it should probably to be fixed with a separate
> patch per view; a combined patch that fixes all of it would be huge.

Here is a patch for the ref view to move the selection cursor up when
the window shrinks. The old code is broken because s->ndisplayed is not
updated during a resize event.

Does this behave as you expect? If so, I'll try to fix others, too.

diff 4f37e849f5fcd6a7f78bb7c683ade6b10b3957ac /home/stsp/src/got
blob - 9195924b08116af1d1840e69703d322ec68922fb
file + tog/tog.c
--- tog/tog.c
+++ tog/tog.c
@@ -6131,8 +6131,8 @@ input_ref_view(struct tog_view **new_view, struct tog_
 		err = ref_view_load_refs(s);
 		break;
 	case KEY_RESIZE:
-		if (s->selected > view->nlines)
-			s->selected = s->ndisplayed - 1;
+		if (view->nlines >= 2 && s->selected >= view->nlines - 1)
+			s->selected = view->nlines - 2;
 		break;
 	default:
 		break;