summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2018-05-11menucomment: Comment clarity nitUlf Magnusson
2018-05-11menuconfig: Code style nitUlf Magnusson
2018-05-11Fix _search_strings() cacheUlf Magnusson
The cache was broken due to using an old variable name. Piggyback a neat trick for storing globals in default arguments that I had missed until now.
2018-05-11menuconfig: Add prompts to incremental searchUlf Magnusson
Search and display prompts for menu nodes that have them. They often contain useful strings. Add a pre-search pass that generates a string to search/display for each menu node, to allow the search regex(es) to run over a single string. That also makes 'foo bar' match for a symbol that has 'FOO' in its name and 'bar' in its prompt, which is handy. Remove the '(in menu X)' string that was added previously for symbols defined in multiple locations. You'd usually be able to tell which menu node is which from the (lack of) prompt.
2018-05-10menuconfig: Add search with multiple search stringsUlf Magnusson
A search like 'host usb' now finds all symbol names that match both 'host' and 'usb' (as regular expressions), including e.g. USB_MTU3_HOST. This saves typing a bunch of '.*' and makes it easier to find symbols when you aren't sure what order the components appear in.
2018-05-10menuconfig: Refactor resizing after fullscreen dialogsUlf Magnusson
Cleaner to do it in _menuconfig(), as it makes the fullscreen dialogs fully independent. Saves some code too.
2018-05-10menuconfig: Remove confusing menu list commentUlf Magnusson
Might have made it sound like _parent_menu() returns a list.
2018-05-10Style nitsUlf Magnusson
Air some long conditionals out a bit. Be more consistent with format().
2018-05-09menuconfig: Misleading comment nitUlf Magnusson
Can't get { } since {} implies n isn't assignable.
2018-05-09menuconfig: Fix rendering of long prefilled edit box stringUlf Magnusson
The horizontal scroll (hscroll) wasn't initialized properly when the initial (prefilled) contents of an edit box was longer than the edit box itself (e.g. when saving with a long path in KCONFIG_CONFIG). Things snapped back into place once a key was pressed. Initialize hscroll properly to fix the initial rendering.
2018-05-08menuconfig: Convert the C locale to a UTF-8 locale for LC_CTYPEUlf Magnusson
If LC_CTYPE is set to the C locale, try to convert it to a UTF-8 locale. Use a list of commonly available UTF-8 locales. Give up and use the C locale if none of them are available. This fixes curses Unicode I/O issues on systems with bad defaults: ncurses configures itself from the locale settings, and the C locale implies ASCII. The logic mirrors https://www.python.org/dev/peps/pep-0538/. I took the list of locales to try from the CPython code (in Python/pylifecycle.c).
2018-05-08Increase indent for implicit submenus to 4Ulf Magnusson
Makes it easier to see the menu structure. Make the indent configurable via a _SUBMENU_INDENT configuration variable.
2018-05-07Add screenshots showing incremental searchUlf Magnusson
Should probably move the screenshots out into a separate section soon.
2018-05-07menuconfig: Add incremental regex search and jump-toUlf Magnusson
Pressing [/] brings up a dialog with an edit box where a regex can be entered. The list of matching symbols is always shown below it. Selecting a symbol and pressing [Enter] jumps directly to it in the menu tree. If the symbol is invisible, show-all mode is turned on automatically. This commit also includes a bunch of more-or-less unrelated changes from poking around with the code: - Some redundant styles were merged. Probably wouldn't want to have a different style for each separator line, for example... - [ESC] in the top menu now works like [Q] - Returning to a parent menu now makes sure that the selected row is visible, even if the terminal was shrunk between entering the child menu and leaving it. - A _max_scroll() helper was factored out to reduce code duplication. It takes a list of items and a window in which the list is displayed, with one row per item, and returns the minimum scroll value that will make the final item visible. - The save dialog now pops up a message to confirm that the save was successful. - Lots of minor code nits all over (renamings, etc.)
2018-05-03menuconfig: Scroll to show current menu in menu pathUlf Magnusson
Previously, the title of the current menu disappeared off the right edge of the terminal for long menu paths. Scroll the menu path to the right if needed to make sure it is always shown.
2018-05-03menuconfig: Quit immediately when configuration is unchangedUlf Magnusson
Don't bother to show the save-and-quit dialog. Also quit immediately if the configuration hasn't been changed since the last time it was explicitly saved with the save dialog. Rename _set_node() to _set_node_tri_val(), as the old name gets confusing with the new _set_val() function.
2018-05-03menuconfig: Support setting values with [N]/[M]/[Y]Ulf Magnusson
Works the same as in mconf.
2018-05-03menuconfig: Add a mode that shows invisible itemsUlf Magnusson
When show-all mode is enabled, all items in the current menu are shown, including promptless and invisible items. Promptless items are shown with their name within <> brackets in place of the prompt. This will make it possible to jump to invisible items once the jump-to feature is added. It is also a handy feature on its own. .config loading from within the interface will make use of it as well, in case the current menu becomes complete invisible. Piggyback various code cleanups. Rename _visible* to _shown*, as it now includes invisible items in show-all mode.
2018-05-01Force encoding to UTF-8 by default on Python 3Ulf Magnusson
Enough people have run into exceptions due to running in the C locale that it seems worthwhile. Add a new 'encoding' parameter to Kconfig.__init__() that specifies the encoding to use and make it default to "utf-8". Passing None gives the old behavior of using the encoding specified in the environment. Related PEP: https://www.python.org/dev/peps/pep-0538/
2018-05-01Formatting nitsUlf Magnusson
2018-05-01Make 5.0.0 releasev5.0.0Ulf Magnusson
New features: - ed3ceaa ("Make warnings available in a list") API changes: - 8983f7e ("Make disable_warnings() disable all warnings") This is a minor API behavior change, so the major version is bumped. It's unlikely to break anything people were depending on.
2018-05-01Make warnings available in a listUlf Magnusson
Also make printing of warnings to stderr optional. It's on by default, since it's almost always what you want. This makes printing and processing of warnings more flexible, compared to always printing warnings to stderr as soon as they're generated. It was inspired by wanting to promote certain warnings to errors in Zephyr, which previously required capturing stderr.
2018-05-01Fix link to genrest.py outputUlf Magnusson
2018-05-01Make disable_warnings() disable all warningsUlf Magnusson
...including the optional ones. Previously, those were independent. This is more intuitive, and it seems unlikely that you'd want some of the optional warnings printed without having general warnings printed. This is a small API behavior change, so the major version will be bumped to 5 at the next release. Programs that enabled optional warnings without enabling general warnings will be affected. This means that all warnings now go through the same code path, which will come in handy for later changes (making the warnings available in a list, though with stderr printing still enabled by default). Add some more documentation for the Kconfig.__init__() 'warn' parameter and the enable_redun_warnings() function as well, and clean up the variable naming a bit.
2018-05-01Make 4.3.0 releasev4.3.0Ulf Magnusson
4.2.1 should have been 4.3.0. That was not a bugfix release. Braino.
2018-05-01Make 4.2.1 releasev4.2.1Ulf Magnusson
New features: - 105c835 ("Add helper for splitting expressions") - 509e374 ("Add Choice.direct_dep field") A terminal menuconfig implementation has been added which relies on these features. Other improvements: - c1c5ef2 ("Print a warning for malformed .config lines") - 09b8c58 ("Give filename and context for UnicodeDecodeError")
2018-05-01Rename examples/menuconfig.py to menuconfig_example.pyUlf Magnusson
To avoid confusing it with the new terminal menuconfig implementation. Clean up the README a bit at the same time, removing some stuff that's less essential now (e.g. the menuconfig_example.py "screenshot").
2018-05-01Fix genrest.py linkUlf Magnusson
2018-05-01Add genrest.py from the Zephyr project as an exampleUlf Magnusson
2018-05-01Formatting fixUlf Magnusson
2018-05-01Fix README formattingUlf Magnusson
2018-05-01Add a terminal menuconfig implementationUlf Magnusson
Uses the 'curses' module, which is in the Python standard library. Only Python 3 is supported, mostly due to Unicode support. Windows support is provided through an external package which adds support for the 'curses' module on Windows. See the changes and the docstring in the newly added menuconfig.py for more information. Piggyback a README notes mentioning that Kconfiglib supports Unicode.
2018-04-25Give filename and context for UnicodeDecodeErrorUlf Magnusson
These errors are a pain to debug otherwise, and might look like Kconfiglib brokenness. Another option would be ignore decoding errors, or do the 'surrogateescape' thing on reading and writing, but keep it simple for now. Pointing out the problem might be more helpful.
2018-04-25Print a warning for malformed .config linesUlf Magnusson
Flag lines matching neither 'CONFIG_FOO=...' nor '# CONFIG_FOO is not set' that aren't blank or comments.
2018-04-19Add Choice.direct_dep fieldUlf Magnusson
Same as Symbol.direct_dep (OR of node dependencies from all definition locations). It's handy to have available when generating information about choices.
2018-04-11Add helper for splitting expressionsUlf Magnusson
I've had to implement the logic for walking reverse dependencies (from select) a couple of times now, and it's always a bit tricky to get right. Reduce code duplication and simplify things by adding a helper function split_expr() that splits an expression into a list of either its AND or OR operands. A nice side effect is that e.g. the warning generated for selecting a symbol with unsatisfied direct dependencies now lists the selecting symbols in the order that they appear in the Kconfig files. split_expr() might be helpful for splitting other types of expressions as well, e.g. to put operands on separate lines when generating documentation.
2018-04-07Make 4.2.0 releasev4.2.0Ulf Magnusson
New features and improvements: - 7245bad ("Parenthesize && expressions within || expressions") makes expressions more readable. - 2259d35 ("Generalize is_menuconfig to non-symbol items") can simplify menuconfig implementations. - c7ac6f8 ("Add parent deps to the right in _T_IF") makes parent dependencies consistently appear on the right in expressions, with the outermost parent dependency the furthest to the right. New warnings: - 7ba79ca ("Warn if user (.config) value is outside of 'range'") - 225ec4b ("Warn if a choice symbol is selected or implied") Some obscure false positive warnings for named choices were fixed too. This came up in https://github.com/zephyrproject-rtos/zephyr/issues/6948. - e8408a0 ("Move sanity checking to after _finalize_tree()")
2018-04-06Move sanity checking to after _finalize_tree()Ulf Magnusson
Previously, the warnings warning: FOO (defined at Kconfig:1, Kconfig:6) defined with type unknown warning: the default selection BAR (defined at Kconfig:9) of FOO (defined at Kconfig:1, Kconfig:6) is not contained in the choice were printed for this (obscure, but okay) pair of definitions: choice FOO default BAR endchoice choice FOO prompt "foo" config BAR bool "bar" endchoice The problem is that BAR is not known to be a choice symbol by the time the first choice definition is encountered in _finalize_tree(), since that's determined only when the second definition is encountered (it needs to happen there, because implicit submenus can influence whether a symbol is a choice symbol or not, and implicit submenus are determined in _finalize_tree()). Fix it by moving the sanity checks out of _finalize_tree() and into a separate pass over all symbols and choices that runs after _finalize_tree(). That might avoid other gotchas too.
2018-04-05Set is_menuconfig True on the top menuUlf Magnusson
Oversight
2018-04-04Code consistency nitUlf Magnusson
'is_menuconfig' is set after 'item' in the other cases.
2018-04-04Generalize is_menuconfig to non-symbol itemsUlf Magnusson
Extending the scope of is_menuconfig so that it's True for all items whose children should be displayed in a separate menu turns out to be handy when implementing menuconfig-like functionality. Keep the old name for backwards compatibility. It's good enough.
2018-03-28Parenthesize && expressions within || expressionsUlf Magnusson
This is redundant from an evaluation perspective, as && has higher precedence than ||, but is easier to read. A && B || C && D is now rendered as "(A && B) || (C && D)".
2018-03-26Use expr_str() to print selected/implied symbolsUlf Magnusson
This is redundant on its own, as only a single symbol can be selected/implied, meaning just .name will work fine too. It means that all symbols appearing in the __str__() representation of symbols and choices are now printed via expr_str() though, which might come in handy soon.
2018-03-26Refactor expr_str() casesUlf Magnusson
- Detect Symbol directly instead of as (not tuple) + (not choice) - Test explicitly for a tuple (non-Symbol) in NOT - Add some tests to get better coverage for NOT and parentheses
2018-03-25merge_config.py: Clean up name_and_loc_str()Ulf Magnusson
- Rename to name_and_loc(), to be consistent with the kconfiglib.py version - Use a comment instead of a docstring. Shorten the description a bit too. - Piggyback a missing # in conf3 in the module docstring. Typo.
2018-03-24Warn if a choice symbol is selected or impliedUlf Magnusson
This has no effect. Model the warning on the one for selecting a symbol with unsatisfied dependencies. This is a Kconfiglib-exclusive warning so far.
2018-03-24_check_choice_sanity() style nitUlf Magnusson
2018-03-24Rename _name_and_loc_str() to _name_and_loc()Ulf Magnusson
Bit shorter, still clear in context.
2018-03-24Refactor _warn_select_unsatisfied_deps()Ulf Magnusson
Simplify the looping and remove some comments that aren't super helpful. Also put " - " at the beginning of the lines listing the selecting symbols. Bit more readable.
2018-03-24Remove redundant int/hex user value 'is None' checkUlf Magnusson
A valid int/hex user value can never be an empty string, so they test can be simplified.