summaryrefslogtreecommitdiff
path: root/menuconfig.py
diff options
context:
space:
mode:
authorUlf Magnusson <ulfalizer@gmail.com>2018-08-29 03:03:32 +0200
committerUlf Magnusson <ulfalizer@gmail.com>2018-08-29 03:03:32 +0200
commite435ecc6f367a2d0f7159bd3c7c0f1aca8dbb982 (patch)
tree191d61403bca1a64b407fce00b3f606bc93b150b /menuconfig.py
parent64b734a930a7670671ef5fdc21c12f2b11b04409 (diff)
menuconfig: Add a _center_vertically() helper
Used in two spots.
Diffstat (limited to 'menuconfig.py')
-rwxr-xr-xmenuconfig.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/menuconfig.py b/menuconfig.py
index 7e1160b..3ebf44e 100755
--- a/menuconfig.py
+++ b/menuconfig.py
@@ -750,8 +750,7 @@ def _jump_to(node):
_shown = _shown_nodes(_cur_menu)
_sel_node_i = _shown.index(node)
- # Center the jumped-to node vertically, if possible
- _menu_scroll = max(_sel_node_i - _menu_win_height()//2, 0)
+ _center_vertically()
def _leave_menu():
# Jumps to the parent menu of the current menu. Does nothing if we're in
@@ -780,8 +779,8 @@ def _leave_menu():
_menu_scroll = max(_sel_node_i - screen_row, 0)
else:
# No saved parent menu locations, meaning we jumped directly to some
- # node earlier. Just center the node vertically if possible.
- _menu_scroll = max(_sel_node_i - _menu_win_height()//2, 0)
+ # node earlier
+ _center_vertically()
def _select_next_menu_entry():
# Selects the menu entry after the current one, adjusting the scroll if
@@ -881,6 +880,13 @@ def _toggle_show_all():
# might be impossible if too many nodes have disappeared above the node.
_menu_scroll = max(_sel_node_i - old_row, 0)
+def _center_vertically():
+ # Centers the selected node vertically, if possible
+
+ global _menu_scroll
+
+ _menu_scroll = max(_sel_node_i - _menu_win_height()//2, 0)
+
def _draw_main():
# Draws the "main" display, with the list of symbols, the header, and the
# footer.