summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlf Magnusson <ulfalizer@gmail.com>2018-11-18 17:41:30 +0100
committerUlf Magnusson <ulfalizer@gmail.com>2018-11-18 18:58:16 +0100
commitdf61771a449a1ca6ed7704e3aed3496063a47910 (patch)
tree2a1d521e90299b70c5c8a305e8872f6f76ae3cd1
parent9a429a9abc1de8c431b42244be6e440d122c2686 (diff)
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).
-rwxr-xr-xmenuconfig.py13
1 files 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