summaryrefslogtreecommitdiff
path: root/menuconfig.py
AgeCommit message (Collapse)Author
2019-10-09menuconfig: _sorted_sc_nodes() code formatting nitUlf Magnusson
2019-10-05menuconfig: Give hint when 'curses' can't be imported on WindowsUlf Magnusson
Tell people to install something like windows-curses. Might help avoid some trouble after commit 21b4c1e ("Do not automatically install windows-curses on Windows").
2019-10-05Do not automatically install windows-curses on WindowsUlf Magnusson
It breaks installation with pip on MSYS2, and Kconfiglib can still be useful without the terminal menuconfig. Unfortunately, MSYS2 seems tricky to identify via environment markers (https://www.python.org/dev/peps/pep-0508/#environment-markers). This has breakage/annoyance potential, as windows-curses now needs to be installed manually. The major Kconfiglib version will be increased. Sorry if this change caused problems! Fixes: #77
2019-08-03menuconfig/guiconfig: Print 'default:' with no 's' if there's just oneUlf Magnusson
Most common case, and makes the symbol info read better.
2019-07-02Catch EnvironmentError instead of OSError/IOErrorUlf Magnusson
menuconfig.py tended to crash on I/O errors on Python 2, due to forgetting to update some 'except OSError's. Catch EnvironmentError instead. EnvironmentError is a common base class of IOError and OSError on Python 2, and an alias for OSError on Python 3. Use it elsewhere too, as it might help catch obscure I/O errors on Python 2.
2019-06-24menuconfig/guiconfig: Use orig_defaults in symbol infoUlf Magnusson
Forgot that they show defaults separately. Use orig_defaults instead of 'defaults' to de-spam it a bit. The direct dependencies are shown above the defaults.
2019-06-15Use 'change' instead of 'convert' re. changing LC_CTYPEUlf Magnusson
Might be less confusing in the context of locales.
2019-06-15menuconfig: Be silent when changing LC_CTYPE to a UTF-8 localeUlf Magnusson
Having LC_ALL=C and the like in Makefiles is probably pretty common, to get consistent collation and messages from commands and stuff. It currently makes menuconfig.py spit out a warning about changing the locale to a UTF-8 locale though. Just remove the message, and silently change the locale. The Python 3.7 PEP 538 code is silent as well.
2019-06-09menuconfig/guiconfig: Clean up 'range' checking a bitUlf Magnusson
Just cosmetic.
2019-06-06menuconfig: Fix help display on Python 2Ulf Magnusson
textwrap.indent() was added in Python 3.3.
2019-06-06Update various comments now that menuconfig is Python 2-compatibleUlf Magnusson
2019-06-06menuconfig: Have hashbang point to 'python' instead of 'python3'Ulf Magnusson
Consistent with the other utilities, and now works even when 'python' is Python 2.
2019-06-06menuconfig: Import print_function for Python 2 compatibilityUlf Magnusson
2019-06-06menuconfig: Only decode curses.erasechar() on Python 3Ulf Magnusson
Avoids turning it into a Unicode string on Python 2, which gets messy when strings are compared.
2019-06-06menuconfig: Fall back on getch() when get_wch() isn't availableUlf Magnusson
Preparation for Python 2 compatibility. Also indirectly makes it compatible with Python 3.2 and earlier (get_wch() was added in 3.3).
2019-06-06menuconfig: Get rid of 'nonlocal'Ulf Magnusson
Preparation for Python 2 compatibility.
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