Lines Matching +full:bad +full:- +full:key +full:- +full:2

4 # SPDX-License-Identifier: ISC
10 # pylint: disable=undefined-variable
16 A Tkinter-based menuconfig implementation, based around a treeview control and
18 ('make xconfig'). Compatible with both Python 2 and Python 3.
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".
69 # Python 2
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
355 …load_image("icon", "R0lGODlhMAAwAPEDAAAAAADQAO7u7v///yH5BAUKAAMALAAAAAAwADAAAAL/nI+gy+2Pokyv2jazuZ…
378 # The treeview rowheight isn't adjusted automatically on high-DPI displays,
383 .metrics("linespace") + 2
393 # be future-safe.
397 if elm[:2] != ("!disabled", "!selected")]})
404 # iconphoto() isn't available in Python 2's Tkinter
405 _root.tk.call("wm", "iconphoto", _root._w, "-default", _icon_img)
439 .grid(column=2, row=0, sticky="ew", padx=".05c")
451 ipady=".2c")
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,
471 .grid(column=2, row=1, sticky="nsew", padx=".05c", pady="0 .05c")
473 _backbutton = ttk.Button(topframe, text="<--", command=_leave_menu,
502 # and the jump-to dialog.
523 # Text.replace() is not available in Python 2's Tkinter
531 tree.bind("<Double-1>", _tree_double_click)
537 tree.bind("y", _tree_set_val(2))
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
811 (sym.choice and sym.choice.tri_value == 2):
816 # Symbol without prompt (can show up in show-all)
832 elif isinstance(node.item, Choice) and node.item.tri_value == 2:
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"
886 if item.assignable == (1, 2):
887 return item.str_value + "-my"
888 return item.str_value + "-tri"
895 return isinstance(item, Symbol) and item.choice and item.visibility == 2
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
967 # Left arrow key press within the Kconfig treeview
970 # Leave the current menu in single-menu mode
978 # Right arrow key press within the Kconfig treeview
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)
1007 # This will hit for invisible symbols, which appear in show-all mode and
1025 # Can only get here in full-tree mode
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
1127 # Tkinter can return 'unicode' strings on Python 2, which Kconfiglib
1128 # can't deal with. UTF-8-encode the string to work around it.
1130 s = s.encode("utf-8", "ignore")
1137 # case: .assignable can be (2,) while .tri_value is 0.
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")
1184 # No 'nonlocal' in Python 2
1209 .grid(column=0, row=0, columnspan=2, sticky="w", padx=".3c",
1210 pady=".2c .05c")
1216 entry.grid(column=0, row=1, columnspan=2, sticky="ew", padx=".3c")
1222 .grid(column=0, row=2, columnspan=2, sticky="w", padx=".3c",
1223 pady=".2c 0")
1239 # https://stackoverflow.com/questions/29334544/why-does-tkinters-entry-xview-moveto-fail.
1265 # Centers 'dialog' on the root window. It often ends up at some bad place
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
1309 "Bad value",
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) - \
1498 _item_row(_tree.identify_row(_treeview_rowheight//2))
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.
1612 return _tree.identify_row(_tree.winfo_height()//2) or \
1618 # Used when changing show-all mode, where non-visible (red) items will
1796 .grid(column=0, row=0, columnspan=2, sticky="w", padx=".1c",
1810 msglabel.grid(column=0, row=2, sticky="w", pady="0 .1c")
1813 panedwindow.grid(column=0, row=3, columnspan=2, sticky="nsew")
1822 jumpto_button.grid(column=0, row=4, columnspan=2, sticky="ns", pady=".1c")
1836 tree.bind("<Double-1>", jump_to_selected)
1864 # there). Those probably have bad interactions with re.search(), which
1869 msg = "Bad regular expression"
1925 # Micro-optimize a bit
1961 key=lambda sym: sym.name):
1962 # += is in-place for lists
1968 key=lambda choice: choice.name or "")
1972 key=lambda node: node.prompt[0] if node.prompt else "")
1985 cached_nodes += sorted(_kconf.menus, key=prompt_text)
1986 cached_nodes += sorted(_kconf.comments, key=prompt_text)
1992 # Menus are lazily populated as they're opened in full-tree mode, but
2097 s += " - " + sym.name
2128 _split_expr_info(sc.direct_dep, 2))
2143 s += " - "
2169 # Returns a string with 'expr' split into its top-level && or || operands,
2213 res += " - {}\n".format(split_expr(si, AND)[0].name)
2219 s += sis(sym.rev_dep, 2,
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")
2227 s += sis(sym.weak_rev_dep, 2,
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
2291 # Show the values of non-constant (non-quoted) symbols that don't look like