From 08cfc33cffb79920914a20c31b5bb84020ba31ec Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Thu, 4 Apr 2019 15:28:39 +0200 Subject: menuconfig: Show menus with unsatisfied 'visible if' in red in show-all mode Previously they were shown in white, due to an oversight in _draw_main(). _draw_main() should use the same logic as _shown_nodes(). Move it into a separate _visible() function and call it from both. --- menuconfig.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'menuconfig.py') diff --git a/menuconfig.py b/menuconfig.py index 7745800..8d06e44 100755 --- a/menuconfig.py +++ b/menuconfig.py @@ -1337,7 +1337,7 @@ def _draw_main(): # outside show-all mode, which could look confusing/broken. Invisible # symbols show up outside show-all mode if an invisible symbol has # visible children in an implicit (indented) menu. - if not _show_all or (node.prompt and expr_value(node.prompt[1])): + if _visible(node) or not _show_all: style = _style["selection" if i == _sel_node_i else "list"] else: style = _style["inv-selection" if i == _sel_node_i else "inv-list"] @@ -1468,7 +1468,7 @@ def _shown_nodes(menu): # with visible items, even if the node itself is invisible. This # can happen e.g. if the symbol has an optional prompt # ('prompt "foo" if COND') that is currently invisible. - if shown(node) or shown_children: + if _visible(node) or shown_children or _show_all: res.append(node) res += shown_children @@ -1476,13 +1476,6 @@ def _shown_nodes(menu): return res - def shown(node): - # Show the node if its prompt is visible. For menus, also check - # 'visible if'. In show-all mode, show everything. - return _show_all or \ - (node.prompt and expr_value(node.prompt[1]) and not - (node.item == MENU and not expr_value(node.visibility))) - if isinstance(menu.item, Choice): # For named choices defined in multiple locations, entering the choice # at a particular menu node would normally only show the choice symbols @@ -1523,6 +1516,14 @@ def _shown_nodes(menu): return rec(menu.list) +def _visible(node): + # Returns True if the node should appear in the menu (outside show-all + # mode) + + return node.prompt and expr_value(node.prompt[1]) and not \ + (node.item == MENU and not expr_value(node.visibility)) + + def _change_node(node): # Changes the value of the menu node 'node' if it is a symbol. Bools and # tristates are toggled, while other symbol types pop up a text entry -- cgit v1.2.3