summaryrefslogtreecommitdiff
path: root/menuconfig.py
AgeCommit message (Collapse)Author
2019-06-03Improve warning control API (with backwards compatibility)Ulf Magnusson
A wart of the warning control API (enable/disable_*_warnings()) is that the current warning settings can't be queried. Querying warning settings is useful in functions that want to temporarily enable/disable some warning and then put things back to how they were. kconfiglib.load_allconfig() ran into this, for example. Make the internal warning control variables public (improve the naming at the same time), and encourage just setting them directly. Keep the old API for backwards compatibility. Also remove _warn_redun_assign() and _warn_override(). They're trivial and were called in a single place.
2019-06-03Have load_config() and write_(min_)config() return messagesUlf Magnusson
Hardcoding load_config() and write_(min_)config() to write any message to stdout is awkward, because it means that the message can't be easily reused when stdout is the wrong place to write it to (e.g. in menuconfig/guiconfig). This gets extra bad now that there's also the "No change to ..." message. Modify load_config() and write_(min_)config() to return the message as a string instead, and have them always return a message, instead of just when 'filename' is None and verbose=True. This makes things flexible and straightforward. Use the new behavior in menuconfig.py and guiconfig.py. They now show "No change to ..." when saving a file doesn't modify it. Tools that want to write messages to stdout should now do print(kconf.load_config()) / print(kconf.write_config()). There's no clean way to preserve perfect backwards compatibility here, but keep accepting the 'verbose' argument and print a deprecation warning if a value is ever passed for it. That way, scripts will keep running, though possibly with less output on stdout. This changes the meaning of the load_config() return value as well, though I suspect it was only ever used by the menuconfig/guiconfig interfaces. The new behavior applies for kconfiglib.VERSION >= (12, 0, 0).
2019-05-25Strip direct deps. from property conditions in Symbol/Choice/MenuNode.__str__()Ulf Magnusson
Commit e81a77b ("Consistently put direct deps. last when propagating") makes the position of the direct deps. in property conditions predictable after dependency propagation, making it easy to strip them as needed. Use this to implement MenuNode.orig_{prompt,defaults,selects,implies,ranges}, which work like the non-orig_* versions but omit the direct deps. Use those in turn to omit the direct deps in Symbol/Choice.__str__(). The direct deps. (with propagated parent deps.) can still be seen after 'depends on ...', so there is no loss of information. This unclutters Kconfig definitions shown in menuconfig/guiconfig and in any generated documentation. The old output also had duplicated dependencies, though it doesn't matter for evaluation. Before: config A bool prompt "A" if DEP default y if FOO && DEP depends on DEP After: config A bool prompt "A" default y if FOO depends on DEP
2019-05-22menuconfig: Fix inconsistent top/bottom scroll offset due to off-by-oneUlf Magnusson
The scroll offset when scrolling up was one more than when scrolling down, due to an off-by-one.
2019-05-19Remove some comments re. setup.py entry pointsUlf Magnusson
Only appeared in two of the scripts, and main() is such a common convention anyway.
2019-05-19Make .config.old easier to discoverUlf Magnusson
Mention that the old version of an overwritten configuration file is saved to <filename>.old in a few different places, to make it easier to discover.
2019-05-19String repetition consistency nitUlf Magnusson
2019-04-28menuconfig: Fix display issue for unsatisfied-deps selected symbol with childrenUlf Magnusson
A symbol with unsatisfied direct dependencies can end up with visible children in an implicit submenu if it is selected (though that generates a warning), so the optimization in _shown_nodes() isn't safe, and causes the child nodes to not be shown outside show-all mode. Just remove the optimization. Trying things out some more, everything's plenty fast enough anyway. Checking the direct dependencies of the parent instead would be safe.
2019-04-27menuconfig: Fix typo in docsUlf Magnusson
2019-04-26menuconfig: Style consistency nitsUlf Magnusson
2019-04-26menuconfig: Remove unused UNKNOWN importUlf Magnusson
2019-04-26menuconfig: Improve space/enter behavior slightlyUlf Magnusson
Space toggles value is possible, and enters menus otherwise. Enter works the other way around. Make this explicit in the code, which also fixes some corner cases, like space doing nothing on a y-selected menuconfig symbol.
2019-04-26menuconfig: Use "(Top)" instead of "(top menu)"Ulf Magnusson
Consistent with guiconfig.py and shorter.
2019-04-26menuconfig: Use 'orig_type' instead of 'type' where possibleUlf Magnusson
Symbol.type is only needed when there might be tristates demoted to bools due to modules being disabled. Symbol.orig_type is faster to read otherwise (no @property magic).
2019-04-26menuconfig: NitUlf Magnusson
Make a comment consistent with guiconfig.py.
2019-04-18menuconfig: Remember last saved/loaded path and improve _conf_changedUlf Magnusson
Remember the last path that was manually saved/loaded instead of reverting back to standard_config_filename() (e.g. .config). Remember the path to the last saved minimal configuration separately as well. Also improve the _conf_changed behavior when loading a .config within the interface. Instead of always treating it as needing to be saved, check if it's outdated, like for the .config file loaded on startup. Also make the exit message ("No changes to save", etc.) always include the target .config file, which is helpful. Previously, only the save message did.
2019-04-17menuconfig: Prune _shown_nodes() recursionUlf Magnusson
When looking for visible children of invisible symbol nodes, _shown_nodes() was always recursing all the way out the leaf nodes. That's a ton of redundant work, though it doesn't seem to have lead to noticeable slowness (it does in the GUI menuconfig). Stop the search at symbol nodes with node.dep = n (from 'if'/'depends on'). Those can never have visible children, because node.dep gets propagated to prompts.
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.