Lines Matching +full:- +full:sc

4 # SPDX-License-Identifier: ISC
10 # pylint: disable=undefined-variable
16 A Tkinter-based menuconfig implementation, based around a treeview control and
21 single menu (like menuconfig.py). Only single-menu mode distinguishes between
24 A show-all mode is available that shows invisible items in red.
29 Ctrl-S : Save configuration
30 Ctrl-O : Open configuration
31 Ctrl-A : Toggle show-all mode
32 Ctrl-N : Toggle show-name mode
33 Ctrl-M : Toggle single-menu mode
34 Ctrl-F, /: Open jump-to dialog
44 When run in standalone mode, the top-level Kconfig file to load can be passed
45 as a command-line argument. With no argument, it defaults to "Kconfig".
96 # Help text for the jump-to dialog
99 of them. Python's regex flavor is used (see the 're' module). Double-clicking
117 # The Treeview in the jump-to dialog. None if the jump-to dialog isn't
121 # List of Nodes shown in the jump-to dialog
127 # The button shown in single-menu mode for jumping to the parent menu
139 # The current menu. Ignored outside single-menu mode.
156 # showing the save-and-quit dialog.
194 # Current menu in single-menu mode
199 # Nothing visible. Start in show-all mode and try again.
203 # the tree is non-empty in the rest of the code.
207 "Empty configuration -- nothing to configure.\n\n"
228 (_root.winfo_screenwidth() - _root.winfo_reqwidth())//2,
229 (_root.winfo_screenheight() - _root.winfo_reqheight())//2))
257 # Returns True if a just-loaded .config file is outdated (would get
311 # Start with show-name disabled
316 # Note: Binding this for the jump-to tree as well would cause issues due to
322 _root.bind("<Control-s>", _save)
323 _root.bind("<Control-o>", _open)
324 _root.bind("<Control-a>", _toggle_showall)
325 _root.bind("<Control-n>", _toggle_showname)
326 _root.bind("<Control-m>", _toggle_tree_mode)
327 _root.bind("<Control-f>", _jump_to_dialog)
334 # Base64-encoded images embedded in this script are used if
339 # garbage-collected. Passing an image to a Tkinter function isn't enough to
353 # $ base64 -w0 foo.gif | xclip
378 # The treeview rowheight isn't adjusted automatically on high-DPI displays,
393 # be future-safe.
405 _root.tk.call("wm", "iconphoto", _root._w, "-default", _icon_img)
458 # Allow the show-all and single-menu status to be queried via plain global
469 ttk.Checkbutton(topframe, text="Single-menu mode", command=_do_tree_mode,
473 _backbutton = ttk.Button(topframe, text="<--", command=_leave_menu,
502 # and the jump-to dialog.
531 tree.bind("<Double-1>", _tree_double_click)
552 tree.tag_configure("n-bool", image=_n_bool_img)
553 tree.tag_configure("y-bool", image=_y_bool_img)
554 tree.tag_configure("m-tri", image=_m_tri_img)
555 tree.tag_configure("n-tri", image=_n_tri_img)
556 tree.tag_configure("m-tri", image=_m_tri_img)
557 tree.tag_configure("y-tri", image=_y_tri_img)
558 tree.tag_configure("m-my", image=_m_my_img)
559 tree.tag_configure("y-my", image=_y_my_img)
560 tree.tag_configure("n-locked", image=_n_locked_img)
561 tree.tag_configure("m-locked", image=_m_locked_img)
562 tree.tag_configure("y-locked", image=_y_locked_img)
563 tree.tag_configure("not-selected", image=_not_selected_img)
576 # Micro-optimize this a bit.
597 # Work around not being to Ctrl-C/V text from a disabled Text widget, with a
598 …d in https://stackoverflow.com/questions/3842155/is-there-a-way-to-make-the-tkinter-text-widget-re…
666 # Detach all tree items before re-stringing them. This is relatively fast,
680 # Updates the tree starting from menu.list, in full-tree mode. To speed
681 # things up, only open menus are updated. The menu-at-a-time logic here is
682 # to deal with invisible items that can show up outside show-all mode (see
704 # for full-tree mode. A tricky detail is that invisible items need to be
720 # for an m/y-valued symbol with an optional prompt
735 # Updates the tree in single-menu mode. See _build_full_tree() as well.
742 # Used for single-menu mode. Similar to _shown_full_nodes(), but doesn't
770 # Returns True if the node should appear in the menu (outside show-all
780 # corresponds to the top-level menu, and can vary in single-menu mode.
788 # show-all mode, which could look confusing/broken. Invisible symbols
789 # are shown outside show-all mode if an invisible symbol has visible
816 # Symbol without prompt (can show up in show-all)
851 # In single-menu mode, print "--->" next to nodes that have menus that can
852 # potentially be entered. Print "----" if the menu is empty. We don't allow
855 s += " --->" if _shown_menu_nodes(node) else " ----"
875 # Choice symbol in y-mode choice
876 return "selected" if item.choice.selection is item else "not-selected"
880 return "" if isinstance(item, Choice) else item.str_value + "-locked"
883 return item.str_value + "-bool"
887 return item.str_value + "-my"
888 return item.str_value + "-tri"
912 # Double-click on the Kconfig treeview
914 # Do an extra check to avoid weirdness when double-clicking in the tree
929 # Enter press or double-click within the Kconfig treeview. Prefer to
970 # Leave the current menu in single-menu mode
983 # If the node can be entered in single-menu mode, do it
992 # Returns True if single-menu mode is on and 'node' is an (interface)
1002 sc = node.item
1004 if not isinstance(sc, (Symbol, Choice)):
1007 # This will hit for invisible symbols, which appear in show-all mode and
1013 return sc.orig_type in (STRING, INT, HEX) or len(sc.assignable) > 1 \
1014 or _is_y_mode_choice_sym(sc)
1025 # Can only get here in full-tree mode
1039 sc = _id_to_node[sel].item
1040 if isinstance(sc, (Symbol, Choice)) and tri_val in sc.assignable:
1041 _set_val(sc, tri_val)
1047 # Lazily populates the Kconfig tree when menus are opened in full-tree mode
1053 # single-menu mode otherwise.
1107 # good APIs for this. Might fail for super-obscure cases with tiny trees,
1108 # but you'd just get a small scroll mess-up.
1115 # (either the main window or the jump-to dialog), in case we need to pop up
1121 # sc = symbol/choice
1122 sc = node.item
1124 if sc.type in (INT, HEX, STRING):
1128 # can't deal with. UTF-8-encode the string to work around it.
1130 s = s.encode("utf-8", "ignore")
1133 _set_val(sc, s)
1135 elif len(sc.assignable) == 1:
1138 _set_val(sc, sc.assignable[0])
1142 # sc.assignable, with wrapping
1143 val_index = sc.assignable.index(sc.tri_value)
1144 _set_val(sc, sc.assignable[(val_index + 1) % len(sc.assignable)])
1147 def _set_val(sc, val): argument
1156 if val != sc.str_value:
1157 sc.set_value(val)
1161 # than in the show-all case, that might mess up the scroll slightly in
1162 # rare cases, but is fast and flicker-free.
1170 # from the jump-to dialog), then avoid messing with the scroll and hope
1173 _tree.yview_scroll(_item_row(stayput) - old_row, "units")
1239 # https://stackoverflow.com/questions/29334544/why-does-tkinters-entry-xview-moveto-fail.
1266 # like the top-left corner of the screen otherwise. See the menuconfig()
1278 x = _root.winfo_rootx() + (_root.winfo_width() - dialog_width)//2
1279 y = _root.winfo_rooty() + (_root.winfo_height() - dialog_height)//2
1283 x = screen_width - dialog_width
1287 y = screen_height - dialog_height
1297 # Returns True if the string 's' is a well-formed value for 'sym'.
1301 # Anything goes for non-int/hex symbols
1324 "{} is outside the range {}-{}".format(s, low_s, high_s),
1341 return "Range: {}-{}".format(low.str_value, high.str_value)
1435 # Turn on show-all if we're in single-menu mode and would end
1447 # Toggles show-name mode on/off
1454 # Updates the UI for the current show-name setting
1465 _tree.column("#0", width=max(tree_width - name_width, 1))
1476 # Toggles show-all mode on/off
1483 # Updates the UI for the current show-all setting
1485 # Don't allow turning off show-all if we'd end up with no visible nodes
1492 # show-all being turned off).
1497 old_scroll = _item_row(stayput) - \
1505 # height of the new tree. Since the tree with show-all on is guaranteed
1507 # turning show-all on.
1511 # things work anyway there (with usually minor scroll mess-ups in the
1516 _tree.yview(_item_row(stayput) - old_scroll)
1523 # shown with the current show-all setting. Also handles the
1526 # show-all mode, which mustn't be turned off.
1533 # Toggles single-menu mode on/off
1540 # Updates the UI for the current tree mode (full-tree or single-menu)
1545 # _jump_to() -> _enter_menu() already updates the tree, but
1546 # _jump_to() -> load_parents() doesn't, because it isn't always needed.
1547 # We always need to update the tree here, e.g. to add/remove "--->".
1555 # Enters the menu 'menu' and selects the first item. Used in single-menu
1563 # Enters the menu 'menu'. Used in single-menu mode.
1574 # Leaves the current menu. Used in single-menu mode.
1618 # Used when changing show-all mode, where non-visible (red) items will
1836 tree.bind("<Double-1>", jump_to_selected)
1883 sc = node.item
1891 if not (sc.name and search(sc.name.lower()) or
1925 # Micro-optimize a bit
1962 # += is in-place for lists
1992 # Menus are lazily populated as they're opened in full-tree mode, but
2073 def _name_info(sc): argument
2077 return (sc.name if sc.name else standard_sc_expr_str(sc)) + "\n\n"
2097 s += " - " + sym.name
2105 def _help_info(sc): argument
2106 # Returns a string with the help text(s) of 'sc' (Symbol or Choice).
2112 for node in sc.nodes:
2119 def _direct_dep_info(sc): argument
2120 # Returns a string describing the direct dependencies of 'sc' (Symbol or
2125 return "" if sc.direct_dep is _kconf.y else \
2127 .format(TRI_TO_STR[expr_value(sc.direct_dep)],
2128 _split_expr_info(sc.direct_dep, 2))
2131 def _defaults_info(sc): argument
2132 # Returns a string describing the defaults of 'sc' (Symbol or Choice)
2134 if not sc.defaults:
2138 if len(sc.defaults) > 1:
2142 for val, cond in sc.orig_defaults:
2143 s += " - "
2144 if isinstance(sc, Symbol):
2169 # Returns a string with 'expr' split into its top-level && or || operands,
2213 res += " - {}\n".format(split_expr(si, AND)[0].name)
2220 "Symbols currently y-selecting this symbol:\n")
2222 "Symbols currently m-selecting this symbol:\n")
2224 "Symbols currently n-selecting this symbol (no effect):\n")
2228 "Symbols currently y-implying this symbol:\n")
2230 "Symbols currently m-implying this symbol:\n")
2232 "Symbols currently n-implying this symbol (no effect):\n")
2245 s += (len(s) - 1)*"="
2263 # In the top-level Kconfig file
2267 " -> ".join("{}:{}".format(filename, linenr)
2282 path = " -> " + (node.prompt[0] if node.prompt else
2288 def _name_and_val_str(sc): argument
2291 # Show the values of non-constant (non-quoted) symbols that don't look like
2295 if isinstance(sc, Symbol) and not sc.is_constant and not _is_num(sc.name):
2296 if not sc.nodes:
2298 return "{}(undefined/n)".format(sc.name)
2300 return '{}(={})'.format(sc.name, sc.str_value)
2303 return standard_sc_expr_str(sc)