From ccd149a329f9a33195c2c6216158e283f8993076 Mon Sep 17 00:00:00 2001 From: rodri Date: Sat, 16 Nov 2024 11:22:16 +0000 Subject: fix the menulist (make it play nice with periodic refreshing). before the addition of the timer for periodic matches updates the menulist was supposed to be refreshed manually by the user, and we didn't take into account the fact that every time you clear it and refill it loses its navigational parameters, i.e. which entry was selected and what's the offset if there are more entries than the visible window (Maxvisitems). so now we store those and reconfigure the menulist, adapting to its new state, so that the user experiences as little disruption as possible. --- bts.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'bts.c') diff --git a/bts.c b/bts.c index aa63a4b..1f72a14 100644 --- a/bts.c +++ b/bts.c @@ -955,6 +955,9 @@ processcmd(char *cmd) Point2 cell; uchar buf[BY2MAP]; int i, idx; + struct { + int high, off; + } menuparams; if(debug) fprint(2, "rcvd '%s'\n", cmd); @@ -987,6 +990,8 @@ processcmd(char *cmd) break; case CMmatches: if(!matches->filling){ + menuparams.high = matches->high; + menuparams.off = matches->off; matches->clear(matches); matches->filling = 1; } @@ -997,8 +1002,12 @@ processcmd(char *cmd) smprint("%s vs %s", cb->f[2], cb->f[3])); break; case CMendmatches: - if(matches->filling) + if(matches->filling){ + matches->high = min(menuparams.high, matches->nentries-1); + matches->off = menuparams.off > matches->nentries - matches->maxvis? + 0: menuparams.off; matches->filling = 0; + } break; case CMwatching: match.id = strtoul(cb->f[1], nil, 10); -- cgit v1.2.3