From df61771a449a1ca6ed7704e3aed3496063a47910 Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Sun, 18 Nov 2018 17:41:30 +0100 Subject: menuconfig: Never snap scroll back to max_scroll When scroll > max_scroll (blank space at the bottom of the menu, and also scrolled down), moving the cursor down would snap the scroll back to max_scroll, with a small annoying jump. This could happen when going into show-all mode and moving the cursor down near the bottom of a menu, for example. Fix it by leaving the scroll as-is when scroll >= max_scroll (increasing it by one otherwise). --- menuconfig.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/menuconfig.py b/menuconfig.py index f8e5d5c..d34f7d8 100755 --- a/menuconfig.py +++ b/menuconfig.py @@ -1131,9 +1131,10 @@ def _select_next_menu_entry(): # (as determined by _SCROLL_OFFSET), increase the scroll by one. This # gives nice and non-jumpy behavior even when # _SCROLL_OFFSET >= _menu_win_height(). - if _sel_node_i >= _menu_scroll + _menu_win_height() - _SCROLL_OFFSET: - _menu_scroll = min(_menu_scroll + 1, - _max_scroll(_shown, _menu_win)) + if _sel_node_i >= _menu_scroll + _menu_win_height() - _SCROLL_OFFSET \ + and _menu_scroll < _max_scroll(_shown, _menu_win): + + _menu_scroll += 1 def _select_prev_menu_entry(): # Selects the menu entry before the current one, adjusting the scroll if @@ -1868,8 +1869,10 @@ def _jump_to_dialog(): if sel_node_i < len(matches) - 1: sel_node_i += 1 - if sel_node_i >= scroll + matches_win.getmaxyx()[0] - _SCROLL_OFFSET: - scroll = min(scroll + 1, _max_scroll(matches, matches_win)) + if sel_node_i >= scroll + matches_win.getmaxyx()[0] - _SCROLL_OFFSET \ + and scroll < _max_scroll(matches, matches_win): + + scroll += 1 def select_prev_match(): nonlocal sel_node_i -- cgit v1.2.3