summaryrefslogtreecommitdiff
path: root/menuconfig.py
AgeCommit message (Collapse)Author
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.
2018-10-14menuconfig: Mention some ncurses ESCDELAY investigationUlf Magnusson
2018-10-14menuconfig: Mention some potential (though never seen) ESCDELAY iffinessUlf Magnusson
2018-10-14menuconfig: Mention that jump-to has been generalized in docstringUlf Magnusson
Can jump to choices, menus, and comments now as well.
2018-10-14menuconfig: Fix crash when pressing Ctrl-F with no matches in jump-to dialogUlf Magnusson
Ctrl-F is the jump-to dialog view-help shortcut. It needs to check whether there are any matches, like Enter/jump-to does.
2018-10-14menuconfig: Add jump-to for choices, menus, and commentsUlf Magnusson
For choices, search the name and the prompt. This is the same as for symbols, except names are optional (and rare) for choices. For menus and comments, search the prompt (title text). When jumping to a non-empty choice or menu, jump into it instead of jumping to its menu node. If show-all mode is off and there are visible items in the choice/menu, then jump to the first visible node. Otherwise, enable show-all and jump to the first node.
2018-10-13menuconfig: Do not show range hint for symbols without rangesUlf Magnusson
The 'no range constraints' input dialog hint for int/hex symbols might be more confusing than helpful, especially if you assume it was something the symbol author put there. Only show the range hint for symbols with active ranges instead, and show nothing for other symbols.
2018-10-10menuconfig: Comment formatting nitsUlf Magnusson
2018-10-10menuconfig: Improve/fix promptless choice handlingUlf Magnusson
The code assumed that all parent (interface) menus always have a prompt, which is false for items in promptless choices. This lead to a crash e.g. when viewing the symbol information for a symbol within a promptless choice. Promptless choices with children can show up "legitimately" when people define choices in multiple locations to add symbols, though this is broken in the C tools. Use standard_sc_expr_str(node.item) instead of the non-existing prompt for promptless choices. That way they show up as <choice (name if any>)>, which is consistent with how they're shown elsewhere. This commit also changes how choices names are displayed in show-name/show-all mode, to the standard_sc_expr_str() format.
2018-10-05menuconfig: Fix Page Up typo in docstringUlf Magnusson
2018-10-05menuconfig: Remove "Value for " prefix from input dialog titlesUlf Magnusson
The prompt and type alone make it obvious, and it prevents many dialogs from getting overly wide.
2018-10-02menuconfig: Mark quit_dialog() as internalUlf Magnusson
Oversight. The _ hides it from e.g. pydoc.
2018-09-19menuconfig: Fix some nits reported by flake8Ulf Magnusson
- Remove some unused imports - Replace a lambda with a plain function - Shorten some long lines - Remove some redundant backslashes within brackets
2018-09-14menuconfig: Fix typo re. menuconfig()Ulf Magnusson
No idea where "menu." came from.
2018-09-14menuconfig: Reorganize code a bitUlf Magnusson
- Point out where the styling part starts and ends - Move _style_attr() into the styling part (by moving the comment) - Move _name_and_val_str() and _expr_str() to later in the file, closer to where they're used (mostly in the help dialog) - Turn _input_dialog() input handling into one if-elif-... chain, like for the other dialogs.
2018-09-14menuconfig: Fix a small symbol information display issueUlf Magnusson
Prevent the 'Symbol/choice/menu/comment information' title string from disappearing when it won't fit on the terminal. Piggyback some code nits: - Remove a redundant 'global _style' - Use 'elif' after checking for KEY_RESIZE - Consistently use '_sel_node_i = _menu_scroll = 0' to reset positions, e.g. when entering menus
2018-09-14menuconfig: RGB color implementation nitsUlf Magnusson
- Make the coding style a bit more consistent with the rest of the code - Allow colors to be allocated from the xterm 256-color grayscale range, and emulate it when dynamically allocating colors. Never allocate above color number 255 though, as anything there would be unknown territory. - Switch back to consistently passing tuples to functions. This was the original design, before I suggested changing it... - Remove some repeated information from docstrings and fix some small typos - Make use of the element1=element2 feature in the style definition for the 'default' style
2018-09-14menuconfig: Add RGB color support to styles.Mitja HORVAT
Styles can now take a HTML notation as a color value: - on terminals that support RGB color mode these are rendered perfeclty - on 256 color terminals the closes matching color is used - on other terminals, the current color palette is scanned and the closes matching color is used. This has few quirks Example: Use "pure" red as selection foreground and "pure" blue as background: MENUCONFIG_STYLE="selection=fg:#ff0000,bg:#0000ff" Additionally, it is possible to copy the style from other elements, for example: MENUCONFIG_STYLE="selection=fg:#ff0000,bg:#0000ff path=selection" In the notation above, the "path" style will be copied from "selection".
2018-09-09menuconfig: Menu drawing code nitUlf Magnusson
2018-09-09menuconfig: Fix some glitching on small terminalsUlf Magnusson
- 'mainmenu' and dialog titles now get clipped instead of disappearing when they don't fit - Lines of text no longer wrap to the next line (this glitch was mostly hidden if something was printed on the next line) - Text in a dialog can no longer end up on top of the dialog's frame
2018-09-08menuconfig: Pass a style string to _styled_win()Ulf Magnusson
Enforces that all windows are created from styles defined via the new styling mechanism.
2018-09-08menuconfig: Print warnings instead of having StyleErrorUlf Magnusson
Mostly motivated by curses.COLORS, which depends on the terminal. It's probably friendlier to run even if the style gets a bit messed up, but it's also nice to point out problems. Missing style templates and missing styles to the left of '=' are pointed out now too, with the help of some flag hackery. Prefix the warnings with 'menuconfig warning:' to make it easier to distinguish them from warnings from Kconfiglib.
2018-09-08menuconfig: Ignore non-existent style templatesUlf Magnusson
This is consistent with non-existent styles being ignored, and gives some forwards/backwards compatibility. I wonder if there should be a warning for both instead. Piggyback some nits.
2018-09-07menuconfig: Fix off-by-one in range check for COLORSUlf Magnusson
"color values are expected to be in the range 0 to COLORS-1", from init_color(3ncurses).
2018-09-07menuconfig: Allow numbers to be used directly for colorsUlf Magnusson
Make the syntax 'fg:123' instead of 'fg:color123'. This is a bit easier to type. Hex and octal constants are accepted as well.
2018-09-07menuconfig: Add support for custom color schemes (aka styles)Mitja HORVAT
- introduce the _parse_styles() function which can take a string defintion and parse it into a color structure that can be used by UI elements - the _parse_styles() function modifies a global dictionary (_style) which is subsequentially used to style the UI elements - the _style_to_curses() function takes a string representation of style colors and converts it to ncurses attributes. For eaxmple: fg:brightred,bg:black,bold -> returns a color pair representing brightred and black ORed with A_BOLD - simplify _init_styles() as now the majority of the heavy lifting is done by _parse_styles(). _init_styles() initializes the default theme (either "defualt" or "monochrome") - terminals without color capabilities are now handled by using the "monochrome" theme. This theme doesn't use any colors but rather just bold and standout attribtes. - add support for the "underline" attribute - add doctstring at the beginning describing the style syntax - rename the _style() function to _style_attr() as it was conflicting with the global _style dictionary - introduce the StyleError exception; this one is thrown if an error in the style syntax is encountered
2018-08-29menuconfig: Fix outdated comment re. show-all modeUlf Magnusson
Invisible symbols are no longer shown in red outside of show-all mode.
2018-08-29menuconfig: Do not use red for invisible symbols outside of show-all modeUlf Magnusson
Invisible symbols can show up outside show-all mode if an invisible symbol has visible symbols in an implicit (indented) submenu. Printing them in red like in show-all mode is the perfectly consistent thing to do, but might look confusing/broken. Only print invisible symbols in red in show-all mode. Also change the bracket style for all invisible bool/tristate symbols to - - N_SYM -M- M_SYM -*- Y_SYM That makes it clear that they can't be changed, even when they show up outside show-all mode, and makes logical sense if that style is taken to always mean that the symbol value can't be changed. You lose a quick reference for whether a symbol is a bool or tristate, but it's not a huge deal.
2018-08-29menuconfig: Fix a case of needlessly turning on show-allUlf Magnusson
Show-all mode does not need to be enabled when jumping to an invisible symbol with visible children from an implicit submenu, because the invisible symbol will be shown anyway in that case. Explicitly check whether the jumped-to node would be shown instead, and enable show-all mode otherwise.
2018-08-29menuconfig: Always show implicit submenus with visible nodesUlf Magnusson
Currently, the symbol BAR below (which ends up indented in an implicit submenu) is shown only if DEP is non-n (or if show-all mode is enabled): config FOO bool "foo" if DEP default y config BAR bool "bar" if FOO This is bad, because it hides visible symbols from the interface. The assumption was that an implicit submenu (which is only created if the parent has a prompt) would never have visible items when the root item is invisible, but prompt-specific conditions and select/imply can break that assumption. Fix it by always showing implicit submenus with visible nodes, along with the parent node. If the parent node is invisible, show it in red, like in show-all mode (which happens automatically). That's probably better than having mysteriously indented nodes when the parent is invisible.
2018-08-29menuconfig: Quote style consistency nitUlf Magnusson
2018-08-29menuconfig: Simplify default value info codeUlf Magnusson
Just checking whether the default value expression is a single symbol correctly handles the string/int/hex cases too, because that case will always hit for those. D'oh.
2018-08-29menuconfig: Add a _center_vertically() helperUlf Magnusson
Used in two spots.