summaryrefslogtreecommitdiff
path: root/menuconfig.py
AgeCommit message (Collapse)Author
2019-04-17menuconfig: Style nitUlf Magnusson
Shorten a bit.
2019-04-17menuconfig: _select_imply_info() style nitUlf Magnusson
2019-04-17menuconfig: Micro-optimize incremental searchUlf Magnusson
removing the matches.append lookup saves a few %, as measured with line_profiler. It's fast enough already on any reasonable machine, so it's a bit silly, but it's pretty trivial.
2019-04-17menuconfig: _jump_to_dialog() comment nitsUlf Magnusson
Make things a bit more compact.
2019-04-17menuconfig: Add missing 'return' in _select_selected_choice_sym()Ulf Magnusson
Won't affect behavior, but it was intended.
2019-04-17menuconfig: Fix display issue for optional-prompt menuconfigsUlf Magnusson
_shown_nodes() needs to check whether invisible 'menuconfig' symbols with optional prompts have visible children, so that they can be shown outside show-all mode. Previously, only 'config' symbols were checked.
2019-04-11menuconfig: Simplify _menu_path_info()Ulf Magnusson
2019-04-11menuconfig: Include all parents in menu pathsUlf Magnusson
Previously, symbols not defined with 'menuconfig' with children weren't listed in the children's menu paths. It was deliberate, but it's probably an anti-feature in retrospect, because it can make it harder to find stuff by following the menu path. Don't try to be clever and just list all the parent nodes in the menu path.
2019-04-11menuconfig: Rename _try_set_locale() to try_set_locale()Ulf Magnusson
This function isn't defined at the module level.
2019-04-10menuconfig: Rename _check_validity() to _check_valid()Ulf Magnusson
Bit shorter, as clear.
2019-04-10menuconfig: Code style nitsUlf Magnusson
2019-04-05menuconfig: Make comment re. preserving cursor position more accurateUlf Magnusson
Items being added above the selected item would mess with the cursor position too, if we didn't compensate.
2019-04-05menuconfig: Avoid needlessly turning on show-all in rare casesUlf Magnusson
Loading a new configuration with the cursor on an invisible item with visible children (can happen with optional prompts) would needlessly turn on show-all, even though such invisible items are always shown. Fix it by doing a more explicit check for whether the selected item shows up in the menu after loading the configuration, like _toggle_show_all() and _jump_to() do.
2019-04-05menuconfig: Fix typo in comment in _load_dialog()Ulf Magnusson
Show-all mode is turned on if the node becomes invisible. The comment said the opposite if you didn't include the parenthesis. Piggyback some code nits.
2019-04-04menuconfig: Show menus with unsatisfied 'visible if' in red in show-all modeUlf Magnusson
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.
2019-04-03menuconfig: Simplify show-all backwards searchUlf Magnusson
Roll the reversing into the slice.
2019-03-21menuconfig: Whitespace nitUlf Magnusson
2019-03-20menuconfig: Style nitsUlf Magnusson
2019-03-19menuconfig: Mention windows-curses in module docstringUlf Magnusson
People might miss it otherwise, and think they have to download and install the wheels manually.
2019-03-19menuconfig: Get rid of 'platform' importUlf Magnusson
Test for Windows with os.name == 'nt' instead. Saves around 10 ms of startup time.
2019-03-16menuconfig: Add generic window height/width helpersUlf Magnusson
Replace _menu_win_height() with two generic _height(win)/_width(win) helpers and use them for other windows as well. Makes things a bit easier to read.
2019-03-14menuconfig: Fix some typos in commentsUlf Magnusson
2019-03-14menuconfig: Put two blank lines between top-level functionsUlf Magnusson
Be consistent with the other utilities.
2019-01-15Update copyright years for 2019Ulf Magnusson
2018-12-24menuconfig: Prompt for save if a different .config would be savedUlf Magnusson
Previously, menuconfig.py only prompted for saving the configuration if .config didn't exist or the user changed symbol values within the interface. Also make it prompt for save if Kconfig symbols have been added, removed, or have had their defaults changed, provided it would make the saved .config differ from the loaded one. This usually won't matter for correctness, because loading an outdated configuration performs an implicit olddefconfig, but it's less confusing. Also add a Kconfig.missing_syms attribute that records all assignments to undefined symbols in the most recently loaded .config file. This is needed to implement the check for whether the saved .config would be different. As an unrelated change, always prompt for saving if a .config has been loaded from within the menuconfig interface. The intention is probably often to save the configuration somewhere else, even if it isn't modified.
2018-12-15menuconfig: Add show-help modeUlf Magnusson
Pressing F toggles show-help mode, where the help window at the bottom displays the help text of the currently selected item, if any. Can be handy when browsing through symbols. Also mention the different modes that are available in the module docstring.
2018-12-08Make {load,write}_config(filename=None) implement the standard behaviorUlf Magnusson
Make the previously obligatory 'filename' argument to load_config() and write_config() default to None, and have that implement the behavior you'd usually want: read/write either KCONFIG_CONFIG or ".config" if unset, and read the 'option defconfig_list' configuration file if KCONFIG_CONFIG/".config" doesn't exist. For load_config(), filename=None also allows the configuration file to be missing without raising an error. load_config() returns True if a local configuration file was loaded, which is useful to check in the menuconfig (if no local configuration file exists, we always want to prompt for saving the configuration when exiting). Also add a 'verbose' argument (default True) to load_config() and read_config() that makes them print which files were read/written in filename=None mode. Also generalize olddefconfig.py and oldconfig.py to not require there to already be a local configuration file. This was a bit silly for olddefconfig.py in particular. Remove the examples/defconfig.py script. It's a duplicate of olddefconfig.py.
2018-12-07menuconfig: Code formatting nitUlf Magnusson
2018-11-28menuconfig: Clarify the scope of the named choice special-casingUlf Magnusson
One thing that irks me a bit about it is that it might give the idea that menuconfigs have to include it, making things seem more complex than they really are.
2018-11-28menuconfig: Improve comment re. multiply-defined choice symbolsUlf Magnusson
The thing it's talking about usually happens when some file with a named choice is included multiple times with different dependencies.
2018-11-28menuconfig: Fix variable name typo in commentUlf Magnusson
2018-11-28menuconfig: Only list duplicated choice symbols onceUlf Magnusson
When a Kconfig file defined a named choice and was included multiple times, the choice symbols were listed multiple times in the menuconfig as well (due to commit 17d7c1e ("menuconfig: Show all symbols at each menu location for multi.def. choices")). That's probably not what you want. Tweak it so that each symbol is only shown once, with the prompt that was used for it at whatever choice definition location is entered. Also change how the choice selection is displayed before the choice is entered, so that the prompt used for the selected symbol at that particular location is used. Previously, the prompt at the first definition location for the symbol was always used. (Note that all of this is only about how things are displayed. It's not essential to functionality, in case you're writing your own menuconfig.)
2018-11-21menuconfig: Mention that menus can be 'menuconfig' symbolsUlf Magnusson
They're either proper menus, choices, or 'menuconfig' symbols.
2018-11-21menuconfig: Print '----' instead of '---> (empty)'Ulf Magnusson
This matches the C tools and is a bit less spammy. Maybe it's less clear what it means at a glance, but it's probably less confusing for disabled 'menuconfig' symbols at least.
2018-11-18menuconfig: Never snap scroll back to max_scrollUlf Magnusson
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).
2018-11-18menuconfig: Tighten up _shown_nodes() a bitUlf Magnusson
Move the addition of the visible child nodes and use += instead of extend().
2018-11-18menuconfig: Get rid of a temporary list in the jump-to implemenationUlf Magnusson
Not noticeable performance-wise, but a bit neater.
2018-11-07menuconfig: Support HOME and END in the jump-to dialogUlf Magnusson
Oversight. END can be handy for viewing all choices, menus, and comments, which appear at the end. Also support Ctrl-D as an alias for Page Down. Ctrl-U is already used by the edit box (erase to beginning of line). Also change the jump-to dialog title to hint that other things besides symbols can be jumped to.
2018-11-04Comment grammar nitUlf Magnusson
2018-11-04menuconfig: Move cursor to choice selection when entering choicesUlf Magnusson
Previously, the first entry was selected, like for menus. Also tweak _center_vertically() so that the menu is never scrolled down when all entries fit on the screen.
2018-11-02menuconfig: Fix crash when toggling symbols without a typeUlf Magnusson
Trying to toggle the following symbol crashed the menuconfig: config FOO prompt "foo" Symbols defined without a type are pointless and generate a warning (particular definition locations can omit the type, but some definition location should give a type if the symbol is defined in multiple locations). We should never crash for them though. Fix the crash. The code assumed that the symbol's current value would appear in Symbol.assignable, like for a visible bool/tristate, but symbols without types get their name as their value. Also skip printing "(NEW)" next to symbols without a type.
2018-11-01menuconfig: Add quotes around filename for .config loading errorsUlf Magnusson
Turns into a weird-looking 'Error loading ' otherwise. Maybe Enter should be ignored for empty filenames instead...
2018-10-31Make errno/strerror/filename available on IOErrorUlf Magnusson
An error reporting flaw was that most raised IOErrors got their errno/strerror/filename fields stripped, due to wanting to show a custom messages. The problem was that adding back 'errno' and 'strerror' made IOError.__str__() always return a fixed string ("[Errno <errno>] <strerror>"), ignoring any custom message. This is friendly to users, but unfriendly to scripts (the menuconfig had a workaround). Make things friendly to both by raising an internal subclass of IOError instead, that preserves errno/strerror/filename but prints a custom message. The exception can then still be caught as IOError/OSError by scripts.
2018-10-22menuconfig: Mention jump-to in info dialog helpUlf Magnusson
Might be hard to discover that [/] works inside the info dialog otherwise.
2018-10-21menuconfig: Show the selected symbol for promptless choicesUlf Magnusson
If a choice is defined in multiple locations to add symbols, and show-all mode is turned on to reveal one of the promptless definitions, then it doesn't hurt to show the selected symbol next to it.
2018-10-21menuconfig: _node_str() simplification nitUlf Magnusson
2018-10-16menuconfig: Use Kconfig.unique_choices in jump-toUlf Magnusson
Use Kconfig.unique_choices instead of Kconfig.choices in the jump-to dialog, as choices defined in multiple locations should only get their menu nodes added once (to avoid redundant entries). I noticed a related Kconfiglib issue while working on this: Kconfig.choices has been identical to Kconfig.unique_choices all long, so things were never actually broken. That means Kconfig.choices should be fixed to match its description though. The next commit will do that.
2018-10-15menuconfig: Simplify _sorted_menu_comment_nodes()Ulf Magnusson
Can use the same function for both sort keys, and the logic can be simplified a bit too. The += is deliberate, to do in-place modification.
2018-10-14menuconfig: Fix some minor resizing jumpiness on gnome-terminalUlf Magnusson
gnome-terminal jerks a bit whenever the terminal is shrunk so that the row with the cursor on it disappears. This is probably gnome-terminal shoddiness, but it's pretty easy to work around by drawing stuff at the top last, so do it. No need to do it for the jump-to dialog, because the cursor is already in the edit box at the top there.
2018-10-14menuconfig: Switch back to "very visible" cursor after Ctrl-FUlf Magnusson
Was set back to "normal" instead due to a typo, which is inconsistent with the rest of the code.