kconfig/devicetree: Print path to headers when configuring
Change the output during CMake configure from
Devicetree configuration written to .../devicetree.conf
Parsing /home/ulf/z/z/Kconfig
Loaded configuration '.../frdm_kw41z_defconfig'
Merged configuration '.../prj.conf'
Configuration saved to '.../.config'
to
Devicetree header saved to '.../devicetree_unfixed.h'
Parsing /home/ulf/z/z/Kconfig
Loaded configuration '.../frdm_kw41z_defconfig'
Merged configuration '.../prj.conf'
Configuration saved to '.../.config'
Kconfig header saved to '.../autoconf.h'
devicetree_unfixed.h is more useful to be aware of than devicetree.conf
(still hoping we can get rid of it at some point), and seeing the
Kconfig header clarifies things to.
"Saved" instead of "written" for consistency. Maybe it could say
"Kconfig configuration" instead of "configuration" too, though it gets a
bit spammy in other contexts where the message shows up.
Updates Kconfiglib (and menuconfig/guiconfig, just to sync) to upstream
revision 061e71f7d7, to get this commit in, which is used to print the
header path:
Return a message from Kconfig.write_autoconf()
Like for Kconfig.write_config() and Kconfig.write_min_config(),
return a string from Kconfig.write_autoconf() with a message saying
that the header got saved, or that there were no changes to it. Can
be handy in tools.
Also make the "no change" message for the various files more
specific, by mentioning what type of file it is (configuration,
header, etc.)
Return True/False from Kconfig._write_if_changed() to indicate if
the file was updated. This also allows it to be reused in
Kconfig.write_min_config().
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-01-31 06:38:10 +01:00
|
|
|
#!/usr/bin/env python3
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
2019-02-20 17:38:22 +01:00
|
|
|
# Copyright (c) 2018-2019, Nordic Semiconductor ASA and Ulf Magnusson
|
2018-06-15 19:30:34 +02:00
|
|
|
# SPDX-License-Identifier: ISC
|
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
"""
|
|
|
|
Overview
|
|
|
|
========
|
|
|
|
|
2019-06-24 08:01:09 +02:00
|
|
|
A curses-based Python 2/3 menuconfig implementation. The interface should feel
|
|
|
|
familiar to people used to mconf ('make menuconfig').
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
Supports the same keys as mconf, and also supports a set of keybindings
|
|
|
|
inspired by Vi:
|
|
|
|
|
|
|
|
J/K : Down/Up
|
|
|
|
L : Enter menu/Toggle item
|
|
|
|
H : Leave menu
|
2018-10-10 15:08:45 +02:00
|
|
|
Ctrl-D/U: Page Down/Page Up
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
G/End : Jump to end of list
|
|
|
|
g/Home : Jump to beginning of list
|
|
|
|
|
2019-05-06 17:12:27 +02:00
|
|
|
[Space] toggles values if possible, and enters menus otherwise. [Enter] works
|
|
|
|
the other way around.
|
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
The mconf feature where pressing a key jumps to a menu entry with that
|
2018-05-07 13:02:22 +02:00
|
|
|
character in it in the current menu isn't supported. A jump-to feature for
|
menuconfig: Add jump-to for choices, menus, and comments
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
bf1701b36634b, to add this commit:
menuconfig: Add jump-to for choices, menus, and comments
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.
Previously, only symbols could be jumped to.
Various other small fixes/improvements are included too:
- The "no range constraints" text was dropped from the input dialog
when settings int/hex symbols without an active 'range'. It might be
more confusing than helpful.
- A crash when pressing Ctrl-F (the view-help shortcut) with no matches
in the jump-to dialog was fixed
- Some gnome-terminal shoddiness was worked around to remove minor
jumpiness when reducing the height of the terminal
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-10-15 02:05:45 +02:00
|
|
|
jumping directly to any symbol (including invisible symbols), choice, menu or
|
|
|
|
comment (as in a Kconfig 'comment "Foo"') is available instead.
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
2018-12-17 14:03:58 +01:00
|
|
|
A few different modes are available:
|
|
|
|
|
|
|
|
F: Toggle show-help mode, which shows the help text of the currently selected
|
|
|
|
item in the window at the bottom of the menu display. This is handy when
|
|
|
|
browsing through options.
|
|
|
|
|
|
|
|
C: Toggle show-name mode, which shows the symbol name before each symbol menu
|
|
|
|
entry
|
|
|
|
|
|
|
|
A: Toggle show-all mode, which shows all items, including currently invisible
|
|
|
|
items and items that lack a prompt. Invisible items are drawn in a different
|
|
|
|
style to make them stand out.
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
|
|
|
|
Running
|
|
|
|
=======
|
|
|
|
|
|
|
|
menuconfig.py can be run either as a standalone executable or by calling the
|
2018-09-15 08:45:50 +02:00
|
|
|
menuconfig() function with an existing Kconfig instance. The second option is a
|
|
|
|
bit inflexible in that it will still load and save .config, etc.
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
When run in standalone mode, the top-level Kconfig file to load can be passed
|
|
|
|
as a command-line argument. With no argument, it defaults to "Kconfig".
|
|
|
|
|
|
|
|
The KCONFIG_CONFIG environment variable specifies the .config file to load (if
|
|
|
|
it exists) and save. If KCONFIG_CONFIG is unset, ".config" is used.
|
|
|
|
|
2019-05-06 17:12:27 +02:00
|
|
|
When overwriting a configuration file, the old version is saved to
|
|
|
|
<filename>.old (e.g. .config.old).
|
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
$srctree is supported through Kconfiglib.
|
|
|
|
|
|
|
|
|
menuconfig: Fix a case of visible symbols not being shown
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
78682a8e3c4fe to get the following fix in, which could cause certain
visible symbols to not show up in the menuconfig interface:
menuconfig: Always show implicit submenus with visible nodes
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
parent 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.
(Some other tweaks were made later to avoid showing red outside show-all
mode, because it might look confusing/broken.)
A new color scheme for the menuconfig has been added as well,
contributed by Mitja Horvat (pinkfluid). It can be enabled by setting
the environment variable MENUCONFIG_THEME to 'aquatic'.
The default theme has been tweaked to use bold text for the selected
item too.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-29 10:16:51 +02:00
|
|
|
Color schemes
|
|
|
|
=============
|
|
|
|
|
2018-09-15 08:45:50 +02:00
|
|
|
It is possible to customize the color scheme by setting the MENUCONFIG_STYLE
|
|
|
|
environment variable. For example, setting it to 'aquatic' will enable an
|
menuconfig: Fix a case of visible symbols not being shown
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
78682a8e3c4fe to get the following fix in, which could cause certain
visible symbols to not show up in the menuconfig interface:
menuconfig: Always show implicit submenus with visible nodes
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
parent 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.
(Some other tweaks were made later to avoid showing red outside show-all
mode, because it might look confusing/broken.)
A new color scheme for the menuconfig has been added as well,
contributed by Mitja Horvat (pinkfluid). It can be enabled by setting
the environment variable MENUCONFIG_THEME to 'aquatic'.
The default theme has been tweaked to use bold text for the selected
item too.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-29 10:16:51 +02:00
|
|
|
alternative, less yellow, more 'make menuconfig'-like color scheme, contributed
|
|
|
|
by Mitja Horvat (pinkfluid).
|
|
|
|
|
2018-09-15 08:45:50 +02:00
|
|
|
This is the current list of built-in styles:
|
|
|
|
- default classic Kconfiglib theme with a yellow accent
|
|
|
|
- monochrome colorless theme (uses only bold and standout) attributes,
|
|
|
|
this style is used if the terminal doesn't support colors
|
2019-10-29 19:32:17 +01:00
|
|
|
- aquatic blue-tinted style loosely resembling the lxdialog theme
|
2018-09-15 08:45:50 +02:00
|
|
|
|
|
|
|
It is possible to customize the current style by changing colors of UI
|
|
|
|
elements on the screen. This is the list of elements that can be stylized:
|
|
|
|
|
|
|
|
- path Top row in the main display, with the menu path
|
|
|
|
- separator Separator lines between windows. Also used for the top line
|
|
|
|
in the symbol information display.
|
|
|
|
- list List of items, e.g. the main display
|
|
|
|
- selection Style for the selected item
|
|
|
|
- inv-list Like list, but for invisible items. Used in show-all mode.
|
|
|
|
- inv-selection Like selection, but for invisible items. Used in show-all
|
|
|
|
mode.
|
|
|
|
- help Help text windows at the bottom of various fullscreen
|
|
|
|
dialogs
|
2018-12-17 14:03:58 +01:00
|
|
|
- show-help Window showing the help text in show-help mode
|
2018-09-15 08:45:50 +02:00
|
|
|
- frame Frame around dialog boxes
|
|
|
|
- body Body of dialog boxes
|
|
|
|
- edit Edit box in pop-up dialogs
|
|
|
|
- jump-edit Edit box in jump-to dialog
|
|
|
|
- text Symbol information text
|
|
|
|
|
|
|
|
The color definition is a comma separated list of attributes:
|
|
|
|
|
|
|
|
- fg:COLOR Set the foreground/background colors. COLOR can be one of
|
|
|
|
* or * the basic 16 colors (black, red, green, yellow, blue,
|
2019-05-06 17:12:27 +02:00
|
|
|
- bg:COLOR magenta, cyan, white and brighter versions, for example,
|
2018-09-15 08:45:50 +02:00
|
|
|
brightred). On terminals that support more than 8 colors,
|
|
|
|
you can also directly put in a color number, e.g. fg:123
|
|
|
|
(hexadecimal and octal constants are accepted as well).
|
|
|
|
Colors outside the range -1..curses.COLORS-1 (which is
|
|
|
|
terminal-dependent) are ignored (with a warning). The COLOR
|
|
|
|
can be also specified using a RGB value in the HTML
|
|
|
|
notation, for example #RRGGBB. If the terminal supports
|
2018-09-27 17:28:00 +02:00
|
|
|
color changing, the color is rendered accurately.
|
|
|
|
Otherwise, the visually nearest color is used.
|
2018-09-15 08:45:50 +02:00
|
|
|
|
|
|
|
If the background or foreground color of an element is not
|
|
|
|
specified, it defaults to -1, representing the default
|
|
|
|
terminal foreground or background color.
|
|
|
|
|
2018-09-27 17:28:00 +02:00
|
|
|
Note: On some terminals a bright version of the color
|
|
|
|
implies bold.
|
2018-09-15 08:45:50 +02:00
|
|
|
- bold Use bold text
|
|
|
|
- underline Use underline text
|
|
|
|
- standout Standout text attribute (reverse color)
|
|
|
|
|
|
|
|
More often than not, some UI elements share the same color definition. In such
|
|
|
|
cases the right value may specify an UI element from which the color definition
|
|
|
|
will be copied. For example, "separator=help" will apply the current color
|
|
|
|
definition for "help" to "separator".
|
|
|
|
|
|
|
|
A keyword without the '=' is assumed to be a style template. The template name
|
|
|
|
is looked up in the built-in styles list and the style definition is expanded
|
|
|
|
in-place. With this, built-in styles can be used as basis for new styles.
|
|
|
|
|
|
|
|
For example, take the aquatic theme and give it a red selection bar:
|
|
|
|
|
|
|
|
MENUCONFIG_STYLE="aquatic selection=fg:white,bg:red"
|
|
|
|
|
|
|
|
If there's an error in the style definition or if a missing style is assigned
|
|
|
|
to, the assignment will be ignored, along with a warning being printed on
|
|
|
|
stderr.
|
|
|
|
|
2019-12-17 08:39:07 +01:00
|
|
|
The 'default' theme is always implicitly parsed first, so the following two
|
|
|
|
settings have the same effect:
|
2018-09-15 08:45:50 +02:00
|
|
|
|
|
|
|
MENUCONFIG_STYLE="selection=fg:white,bg:red"
|
|
|
|
MENUCONFIG_STYLE="default selection=fg:white,bg:red"
|
menuconfig: Fix a case of visible symbols not being shown
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
78682a8e3c4fe to get the following fix in, which could cause certain
visible symbols to not show up in the menuconfig interface:
menuconfig: Always show implicit submenus with visible nodes
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
parent 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.
(Some other tweaks were made later to avoid showing red outside show-all
mode, because it might look confusing/broken.)
A new color scheme for the menuconfig has been added as well,
contributed by Mitja Horvat (pinkfluid). It can be enabled by setting
the environment variable MENUCONFIG_THEME to 'aquatic'.
The default theme has been tweaked to use bold text for the selected
item too.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-29 10:16:51 +02:00
|
|
|
|
2019-12-17 08:39:07 +01:00
|
|
|
If the terminal doesn't support colors, the 'monochrome' theme is used, and
|
|
|
|
MENUCONFIG_STYLE is ignored. The assumption is that the environment is broken
|
|
|
|
somehow, and that the important thing is to get something usable.
|
|
|
|
|
menuconfig: Fix a case of visible symbols not being shown
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
78682a8e3c4fe to get the following fix in, which could cause certain
visible symbols to not show up in the menuconfig interface:
menuconfig: Always show implicit submenus with visible nodes
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
parent 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.
(Some other tweaks were made later to avoid showing red outside show-all
mode, because it might look confusing/broken.)
A new color scheme for the menuconfig has been added as well,
contributed by Mitja Horvat (pinkfluid). It can be enabled by setting
the environment variable MENUCONFIG_THEME to 'aquatic'.
The default theme has been tweaked to use bold text for the selected
item too.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-29 10:16:51 +02:00
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
Other features
|
|
|
|
==============
|
|
|
|
|
|
|
|
- Seamless terminal resizing
|
|
|
|
|
|
|
|
- No dependencies on *nix, as the 'curses' module is in the Python standard
|
|
|
|
library
|
|
|
|
|
|
|
|
- Unicode text entry
|
|
|
|
|
|
|
|
- Improved information screen compared to mconf:
|
|
|
|
|
|
|
|
* Expressions are split up by their top-level &&/|| operands to improve
|
|
|
|
readability
|
|
|
|
|
|
|
|
* Undefined symbols in expressions are pointed out
|
|
|
|
|
|
|
|
* Menus and comments have information displays
|
|
|
|
|
|
|
|
* Kconfig definitions are printed
|
|
|
|
|
menuconfig: Fix a case of visible symbols not being shown
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
78682a8e3c4fe to get the following fix in, which could cause certain
visible symbols to not show up in the menuconfig interface:
menuconfig: Always show implicit submenus with visible nodes
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
parent 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.
(Some other tweaks were made later to avoid showing red outside show-all
mode, because it might look confusing/broken.)
A new color scheme for the menuconfig has been added as well,
contributed by Mitja Horvat (pinkfluid). It can be enabled by setting
the environment variable MENUCONFIG_THEME to 'aquatic'.
The default theme has been tweaked to use bold text for the selected
item too.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-29 10:16:51 +02:00
|
|
|
* The include path is shown, listing the locations of the 'source'
|
|
|
|
statements that included the Kconfig file of the symbol (or other
|
|
|
|
item)
|
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
Limitations
|
|
|
|
===========
|
|
|
|
|
2019-10-29 19:32:17 +01:00
|
|
|
Doesn't work out of the box on Windows, but can be made to work with
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
2019-10-29 19:32:17 +01:00
|
|
|
pip install windows-curses
|
|
|
|
|
|
|
|
See the https://github.com/zephyrproject-rtos/windows-curses repository.
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
"""
|
2019-06-24 08:01:09 +02:00
|
|
|
from __future__ import print_function
|
|
|
|
|
2019-12-17 08:39:07 +01:00
|
|
|
import os
|
2019-10-29 19:32:17 +01:00
|
|
|
import sys
|
|
|
|
|
2019-12-17 08:39:07 +01:00
|
|
|
_IS_WINDOWS = os.name == "nt" # Are we running on Windows?
|
|
|
|
|
2019-10-29 19:32:17 +01:00
|
|
|
try:
|
|
|
|
import curses
|
|
|
|
except ImportError as e:
|
2019-12-17 08:39:07 +01:00
|
|
|
if not _IS_WINDOWS:
|
2019-10-29 19:32:17 +01:00
|
|
|
raise
|
|
|
|
sys.exit("""\
|
|
|
|
menuconfig failed to import the standard Python 'curses' library. Try
|
|
|
|
installing a package like windows-curses
|
|
|
|
(https://github.com/zephyrproject-rtos/windows-curses) by running this command
|
|
|
|
in cmd.exe:
|
|
|
|
|
|
|
|
pip install windows-curses
|
|
|
|
|
|
|
|
Starting with Kconfiglib 13.0.0, windows-curses is no longer automatically
|
|
|
|
installed when installing Kconfiglib via pip on Windows (because it breaks
|
|
|
|
installation on MSYS2).
|
|
|
|
|
|
|
|
Exception:
|
|
|
|
{}: {}""".format(type(e).__name__, e))
|
|
|
|
|
2018-05-07 13:02:22 +02:00
|
|
|
import errno
|
|
|
|
import locale
|
|
|
|
import re
|
|
|
|
import textwrap
|
|
|
|
|
kconfiglib/menuconfig: Add functionality and improve symbol information
Update Kconfiglib and menuconfig to upstream revision 6aea8d06b637e.
Kconfiglib changes:
- Kconfig files are now looked up just relative to $srctree (if set).
Previously, each source'd Kconfig file was also looked up in the
current directory, and Kconfig files there could override Kconfig
files in $srctree. This is what the C tools do.
I'm pretty sure that behavior was a bug in the C tools all along, and
only meant for .config files. It caused problems (and an ugly
workaround) for the undefined Kconfig symbol CI check in an external
project.
The new behavior also saves a bunch of open()'s, though it's probably
not noticeable.
- Setting the KCONFIG_STRICT environment variable to 'y' now makes
Kconfiglib itself warn for references to undefined symbols. This
isn't safe in general, as some projects use multiple Kconfig trees
with shared Kconfig files (e.g. the Linux kernel).
This will be used to simplify the undefined Kconfig symbol CI check.
- It's now possible to customize how symbols and choices are printed
within expressions.
This will be used to make the RST link generation in genrest.py less
hacky.
- Instead of having 'gsource', a plain 'source' is now globbing, and
requires at least one match. There's also 'osource', for when it's
okay for a glob pattern to match no files.
'gsource' had the design flaw that there was no way to require at
least one file to match. I plan on replacing all 'gsource' statements
with plain 'source's later, but 'gsource' is still supported for
backwards compatibility.
- def_int, def_hex, and def_string are now available as a Kconfig
extensions, analogous to def_bool (set type and add default).
- Misc. internal cleanup.
menuconfig changes:
- Boolean value hints are no longer shown to the right of defaults in
the symbol information for int/hex symbols. Stuff like
'- 74 (value: "n")' wasn't helpful, and looked confusing.
- Symbol information has been made more compact in general, e.g. by
skipping value hints where they aren't helpful
('FOO(=y)' instead of 'FOO(=y) (=y)'), and by shortening stuff like
'(value: "y")' to just '(=y)'.
- Misc. internal cleanup.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-10 06:04:23 +02:00
|
|
|
from kconfiglib import Symbol, Choice, MENU, COMMENT, MenuNode, \
|
2019-05-06 17:12:27 +02:00
|
|
|
BOOL, TRISTATE, STRING, INT, HEX, \
|
2018-09-27 17:28:00 +02:00
|
|
|
AND, OR, \
|
kconfiglib/menuconfig: Add functionality and improve symbol information
Update Kconfiglib and menuconfig to upstream revision 6aea8d06b637e.
Kconfiglib changes:
- Kconfig files are now looked up just relative to $srctree (if set).
Previously, each source'd Kconfig file was also looked up in the
current directory, and Kconfig files there could override Kconfig
files in $srctree. This is what the C tools do.
I'm pretty sure that behavior was a bug in the C tools all along, and
only meant for .config files. It caused problems (and an ugly
workaround) for the undefined Kconfig symbol CI check in an external
project.
The new behavior also saves a bunch of open()'s, though it's probably
not noticeable.
- Setting the KCONFIG_STRICT environment variable to 'y' now makes
Kconfiglib itself warn for references to undefined symbols. This
isn't safe in general, as some projects use multiple Kconfig trees
with shared Kconfig files (e.g. the Linux kernel).
This will be used to simplify the undefined Kconfig symbol CI check.
- It's now possible to customize how symbols and choices are printed
within expressions.
This will be used to make the RST link generation in genrest.py less
hacky.
- Instead of having 'gsource', a plain 'source' is now globbing, and
requires at least one match. There's also 'osource', for when it's
okay for a glob pattern to match no files.
'gsource' had the design flaw that there was no way to require at
least one file to match. I plan on replacing all 'gsource' statements
with plain 'source's later, but 'gsource' is still supported for
backwards compatibility.
- def_int, def_hex, and def_string are now available as a Kconfig
extensions, analogous to def_bool (set type and add default).
- Misc. internal cleanup.
menuconfig changes:
- Boolean value hints are no longer shown to the right of defaults in
the symbol information for int/hex symbols. Stuff like
'- 74 (value: "n")' wasn't helpful, and looked confusing.
- Symbol information has been made more compact in general, e.g. by
skipping value hints where they aren't helpful
('FOO(=y)' instead of 'FOO(=y) (=y)'), and by shortening stuff like
'(value: "y")' to just '(=y)'.
- Misc. internal cleanup.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-10 06:04:23 +02:00
|
|
|
expr_str, expr_value, split_expr, \
|
|
|
|
standard_sc_expr_str, \
|
2018-06-15 19:30:34 +02:00
|
|
|
TRI_TO_STR, TYPE_TO_STR, \
|
|
|
|
standard_kconfig, standard_config_filename
|
2018-05-07 13:02:22 +02:00
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# Configuration variables
|
|
|
|
#
|
|
|
|
|
2019-06-24 08:01:09 +02:00
|
|
|
# If True, try to change LC_CTYPE to a UTF-8 locale if it is set to the C
|
2018-05-08 17:51:11 +02:00
|
|
|
# locale (which implies ASCII). This fixes curses Unicode I/O issues on systems
|
|
|
|
# with bad defaults. ncurses configures itself from the locale settings.
|
|
|
|
#
|
|
|
|
# Related PEP: https://www.python.org/dev/peps/pep-0538/
|
2019-06-24 08:01:09 +02:00
|
|
|
_CHANGE_C_LC_CTYPE_TO_UTF8 = True
|
2018-05-08 17:51:11 +02:00
|
|
|
|
|
|
|
# How many steps an implicit submenu will be indented. Implicit submenus are
|
|
|
|
# created when an item depends on the symbol before it. Note that symbols
|
|
|
|
# defined with 'menuconfig' create a separate menu instead of indenting.
|
|
|
|
_SUBMENU_INDENT = 4
|
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
# Number of steps for Page Up/Down to jump
|
|
|
|
_PG_JUMP = 6
|
|
|
|
|
2018-12-17 14:03:58 +01:00
|
|
|
# Height of the help window in show-help mode
|
|
|
|
_SHOW_HELP_HEIGHT = 8
|
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
# How far the cursor needs to be from the edge of the window before it starts
|
2018-05-21 15:48:23 +02:00
|
|
|
# to scroll. Used for the main menu display, the information display, the
|
|
|
|
# search display, and for text boxes.
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
_SCROLL_OFFSET = 5
|
|
|
|
|
|
|
|
# Minimum width of dialogs that ask for text input
|
|
|
|
_INPUT_DIALOG_MIN_WIDTH = 30
|
|
|
|
|
|
|
|
# Number of arrows pointing up/down to draw when a window is scrolled
|
|
|
|
_N_SCROLL_ARROWS = 14
|
|
|
|
|
|
|
|
# Lines of help text shown at the bottom of the "main" display
|
|
|
|
_MAIN_HELP_LINES = """
|
2018-12-17 14:03:58 +01:00
|
|
|
[Space/Enter] Toggle/enter [ESC] Leave menu [S] Save
|
|
|
|
[O] Load [?] Symbol info [/] Jump to symbol
|
|
|
|
[F] Toggle show-help mode [C] Toggle show-name mode [A] Toggle show-all mode
|
|
|
|
[Q] Quit (prompts for save) [D] Save minimal config (advanced)
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
"""[1:-1].split("\n")
|
|
|
|
|
2018-05-07 13:02:22 +02:00
|
|
|
# Lines of help text shown at the bottom of the information dialog
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
_INFO_HELP_LINES = """
|
2019-05-06 17:12:27 +02:00
|
|
|
[ESC/q] Return to menu [/] Jump to symbol
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
"""[1:-1].split("\n")
|
|
|
|
|
2018-05-07 13:02:22 +02:00
|
|
|
# Lines of help text shown at the bottom of the search dialog
|
|
|
|
_JUMP_TO_HELP_LINES = """
|
2018-05-11 00:22:32 +02:00
|
|
|
Type text to narrow the search. Regexes are supported (via Python's 're'
|
|
|
|
module). The up/down cursor keys step in the list. [Enter] jumps to the
|
|
|
|
selected symbol. [ESC] aborts the search. Type multiple space-separated
|
2018-06-15 19:30:34 +02:00
|
|
|
strings/regexes to find entries that match all of them. Type Ctrl-F to
|
|
|
|
view the help of the selected item without leaving the dialog.
|
2018-05-07 13:02:22 +02:00
|
|
|
"""[1:-1].split("\n")
|
|
|
|
|
2018-09-15 08:45:50 +02:00
|
|
|
#
|
|
|
|
# Styling
|
|
|
|
#
|
|
|
|
|
|
|
|
_STYLES = {
|
|
|
|
"default": """
|
|
|
|
path=fg:black,bg:white,bold
|
|
|
|
separator=fg:black,bg:yellow,bold
|
|
|
|
list=fg:black,bg:white
|
|
|
|
selection=fg:white,bg:blue,bold
|
|
|
|
inv-list=fg:red,bg:white
|
|
|
|
inv-selection=fg:red,bg:blue
|
|
|
|
help=path
|
2018-12-17 14:03:58 +01:00
|
|
|
show-help=list
|
2018-09-15 08:45:50 +02:00
|
|
|
frame=fg:black,bg:yellow,bold
|
|
|
|
body=fg:white,bg:black
|
|
|
|
edit=fg:white,bg:blue
|
|
|
|
jump-edit=edit
|
|
|
|
text=list
|
|
|
|
""",
|
|
|
|
|
|
|
|
# This style is forced on terminals that do no support colors
|
|
|
|
"monochrome": """
|
|
|
|
path=bold
|
|
|
|
separator=bold,standout
|
|
|
|
list=
|
|
|
|
selection=bold,standout
|
|
|
|
inv-list=bold
|
|
|
|
inv-selection=bold,standout
|
|
|
|
help=bold
|
2018-12-17 14:03:58 +01:00
|
|
|
show-help=
|
2018-09-15 08:45:50 +02:00
|
|
|
frame=bold,standout
|
|
|
|
body=
|
|
|
|
edit=standout
|
|
|
|
jump-edit=
|
|
|
|
text=
|
|
|
|
""",
|
|
|
|
|
2019-12-17 08:39:07 +01:00
|
|
|
# Blue-tinted style loosely resembling lxdialog
|
2018-09-15 08:45:50 +02:00
|
|
|
"aquatic": """
|
2020-01-13 10:38:45 +01:00
|
|
|
path=fg:white,bg:blue
|
|
|
|
separator=fg:white,bg:cyan
|
2018-09-15 08:45:50 +02:00
|
|
|
help=path
|
2020-01-13 10:38:45 +01:00
|
|
|
frame=fg:white,bg:cyan
|
2019-12-17 08:39:07 +01:00
|
|
|
body=fg:white,bg:blue
|
2018-09-15 08:45:50 +02:00
|
|
|
edit=fg:black,bg:white
|
|
|
|
"""
|
|
|
|
}
|
|
|
|
|
2019-12-17 08:39:07 +01:00
|
|
|
_NAMED_COLORS = {
|
2018-09-15 08:45:50 +02:00
|
|
|
# Basic colors
|
|
|
|
"black": curses.COLOR_BLACK,
|
|
|
|
"red": curses.COLOR_RED,
|
|
|
|
"green": curses.COLOR_GREEN,
|
|
|
|
"yellow": curses.COLOR_YELLOW,
|
|
|
|
"blue": curses.COLOR_BLUE,
|
|
|
|
"magenta": curses.COLOR_MAGENTA,
|
|
|
|
"cyan": curses.COLOR_CYAN,
|
|
|
|
"white": curses.COLOR_WHITE,
|
|
|
|
|
|
|
|
# Bright versions
|
|
|
|
"brightblack": curses.COLOR_BLACK + 8,
|
|
|
|
"brightred": curses.COLOR_RED + 8,
|
|
|
|
"brightgreen": curses.COLOR_GREEN + 8,
|
|
|
|
"brightyellow": curses.COLOR_YELLOW + 8,
|
|
|
|
"brightblue": curses.COLOR_BLUE + 8,
|
|
|
|
"brightmagenta": curses.COLOR_MAGENTA + 8,
|
|
|
|
"brightcyan": curses.COLOR_CYAN + 8,
|
|
|
|
"brightwhite": curses.COLOR_WHITE + 8,
|
|
|
|
|
|
|
|
# Aliases
|
|
|
|
"purple": curses.COLOR_MAGENTA,
|
|
|
|
"brightpurple": curses.COLOR_MAGENTA + 8,
|
|
|
|
}
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
2018-09-15 08:45:50 +02:00
|
|
|
def _rgb_to_6cube(rgb):
|
|
|
|
# Converts an 888 RGB color to a 3-tuple (nice in that it's hashable)
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
# representing the closest xterm 256-color 6x6x6 color cube color.
|
2018-09-15 08:45:50 +02:00
|
|
|
#
|
|
|
|
# The xterm 256-color extension uses a RGB color palette with components in
|
|
|
|
# the range 0-5 (a 6x6x6 cube). The catch is that the mapping is nonlinear.
|
|
|
|
# Index 0 in the 6x6x6 cube is mapped to 0, index 1 to 95, then 135, 175,
|
|
|
|
# etc., in increments of 40. See the links below:
|
|
|
|
#
|
|
|
|
# https://commons.wikimedia.org/wiki/File:Xterm_256color_chart.svg
|
|
|
|
# https://github.com/tmux/tmux/blob/master/colour.c
|
|
|
|
|
|
|
|
# 48 is the middle ground between 0 and 95.
|
|
|
|
return tuple(0 if x < 48 else int(round(max(1, (x - 55)/40))) for x in rgb)
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
2018-09-15 08:45:50 +02:00
|
|
|
def _6cube_to_rgb(r6g6b6):
|
|
|
|
# Returns the 888 RGB color for a 666 xterm color cube index
|
|
|
|
|
|
|
|
return tuple(0 if x == 0 else 40*x + 55 for x in r6g6b6)
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
2018-09-15 08:45:50 +02:00
|
|
|
def _rgb_to_gray(rgb):
|
|
|
|
# Converts an 888 RGB color to the index of an xterm 256-color grayscale
|
|
|
|
# color with approx. the same perceived brightness
|
|
|
|
|
|
|
|
# Calculate the luminance (gray intensity) of the color. See
|
|
|
|
# https://stackoverflow.com/questions/596216/formula-to-determine-brightness-of-rgb-color
|
|
|
|
# and
|
|
|
|
# https://www.w3.org/TR/AERT/#color-contrast
|
|
|
|
luma = 0.299*rgb[0] + 0.587*rgb[1] + 0.114*rgb[2]
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
# Closest index in the grayscale palette, which starts at RGB 0x080808,
|
2018-09-15 08:45:50 +02:00
|
|
|
# with stepping 0x0A0A0A
|
|
|
|
index = int(round((luma - 8)/10))
|
|
|
|
|
|
|
|
# Clamp the index to 0-23, corresponding to 232-255
|
|
|
|
return max(0, min(index, 23))
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
2018-09-15 08:45:50 +02:00
|
|
|
def _gray_to_rgb(index):
|
|
|
|
# Convert a grayscale index to its closet single RGB component
|
|
|
|
|
|
|
|
return 3*(10*index + 8,) # Returns a 3-tuple
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
2018-09-15 08:45:50 +02:00
|
|
|
# Obscure Python: We never pass a value for rgb2index, and it keeps pointing to
|
|
|
|
# the same dict. This avoids a global.
|
|
|
|
def _alloc_rgb(rgb, rgb2index={}):
|
|
|
|
# Initialize a new entry in the xterm palette to the given RGB color,
|
|
|
|
# returning its index. If the color has already been initialized, the index
|
|
|
|
# of the existing entry is returned.
|
|
|
|
#
|
|
|
|
# ncurses is palette-based, so we need to overwrite palette entries to make
|
|
|
|
# new colors.
|
|
|
|
#
|
|
|
|
# The colors from 0 to 15 are user-defined, and there's no way to query
|
|
|
|
# their RGB values, so we better leave them untouched. Also leave any
|
|
|
|
# hypothetical colors above 255 untouched (though we're unlikely to
|
|
|
|
# allocate that many colors anyway).
|
|
|
|
|
|
|
|
if rgb in rgb2index:
|
|
|
|
return rgb2index[rgb]
|
|
|
|
|
|
|
|
# Many terminals allow the user to customize the first 16 colors. Avoid
|
|
|
|
# changing their values.
|
|
|
|
color_index = 16 + len(rgb2index)
|
|
|
|
if color_index >= 256:
|
|
|
|
_warn("Unable to allocate new RGB color ", rgb, ". Too many colors "
|
|
|
|
"allocated.")
|
|
|
|
return 0
|
|
|
|
|
|
|
|
# Map each RGB component from the range 0-255 to the range 0-1000, which is
|
|
|
|
# what curses uses
|
|
|
|
curses.init_color(color_index, *(int(round(1000*x/255)) for x in rgb))
|
|
|
|
rgb2index[rgb] = color_index
|
|
|
|
|
|
|
|
return color_index
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
2018-09-15 08:45:50 +02:00
|
|
|
def _color_from_num(num):
|
|
|
|
# Returns the index of a color that looks like color 'num' in the xterm
|
|
|
|
# 256-color palette (but that might not be 'num', if we're redefining
|
|
|
|
# colors)
|
|
|
|
|
|
|
|
# - _alloc_rgb() won't touch the first 16 colors or any (hypothetical)
|
|
|
|
# colors above 255, so we can always return them as-is
|
|
|
|
#
|
|
|
|
# - If the terminal doesn't support changing color definitions, or if
|
|
|
|
# curses.COLORS < 256, _alloc_rgb() won't touch any color, and all colors
|
|
|
|
# can be returned as-is
|
|
|
|
if num < 16 or num > 255 or not curses.can_change_color() or \
|
|
|
|
curses.COLORS < 256:
|
|
|
|
return num
|
|
|
|
|
|
|
|
# _alloc_rgb() might redefine colors, so emulate the xterm 256-color
|
|
|
|
# palette by allocating new colors instead of returning color numbers
|
|
|
|
# directly
|
|
|
|
|
|
|
|
if num < 232:
|
|
|
|
num -= 16
|
|
|
|
return _alloc_rgb(_6cube_to_rgb(((num//36)%6, (num//6)%6, num%6)))
|
|
|
|
|
|
|
|
return _alloc_rgb(_gray_to_rgb(num - 232))
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
2018-09-15 08:45:50 +02:00
|
|
|
def _color_from_rgb(rgb):
|
|
|
|
# Returns the index of a color matching the 888 RGB color 'rgb'. The
|
|
|
|
# returned color might be an ~exact match or an approximation, depending on
|
|
|
|
# terminal capabilities.
|
|
|
|
|
|
|
|
# Calculates the Euclidean distance between two RGB colors
|
2018-09-27 17:28:00 +02:00
|
|
|
def dist(r1, r2): return sum((x - y)**2 for x, y in zip(r1, r2))
|
2018-09-15 08:45:50 +02:00
|
|
|
|
|
|
|
if curses.COLORS >= 256:
|
|
|
|
# Assume we're dealing with xterm's 256-color extension
|
|
|
|
|
|
|
|
if curses.can_change_color():
|
|
|
|
# Best case -- the terminal supports changing palette entries via
|
|
|
|
# curses.init_color(). Initialize an unused palette entry and
|
|
|
|
# return it.
|
|
|
|
return _alloc_rgb(rgb)
|
|
|
|
|
|
|
|
# Second best case -- pick between the xterm 256-color extension colors
|
|
|
|
|
|
|
|
# Closest 6-cube "color" color
|
|
|
|
c6 = _rgb_to_6cube(rgb)
|
|
|
|
# Closest gray color
|
|
|
|
gray = _rgb_to_gray(rgb)
|
|
|
|
|
|
|
|
if dist(rgb, _6cube_to_rgb(c6)) < dist(rgb, _gray_to_rgb(gray)):
|
|
|
|
# Use the "color" color from the 6x6x6 color palette. Calculate the
|
|
|
|
# color number from the 6-cube index triplet.
|
|
|
|
return 16 + 36*c6[0] + 6*c6[1] + c6[2]
|
|
|
|
|
|
|
|
# Use the color from the gray palette
|
|
|
|
return 232 + gray
|
|
|
|
|
|
|
|
# Terminal not in xterm 256-color mode. This is probably the best we can
|
|
|
|
# do, or is it? Submit patches. :)
|
|
|
|
min_dist = float('inf')
|
|
|
|
best = -1
|
|
|
|
for color in range(curses.COLORS):
|
|
|
|
# ncurses uses the range 0..1000. Scale that down to 0..255.
|
|
|
|
d = dist(rgb, tuple(int(round(255*c/1000))
|
|
|
|
for c in curses.color_content(color)))
|
|
|
|
if d < min_dist:
|
|
|
|
min_dist = d
|
|
|
|
best = color
|
|
|
|
|
|
|
|
return best
|
|
|
|
|
|
|
|
|
|
|
|
def _parse_style(style_str, parsing_default):
|
|
|
|
# Parses a string with '<element>=<style>' assignments. Anything not
|
|
|
|
# containing '=' is assumed to be a reference to a built-in style, which is
|
|
|
|
# treated as if all the assignments from the style were inserted at that
|
|
|
|
# point in the string.
|
|
|
|
#
|
|
|
|
# The parsing_default flag is set to True when we're implicitly parsing the
|
|
|
|
# 'default'/'monochrome' style, to prevent warnings.
|
|
|
|
|
|
|
|
for sline in style_str.split():
|
|
|
|
# Words without a "=" character represents a style template
|
|
|
|
if "=" in sline:
|
|
|
|
key, data = sline.split("=", 1)
|
|
|
|
|
|
|
|
# The 'default' style template is assumed to define all keys. We
|
|
|
|
# run _style_to_curses() for non-existing keys as well, so that we
|
|
|
|
# print warnings for errors to the right of '=' for those too.
|
|
|
|
if key not in _style and not parsing_default:
|
|
|
|
_warn("Ignoring non-existent style", key)
|
|
|
|
|
|
|
|
# If data is a reference to another key, copy its style
|
|
|
|
if data in _style:
|
|
|
|
_style[key] = _style[data]
|
|
|
|
else:
|
|
|
|
_style[key] = _style_to_curses(data)
|
|
|
|
|
|
|
|
elif sline in _STYLES:
|
|
|
|
# Recursively parse style template. Ignore styles that don't exist,
|
|
|
|
# for backwards/forwards compatibility.
|
|
|
|
_parse_style(_STYLES[sline], parsing_default)
|
|
|
|
|
|
|
|
else:
|
|
|
|
_warn("Ignoring non-existent style template", sline)
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
# Dictionary mapping element types to the curses attributes used to display
|
|
|
|
# them
|
|
|
|
_style = {}
|
|
|
|
|
|
|
|
|
2018-09-15 08:45:50 +02:00
|
|
|
def _style_to_curses(style_def):
|
|
|
|
# Parses a style definition string (<element>=<style>), returning
|
|
|
|
# a (fg_color, bg_color, attributes) tuple.
|
|
|
|
|
|
|
|
def parse_color(color_def):
|
|
|
|
color_def = color_def.split(":", 1)[1]
|
|
|
|
|
|
|
|
# HTML format, #RRGGBB
|
|
|
|
if re.match("#[A-Fa-f0-9]{6}", color_def):
|
|
|
|
return _color_from_rgb((
|
|
|
|
int(color_def[1:3], 16),
|
|
|
|
int(color_def[3:5], 16),
|
|
|
|
int(color_def[5:7], 16)))
|
|
|
|
|
2019-12-17 08:39:07 +01:00
|
|
|
if color_def in _NAMED_COLORS:
|
|
|
|
color_num = _color_from_num(_NAMED_COLORS[color_def])
|
|
|
|
else:
|
|
|
|
try:
|
|
|
|
color_num = _color_from_num(int(color_def, 0))
|
|
|
|
except ValueError:
|
|
|
|
_warn("Ignoring color", color_def, "that's neither "
|
|
|
|
"predefined nor a number")
|
|
|
|
return -1
|
2018-09-15 08:45:50 +02:00
|
|
|
|
|
|
|
if not -1 <= color_num < curses.COLORS:
|
|
|
|
_warn("Ignoring color {}, which is outside the range "
|
|
|
|
"-1..curses.COLORS-1 (-1..{})"
|
|
|
|
.format(color_def, curses.COLORS - 1))
|
|
|
|
return -1
|
|
|
|
|
|
|
|
return color_num
|
|
|
|
|
|
|
|
fg_color = -1
|
|
|
|
bg_color = -1
|
|
|
|
attrs = 0
|
|
|
|
|
|
|
|
if style_def:
|
|
|
|
for field in style_def.split(","):
|
|
|
|
if field.startswith("fg:"):
|
|
|
|
fg_color = parse_color(field)
|
|
|
|
elif field.startswith("bg:"):
|
|
|
|
bg_color = parse_color(field)
|
|
|
|
elif field == "bold":
|
|
|
|
# A_BOLD tends to produce faint and hard-to-read text on the
|
|
|
|
# Windows console, especially with the old color scheme, before
|
|
|
|
# the introduction of
|
|
|
|
# https://blogs.msdn.microsoft.com/commandline/2017/08/02/updating-the-windows-console-colors/
|
|
|
|
attrs |= curses.A_NORMAL if _IS_WINDOWS else curses.A_BOLD
|
|
|
|
elif field == "standout":
|
|
|
|
attrs |= curses.A_STANDOUT
|
|
|
|
elif field == "underline":
|
|
|
|
attrs |= curses.A_UNDERLINE
|
|
|
|
else:
|
|
|
|
_warn("Ignoring unknown style attribute", field)
|
|
|
|
|
|
|
|
return _style_attr(fg_color, bg_color, attrs)
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
def _init_styles():
|
2018-09-15 08:45:50 +02:00
|
|
|
if curses.has_colors():
|
2019-12-17 08:39:07 +01:00
|
|
|
try:
|
|
|
|
curses.use_default_colors()
|
|
|
|
except curses.error:
|
|
|
|
# Ignore errors on funky terminals that support colors but not
|
|
|
|
# using default colors. Worst it can do is break transparency and
|
|
|
|
# the like. Ran across this with the MSYS2/winpty setup in
|
|
|
|
# https://github.com/msys2/MINGW-packages/issues/5823, though there
|
|
|
|
# seems to be a lot of general brokenness there.
|
|
|
|
pass
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
2019-12-17 08:39:07 +01:00
|
|
|
# Use the 'default' theme as the base, and add any user-defined style
|
|
|
|
# settings from the environment
|
|
|
|
_parse_style("default", True)
|
|
|
|
if "MENUCONFIG_STYLE" in os.environ:
|
|
|
|
_parse_style(os.environ["MENUCONFIG_STYLE"], False)
|
|
|
|
else:
|
|
|
|
# Force the 'monochrome' theme if the terminal doesn't support colors.
|
|
|
|
# MENUCONFIG_STYLE is likely to mess things up here (though any colors
|
|
|
|
# would be ignored), so ignore it.
|
|
|
|
_parse_style("monochrome", True)
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
2018-05-11 00:22:32 +02:00
|
|
|
# color_attribs holds the color pairs we've already created, indexed by a
|
|
|
|
# (<foreground color>, <background color>) tuple.
|
|
|
|
#
|
|
|
|
# Obscure Python: We never pass a value for color_attribs, and it keeps
|
|
|
|
# pointing to the same dict. This avoids a global.
|
2018-09-15 08:45:50 +02:00
|
|
|
def _style_attr(fg_color, bg_color, attribs, color_attribs={}):
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
# Returns an attribute with the specified foreground and background color
|
|
|
|
# and the attributes in 'attribs'. Reuses color pairs already created if
|
|
|
|
# possible, and creates a new color pair otherwise.
|
|
|
|
#
|
2018-09-15 08:45:50 +02:00
|
|
|
# Returns 'attribs' if colors aren't supported.
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
if not curses.has_colors():
|
2018-09-15 08:45:50 +02:00
|
|
|
return attribs
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
2018-05-11 00:22:32 +02:00
|
|
|
if (fg_color, bg_color) not in color_attribs:
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
# Create new color pair. Color pair number 0 is hardcoded and cannot be
|
|
|
|
# changed, hence the +1s.
|
2018-05-11 00:22:32 +02:00
|
|
|
curses.init_pair(len(color_attribs) + 1, fg_color, bg_color)
|
|
|
|
color_attribs[(fg_color, bg_color)] = \
|
|
|
|
curses.color_pair(len(color_attribs) + 1)
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
2018-05-11 00:22:32 +02:00
|
|
|
return color_attribs[(fg_color, bg_color)] | attribs
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
2018-09-15 08:45:50 +02:00
|
|
|
#
|
|
|
|
# Main application
|
|
|
|
#
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
2018-06-15 19:30:34 +02:00
|
|
|
def _main():
|
2019-10-29 19:32:17 +01:00
|
|
|
menuconfig(standard_kconfig(__doc__))
|
2018-06-15 19:30:34 +02:00
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
def menuconfig(kconf):
|
|
|
|
"""
|
|
|
|
Launches the configuration interface, returning after the user exits.
|
|
|
|
|
|
|
|
kconf:
|
|
|
|
Kconfig instance to be configured
|
|
|
|
"""
|
kconfiglib/menuconfig: Add functionality and improve symbol information
Update Kconfiglib and menuconfig to upstream revision 6aea8d06b637e.
Kconfiglib changes:
- Kconfig files are now looked up just relative to $srctree (if set).
Previously, each source'd Kconfig file was also looked up in the
current directory, and Kconfig files there could override Kconfig
files in $srctree. This is what the C tools do.
I'm pretty sure that behavior was a bug in the C tools all along, and
only meant for .config files. It caused problems (and an ugly
workaround) for the undefined Kconfig symbol CI check in an external
project.
The new behavior also saves a bunch of open()'s, though it's probably
not noticeable.
- Setting the KCONFIG_STRICT environment variable to 'y' now makes
Kconfiglib itself warn for references to undefined symbols. This
isn't safe in general, as some projects use multiple Kconfig trees
with shared Kconfig files (e.g. the Linux kernel).
This will be used to simplify the undefined Kconfig symbol CI check.
- It's now possible to customize how symbols and choices are printed
within expressions.
This will be used to make the RST link generation in genrest.py less
hacky.
- Instead of having 'gsource', a plain 'source' is now globbing, and
requires at least one match. There's also 'osource', for when it's
okay for a glob pattern to match no files.
'gsource' had the design flaw that there was no way to require at
least one file to match. I plan on replacing all 'gsource' statements
with plain 'source's later, but 'gsource' is still supported for
backwards compatibility.
- def_int, def_hex, and def_string are now available as a Kconfig
extensions, analogous to def_bool (set type and add default).
- Misc. internal cleanup.
menuconfig changes:
- Boolean value hints are no longer shown to the right of defaults in
the symbol information for int/hex symbols. Stuff like
'- 74 (value: "n")' wasn't helpful, and looked confusing.
- Symbol information has been made more compact in general, e.g. by
skipping value hints where they aren't helpful
('FOO(=y)' instead of 'FOO(=y) (=y)'), and by shortening stuff like
'(value: "y")' to just '(=y)'.
- Misc. internal cleanup.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-10 06:04:23 +02:00
|
|
|
global _kconf
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
global _conf_filename
|
2018-06-15 19:30:34 +02:00
|
|
|
global _conf_changed
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
global _minconf_filename
|
|
|
|
global _show_all
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
kconfiglib/menuconfig: Add functionality and improve symbol information
Update Kconfiglib and menuconfig to upstream revision 6aea8d06b637e.
Kconfiglib changes:
- Kconfig files are now looked up just relative to $srctree (if set).
Previously, each source'd Kconfig file was also looked up in the
current directory, and Kconfig files there could override Kconfig
files in $srctree. This is what the C tools do.
I'm pretty sure that behavior was a bug in the C tools all along, and
only meant for .config files. It caused problems (and an ugly
workaround) for the undefined Kconfig symbol CI check in an external
project.
The new behavior also saves a bunch of open()'s, though it's probably
not noticeable.
- Setting the KCONFIG_STRICT environment variable to 'y' now makes
Kconfiglib itself warn for references to undefined symbols. This
isn't safe in general, as some projects use multiple Kconfig trees
with shared Kconfig files (e.g. the Linux kernel).
This will be used to simplify the undefined Kconfig symbol CI check.
- It's now possible to customize how symbols and choices are printed
within expressions.
This will be used to make the RST link generation in genrest.py less
hacky.
- Instead of having 'gsource', a plain 'source' is now globbing, and
requires at least one match. There's also 'osource', for when it's
okay for a glob pattern to match no files.
'gsource' had the design flaw that there was no way to require at
least one file to match. I plan on replacing all 'gsource' statements
with plain 'source's later, but 'gsource' is still supported for
backwards compatibility.
- def_int, def_hex, and def_string are now available as a Kconfig
extensions, analogous to def_bool (set type and add default).
- Misc. internal cleanup.
menuconfig changes:
- Boolean value hints are no longer shown to the right of defaults in
the symbol information for int/hex symbols. Stuff like
'- 74 (value: "n")' wasn't helpful, and looked confusing.
- Symbol information has been made more compact in general, e.g. by
skipping value hints where they aren't helpful
('FOO(=y)' instead of 'FOO(=y) (=y)'), and by shortening stuff like
'(value: "y")' to just '(=y)'.
- Misc. internal cleanup.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-10 06:04:23 +02:00
|
|
|
_kconf = kconf
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
# Filename to save configuration to
|
|
|
|
_conf_filename = standard_config_filename()
|
|
|
|
|
kconfiglib: Unclutter symbol strings, avoid redundant writes, misc.
Update kconfiglib, menuconfig, and guiconfig to upstream revision
5c904f4549 to get various improvements and fixes in:
- Marc Herbert found an issue involving symlinks, absolute paths,
and rsource that could lead to files not being found. The root cause
was relpath() assuming that symlink/../bar is the same as bar/, which
isn't guaranteed.
Fix it by handling paths in a simpler, more textual way.
- Propagated dependencies from 'depends on' are now stripped from
properties when symbols are printed (e.g. in information dialogs and
generated documentation).
The printed representation now also uses shorthands.
Before:
config A
bool
prompt "foo" if C && D
default A if B && C && D
depends on C && D
After:
config A
bool "foo"
default A if B
depends on C && D
- Before writing a configuration file or header, Kconfiglib now
compares the previous contents of the file against the new contents,
and skips the write if there's no change. This avoids updating the
modification time, and can save work.
A message like "No change to '.config'" is shown when there's no
change.
- .config now has '# end of <menu>' comments to make it easier to see
where a menu ends. This was taken from a change to the C tools.
- load_config() and write_(min_)config() now return a message that can
be printed with print(kconf.load_config()). This allows messages to
be reused in e.g. the configuration interfaces (nice now that there's
also a "No change to..." string).
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-06-03 19:57:27 +02:00
|
|
|
# Load existing configuration and set _conf_changed True if it is outdated
|
|
|
|
_conf_changed = _load_config()
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
# Filename to save minimal configuration to
|
|
|
|
_minconf_filename = "defconfig"
|
|
|
|
|
2018-05-07 13:02:22 +02:00
|
|
|
# Any visible items in the top menu?
|
|
|
|
_show_all = False
|
2018-12-08 05:32:00 +01:00
|
|
|
if not _shown_nodes(kconf.top_node):
|
2018-05-07 13:02:22 +02:00
|
|
|
# Nothing visible. Start in show-all mode and try again.
|
|
|
|
_show_all = True
|
2018-12-08 05:32:00 +01:00
|
|
|
if not _shown_nodes(kconf.top_node):
|
2018-05-07 13:02:22 +02:00
|
|
|
# Give up. The implementation relies on always having a selected
|
|
|
|
# node.
|
|
|
|
print("Empty configuration -- nothing to configure.\n"
|
|
|
|
"Check that environment variables are set properly.")
|
|
|
|
return
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
# Disable warnings. They get mangled in curses mode, and we deal with
|
|
|
|
# errors ourselves.
|
kconfiglib: Unclutter symbol strings, avoid redundant writes, misc.
Update kconfiglib, menuconfig, and guiconfig to upstream revision
5c904f4549 to get various improvements and fixes in:
- Marc Herbert found an issue involving symlinks, absolute paths,
and rsource that could lead to files not being found. The root cause
was relpath() assuming that symlink/../bar is the same as bar/, which
isn't guaranteed.
Fix it by handling paths in a simpler, more textual way.
- Propagated dependencies from 'depends on' are now stripped from
properties when symbols are printed (e.g. in information dialogs and
generated documentation).
The printed representation now also uses shorthands.
Before:
config A
bool
prompt "foo" if C && D
default A if B && C && D
depends on C && D
After:
config A
bool "foo"
default A if B
depends on C && D
- Before writing a configuration file or header, Kconfiglib now
compares the previous contents of the file against the new contents,
and skips the write if there's no change. This avoids updating the
modification time, and can save work.
A message like "No change to '.config'" is shown when there's no
change.
- .config now has '# end of <menu>' comments to make it easier to see
where a menu ends. This was taken from a change to the C tools.
- load_config() and write_(min_)config() now return a message that can
be printed with print(kconf.load_config()). This allows messages to
be reused in e.g. the configuration interfaces (nice now that there's
also a "No change to..." string).
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-06-03 19:57:27 +02:00
|
|
|
kconf.warn = False
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
2018-05-08 17:51:11 +02:00
|
|
|
# Make curses use the locale settings specified in the environment
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
locale.setlocale(locale.LC_ALL, "")
|
|
|
|
|
2018-05-08 17:51:11 +02:00
|
|
|
# Try to fix Unicode issues on systems with bad defaults
|
2019-06-24 08:01:09 +02:00
|
|
|
if _CHANGE_C_LC_CTYPE_TO_UTF8:
|
|
|
|
_change_c_lc_ctype_to_utf8()
|
2018-05-08 17:51:11 +02:00
|
|
|
|
menuconfig: Add jump-to for choices, menus, and comments
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
bf1701b36634b, to add this commit:
menuconfig: Add jump-to for choices, menus, and comments
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.
Previously, only symbols could be jumped to.
Various other small fixes/improvements are included too:
- The "no range constraints" text was dropped from the input dialog
when settings int/hex symbols without an active 'range'. It might be
more confusing than helpful.
- A crash when pressing Ctrl-F (the view-help shortcut) with no matches
in the jump-to dialog was fixed
- Some gnome-terminal shoddiness was worked around to remove minor
jumpiness when reducing the height of the terminal
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-10-15 02:05:45 +02:00
|
|
|
# Get rid of the delay between pressing ESC and jumping to the parent menu,
|
|
|
|
# unless the user has set ESCDELAY (see ncurses(3)). This makes the UI much
|
|
|
|
# smoother to work with.
|
|
|
|
#
|
|
|
|
# Note: This is strictly pretty iffy, since escape codes for e.g. cursor
|
|
|
|
# keys start with ESC, but I've never seen it cause problems in practice
|
|
|
|
# (probably because it's unlikely that the escape code for a key would get
|
|
|
|
# split up across read()s, at least with a terminal emulator). Please
|
|
|
|
# report if you run into issues. Some suitable small default value could be
|
|
|
|
# used here instead in that case. Maybe it's silly to not put in the
|
|
|
|
# smallest imperceptible delay here already, though I don't like guessing.
|
|
|
|
#
|
|
|
|
# (From a quick glance at the ncurses source code, ESCDELAY might only be
|
|
|
|
# relevant for mouse events there, so maybe escapes are assumed to arrive
|
|
|
|
# in one piece already...)
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
os.environ.setdefault("ESCDELAY", "0")
|
|
|
|
|
|
|
|
# Enter curses mode. _menuconfig() returns a string to print on exit, after
|
|
|
|
# curses has been de-initialized.
|
|
|
|
print(curses.wrapper(_menuconfig))
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
2019-01-03 13:13:38 +01:00
|
|
|
def _load_config():
|
|
|
|
# Loads any existing .config file. See the Kconfig.load_config() docstring.
|
|
|
|
#
|
|
|
|
# Returns True if .config is missing or outdated. We always prompt for
|
|
|
|
# saving the configuration in that case.
|
|
|
|
|
kconfiglib: Unclutter symbol strings, avoid redundant writes, misc.
Update kconfiglib, menuconfig, and guiconfig to upstream revision
5c904f4549 to get various improvements and fixes in:
- Marc Herbert found an issue involving symlinks, absolute paths,
and rsource that could lead to files not being found. The root cause
was relpath() assuming that symlink/../bar is the same as bar/, which
isn't guaranteed.
Fix it by handling paths in a simpler, more textual way.
- Propagated dependencies from 'depends on' are now stripped from
properties when symbols are printed (e.g. in information dialogs and
generated documentation).
The printed representation now also uses shorthands.
Before:
config A
bool
prompt "foo" if C && D
default A if B && C && D
depends on C && D
After:
config A
bool "foo"
default A if B
depends on C && D
- Before writing a configuration file or header, Kconfiglib now
compares the previous contents of the file against the new contents,
and skips the write if there's no change. This avoids updating the
modification time, and can save work.
A message like "No change to '.config'" is shown when there's no
change.
- .config now has '# end of <menu>' comments to make it easier to see
where a menu ends. This was taken from a change to the C tools.
- load_config() and write_(min_)config() now return a message that can
be printed with print(kconf.load_config()). This allows messages to
be reused in e.g. the configuration interfaces (nice now that there's
also a "No change to..." string).
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-06-03 19:57:27 +02:00
|
|
|
print(_kconf.load_config())
|
|
|
|
if not os.path.exists(_conf_filename):
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
# No .config
|
|
|
|
return True
|
|
|
|
|
|
|
|
return _needs_save()
|
|
|
|
|
|
|
|
|
|
|
|
def _needs_save():
|
|
|
|
# Returns True if a just-loaded .config file is outdated (would get
|
|
|
|
# modified when saving)
|
|
|
|
|
|
|
|
if _kconf.missing_syms:
|
|
|
|
# Assignments to undefined symbols in the .config
|
2019-01-03 13:13:38 +01:00
|
|
|
return True
|
|
|
|
|
|
|
|
for sym in _kconf.unique_defined_syms:
|
|
|
|
if sym.user_value is None:
|
|
|
|
if sym.config_string:
|
|
|
|
# Unwritten symbol
|
|
|
|
return True
|
2019-05-06 17:12:27 +02:00
|
|
|
elif sym.orig_type in (BOOL, TRISTATE):
|
2019-01-03 13:13:38 +01:00
|
|
|
if sym.tri_value != sym.user_value:
|
|
|
|
# Written bool/tristate symbol, new value
|
|
|
|
return True
|
|
|
|
elif sym.str_value != sym.user_value:
|
|
|
|
# Written string/int/hex symbol, new value
|
|
|
|
return True
|
|
|
|
|
|
|
|
# No need to prompt for save
|
|
|
|
return False
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
# Global variables used below:
|
|
|
|
#
|
menuconfig: Fix a case of visible symbols not being shown
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
78682a8e3c4fe to get the following fix in, which could cause certain
visible symbols to not show up in the menuconfig interface:
menuconfig: Always show implicit submenus with visible nodes
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
parent 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.
(Some other tweaks were made later to avoid showing red outside show-all
mode, because it might look confusing/broken.)
A new color scheme for the menuconfig has been added as well,
contributed by Mitja Horvat (pinkfluid). It can be enabled by setting
the environment variable MENUCONFIG_THEME to 'aquatic'.
The default theme has been tweaked to use bold text for the selected
item too.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-29 10:16:51 +02:00
|
|
|
# _stdscr:
|
|
|
|
# stdscr from curses
|
|
|
|
#
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
# _cur_menu:
|
|
|
|
# Menu node of the menu (or menuconfig symbol, or choice) currently being
|
|
|
|
# shown
|
|
|
|
#
|
2018-05-07 13:02:22 +02:00
|
|
|
# _shown:
|
|
|
|
# List of items in _cur_menu that are shown (ignoring scrolling). In
|
|
|
|
# show-all mode, this list contains all items in _cur_menu. Otherwise, it
|
|
|
|
# contains just the visible items.
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
#
|
|
|
|
# _sel_node_i:
|
2018-05-07 13:02:22 +02:00
|
|
|
# Index in _shown of the currently selected node
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
#
|
|
|
|
# _menu_scroll:
|
2018-05-07 13:02:22 +02:00
|
|
|
# Index in _shown of the top row of the main display
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
#
|
|
|
|
# _parent_screen_rows:
|
|
|
|
# List/stack of the row numbers that the selections in the parent menus
|
|
|
|
# appeared on. This is used to prevent the scrolling from jumping around
|
|
|
|
# when going in and out of menus.
|
2018-05-07 13:02:22 +02:00
|
|
|
#
|
2018-12-17 14:03:58 +01:00
|
|
|
# _show_help/_show_name/_show_all:
|
|
|
|
# If True, the corresponding mode is on. See the module docstring.
|
2018-05-25 20:12:25 +02:00
|
|
|
#
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
# _conf_filename:
|
2019-05-06 17:12:27 +02:00
|
|
|
# File to save the configuration to
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
#
|
|
|
|
# _minconf_filename:
|
|
|
|
# File to save minimal configurations to
|
|
|
|
#
|
2018-05-07 13:02:22 +02:00
|
|
|
# _conf_changed:
|
|
|
|
# True if the configuration has been changed. If False, we don't bother
|
|
|
|
# showing the save-and-quit dialog.
|
|
|
|
#
|
|
|
|
# We reset this to False whenever the configuration is saved explicitly
|
|
|
|
# from the save dialog.
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
def _menuconfig(stdscr):
|
2018-05-07 13:02:22 +02:00
|
|
|
# Logic for the main display, with the list of symbols, etc.
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
menuconfig: Fix a case of visible symbols not being shown
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
78682a8e3c4fe to get the following fix in, which could cause certain
visible symbols to not show up in the menuconfig interface:
menuconfig: Always show implicit submenus with visible nodes
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
parent 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.
(Some other tweaks were made later to avoid showing red outside show-all
mode, because it might look confusing/broken.)
A new color scheme for the menuconfig has been added as well,
contributed by Mitja Horvat (pinkfluid). It can be enabled by setting
the environment variable MENUCONFIG_THEME to 'aquatic'.
The default theme has been tweaked to use bold text for the selected
item too.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-29 10:16:51 +02:00
|
|
|
global _stdscr
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
global _conf_filename
|
2018-05-07 13:02:22 +02:00
|
|
|
global _conf_changed
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
global _minconf_filename
|
2018-12-17 14:03:58 +01:00
|
|
|
global _show_help
|
2018-05-25 20:12:25 +02:00
|
|
|
global _show_name
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
menuconfig: Fix a case of visible symbols not being shown
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
78682a8e3c4fe to get the following fix in, which could cause certain
visible symbols to not show up in the menuconfig interface:
menuconfig: Always show implicit submenus with visible nodes
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
parent 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.
(Some other tweaks were made later to avoid showing red outside show-all
mode, because it might look confusing/broken.)
A new color scheme for the menuconfig has been added as well,
contributed by Mitja Horvat (pinkfluid). It can be enabled by setting
the environment variable MENUCONFIG_THEME to 'aquatic'.
The default theme has been tweaked to use bold text for the selected
item too.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-29 10:16:51 +02:00
|
|
|
_stdscr = stdscr
|
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
_init()
|
|
|
|
|
|
|
|
while True:
|
|
|
|
_draw_main()
|
|
|
|
curses.doupdate()
|
|
|
|
|
|
|
|
|
2019-06-24 08:01:09 +02:00
|
|
|
c = _getch_compat(_menu_win)
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
if c == curses.KEY_RESIZE:
|
|
|
|
_resize_main()
|
|
|
|
|
2018-09-15 08:45:50 +02:00
|
|
|
elif c in (curses.KEY_DOWN, "j", "J"):
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
_select_next_menu_entry()
|
|
|
|
|
|
|
|
elif c in (curses.KEY_UP, "k", "K"):
|
|
|
|
_select_prev_menu_entry()
|
|
|
|
|
|
|
|
elif c in (curses.KEY_NPAGE, "\x04"): # Page Down/Ctrl-D
|
|
|
|
# Keep it simple. This way we get sane behavior for small windows,
|
|
|
|
# etc., for free.
|
|
|
|
for _ in range(_PG_JUMP):
|
|
|
|
_select_next_menu_entry()
|
|
|
|
|
|
|
|
elif c in (curses.KEY_PPAGE, "\x15"): # Page Up/Ctrl-U
|
|
|
|
for _ in range(_PG_JUMP):
|
|
|
|
_select_prev_menu_entry()
|
|
|
|
|
|
|
|
elif c in (curses.KEY_END, "G"):
|
|
|
|
_select_last_menu_entry()
|
|
|
|
|
|
|
|
elif c in (curses.KEY_HOME, "g"):
|
|
|
|
_select_first_menu_entry()
|
|
|
|
|
2019-05-06 17:12:27 +02:00
|
|
|
elif c == " ":
|
|
|
|
# Toggle the node if possible
|
2018-05-07 13:02:22 +02:00
|
|
|
sel_node = _shown[_sel_node_i]
|
2019-05-06 17:12:27 +02:00
|
|
|
if not _change_node(sel_node):
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
_enter_menu(sel_node)
|
|
|
|
|
2019-05-06 17:12:27 +02:00
|
|
|
elif c in (curses.KEY_RIGHT, "\n", "l", "L"):
|
|
|
|
# Enter the node if possible
|
|
|
|
sel_node = _shown[_sel_node_i]
|
|
|
|
if not _enter_menu(sel_node):
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
_change_node(sel_node)
|
|
|
|
|
2018-05-07 13:02:22 +02:00
|
|
|
elif c in ("n", "N"):
|
kconfiglib/menuconfig: Add functionality and improve symbol information
Update Kconfiglib and menuconfig to upstream revision 6aea8d06b637e.
Kconfiglib changes:
- Kconfig files are now looked up just relative to $srctree (if set).
Previously, each source'd Kconfig file was also looked up in the
current directory, and Kconfig files there could override Kconfig
files in $srctree. This is what the C tools do.
I'm pretty sure that behavior was a bug in the C tools all along, and
only meant for .config files. It caused problems (and an ugly
workaround) for the undefined Kconfig symbol CI check in an external
project.
The new behavior also saves a bunch of open()'s, though it's probably
not noticeable.
- Setting the KCONFIG_STRICT environment variable to 'y' now makes
Kconfiglib itself warn for references to undefined symbols. This
isn't safe in general, as some projects use multiple Kconfig trees
with shared Kconfig files (e.g. the Linux kernel).
This will be used to simplify the undefined Kconfig symbol CI check.
- It's now possible to customize how symbols and choices are printed
within expressions.
This will be used to make the RST link generation in genrest.py less
hacky.
- Instead of having 'gsource', a plain 'source' is now globbing, and
requires at least one match. There's also 'osource', for when it's
okay for a glob pattern to match no files.
'gsource' had the design flaw that there was no way to require at
least one file to match. I plan on replacing all 'gsource' statements
with plain 'source's later, but 'gsource' is still supported for
backwards compatibility.
- def_int, def_hex, and def_string are now available as a Kconfig
extensions, analogous to def_bool (set type and add default).
- Misc. internal cleanup.
menuconfig changes:
- Boolean value hints are no longer shown to the right of defaults in
the symbol information for int/hex symbols. Stuff like
'- 74 (value: "n")' wasn't helpful, and looked confusing.
- Symbol information has been made more compact in general, e.g. by
skipping value hints where they aren't helpful
('FOO(=y)' instead of 'FOO(=y) (=y)'), and by shortening stuff like
'(value: "y")' to just '(=y)'.
- Misc. internal cleanup.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-10 06:04:23 +02:00
|
|
|
_set_sel_node_tri_val(0)
|
2018-05-07 13:02:22 +02:00
|
|
|
|
|
|
|
elif c in ("m", "M"):
|
kconfiglib/menuconfig: Add functionality and improve symbol information
Update Kconfiglib and menuconfig to upstream revision 6aea8d06b637e.
Kconfiglib changes:
- Kconfig files are now looked up just relative to $srctree (if set).
Previously, each source'd Kconfig file was also looked up in the
current directory, and Kconfig files there could override Kconfig
files in $srctree. This is what the C tools do.
I'm pretty sure that behavior was a bug in the C tools all along, and
only meant for .config files. It caused problems (and an ugly
workaround) for the undefined Kconfig symbol CI check in an external
project.
The new behavior also saves a bunch of open()'s, though it's probably
not noticeable.
- Setting the KCONFIG_STRICT environment variable to 'y' now makes
Kconfiglib itself warn for references to undefined symbols. This
isn't safe in general, as some projects use multiple Kconfig trees
with shared Kconfig files (e.g. the Linux kernel).
This will be used to simplify the undefined Kconfig symbol CI check.
- It's now possible to customize how symbols and choices are printed
within expressions.
This will be used to make the RST link generation in genrest.py less
hacky.
- Instead of having 'gsource', a plain 'source' is now globbing, and
requires at least one match. There's also 'osource', for when it's
okay for a glob pattern to match no files.
'gsource' had the design flaw that there was no way to require at
least one file to match. I plan on replacing all 'gsource' statements
with plain 'source's later, but 'gsource' is still supported for
backwards compatibility.
- def_int, def_hex, and def_string are now available as a Kconfig
extensions, analogous to def_bool (set type and add default).
- Misc. internal cleanup.
menuconfig changes:
- Boolean value hints are no longer shown to the right of defaults in
the symbol information for int/hex symbols. Stuff like
'- 74 (value: "n")' wasn't helpful, and looked confusing.
- Symbol information has been made more compact in general, e.g. by
skipping value hints where they aren't helpful
('FOO(=y)' instead of 'FOO(=y) (=y)'), and by shortening stuff like
'(value: "y")' to just '(=y)'.
- Misc. internal cleanup.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-10 06:04:23 +02:00
|
|
|
_set_sel_node_tri_val(1)
|
2018-05-07 13:02:22 +02:00
|
|
|
|
|
|
|
elif c in ("y", "Y"):
|
kconfiglib/menuconfig: Add functionality and improve symbol information
Update Kconfiglib and menuconfig to upstream revision 6aea8d06b637e.
Kconfiglib changes:
- Kconfig files are now looked up just relative to $srctree (if set).
Previously, each source'd Kconfig file was also looked up in the
current directory, and Kconfig files there could override Kconfig
files in $srctree. This is what the C tools do.
I'm pretty sure that behavior was a bug in the C tools all along, and
only meant for .config files. It caused problems (and an ugly
workaround) for the undefined Kconfig symbol CI check in an external
project.
The new behavior also saves a bunch of open()'s, though it's probably
not noticeable.
- Setting the KCONFIG_STRICT environment variable to 'y' now makes
Kconfiglib itself warn for references to undefined symbols. This
isn't safe in general, as some projects use multiple Kconfig trees
with shared Kconfig files (e.g. the Linux kernel).
This will be used to simplify the undefined Kconfig symbol CI check.
- It's now possible to customize how symbols and choices are printed
within expressions.
This will be used to make the RST link generation in genrest.py less
hacky.
- Instead of having 'gsource', a plain 'source' is now globbing, and
requires at least one match. There's also 'osource', for when it's
okay for a glob pattern to match no files.
'gsource' had the design flaw that there was no way to require at
least one file to match. I plan on replacing all 'gsource' statements
with plain 'source's later, but 'gsource' is still supported for
backwards compatibility.
- def_int, def_hex, and def_string are now available as a Kconfig
extensions, analogous to def_bool (set type and add default).
- Misc. internal cleanup.
menuconfig changes:
- Boolean value hints are no longer shown to the right of defaults in
the symbol information for int/hex symbols. Stuff like
'- 74 (value: "n")' wasn't helpful, and looked confusing.
- Symbol information has been made more compact in general, e.g. by
skipping value hints where they aren't helpful
('FOO(=y)' instead of 'FOO(=y) (=y)'), and by shortening stuff like
'(value: "y")' to just '(=y)'.
- Misc. internal cleanup.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-10 06:04:23 +02:00
|
|
|
_set_sel_node_tri_val(2)
|
2018-05-07 13:02:22 +02:00
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
elif c in (curses.KEY_LEFT, curses.KEY_BACKSPACE, _ERASE_CHAR,
|
2018-12-08 05:32:00 +01:00
|
|
|
"\x1B", "h", "H"): # \x1B = ESC
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
2018-05-07 13:02:22 +02:00
|
|
|
if c == "\x1B" and _cur_menu is _kconf.top_node:
|
2018-10-10 15:08:45 +02:00
|
|
|
res = _quit_dialog()
|
2018-05-07 13:02:22 +02:00
|
|
|
if res:
|
|
|
|
return res
|
|
|
|
else:
|
|
|
|
_leave_menu()
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
2018-05-18 10:04:26 +02:00
|
|
|
elif c in ("o", "O"):
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
_load_dialog()
|
2018-05-18 10:04:26 +02:00
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
elif c in ("s", "S"):
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
filename = _save_dialog(_kconf.write_config, _conf_filename,
|
|
|
|
"configuration")
|
|
|
|
if filename:
|
|
|
|
_conf_filename = filename
|
2018-05-07 13:02:22 +02:00
|
|
|
_conf_changed = False
|
|
|
|
|
|
|
|
elif c in ("d", "D"):
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
filename = _save_dialog(_kconf.write_min_config, _minconf_filename,
|
|
|
|
"minimal configuration")
|
|
|
|
if filename:
|
|
|
|
_minconf_filename = filename
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
2018-05-07 13:02:22 +02:00
|
|
|
elif c == "/":
|
|
|
|
_jump_to_dialog()
|
2018-05-11 00:22:32 +02:00
|
|
|
# The terminal might have been resized while the fullscreen jump-to
|
|
|
|
# dialog was open
|
|
|
|
_resize_main()
|
2018-05-07 13:02:22 +02:00
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
elif c == "?":
|
2018-06-15 19:30:34 +02:00
|
|
|
_info_dialog(_shown[_sel_node_i], False)
|
2018-05-11 00:22:32 +02:00
|
|
|
# The terminal might have been resized while the fullscreen info
|
|
|
|
# dialog was open
|
|
|
|
_resize_main()
|
2018-05-07 13:02:22 +02:00
|
|
|
|
2018-12-17 14:03:58 +01:00
|
|
|
elif c in ("f", "F"):
|
|
|
|
_show_help = not _show_help
|
|
|
|
_set_style(_help_win, "show-help" if _show_help else "help")
|
|
|
|
_resize_main()
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
2018-05-25 20:12:25 +02:00
|
|
|
elif c in ("c", "C"):
|
|
|
|
_show_name = not _show_name
|
|
|
|
|
2018-12-17 14:03:58 +01:00
|
|
|
elif c in ("a", "A"):
|
|
|
|
_toggle_show_all()
|
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
elif c in ("q", "Q"):
|
2018-10-10 15:08:45 +02:00
|
|
|
res = _quit_dialog()
|
2018-05-07 13:02:22 +02:00
|
|
|
if res:
|
|
|
|
return res
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
2018-10-10 15:08:45 +02:00
|
|
|
def _quit_dialog():
|
kconfiglib/menuconfig: Add functionality and improve symbol information
Update Kconfiglib and menuconfig to upstream revision 6aea8d06b637e.
Kconfiglib changes:
- Kconfig files are now looked up just relative to $srctree (if set).
Previously, each source'd Kconfig file was also looked up in the
current directory, and Kconfig files there could override Kconfig
files in $srctree. This is what the C tools do.
I'm pretty sure that behavior was a bug in the C tools all along, and
only meant for .config files. It caused problems (and an ugly
workaround) for the undefined Kconfig symbol CI check in an external
project.
The new behavior also saves a bunch of open()'s, though it's probably
not noticeable.
- Setting the KCONFIG_STRICT environment variable to 'y' now makes
Kconfiglib itself warn for references to undefined symbols. This
isn't safe in general, as some projects use multiple Kconfig trees
with shared Kconfig files (e.g. the Linux kernel).
This will be used to simplify the undefined Kconfig symbol CI check.
- It's now possible to customize how symbols and choices are printed
within expressions.
This will be used to make the RST link generation in genrest.py less
hacky.
- Instead of having 'gsource', a plain 'source' is now globbing, and
requires at least one match. There's also 'osource', for when it's
okay for a glob pattern to match no files.
'gsource' had the design flaw that there was no way to require at
least one file to match. I plan on replacing all 'gsource' statements
with plain 'source's later, but 'gsource' is still supported for
backwards compatibility.
- def_int, def_hex, and def_string are now available as a Kconfig
extensions, analogous to def_bool (set type and add default).
- Misc. internal cleanup.
menuconfig changes:
- Boolean value hints are no longer shown to the right of defaults in
the symbol information for int/hex symbols. Stuff like
'- 74 (value: "n")' wasn't helpful, and looked confusing.
- Symbol information has been made more compact in general, e.g. by
skipping value hints where they aren't helpful
('FOO(=y)' instead of 'FOO(=y) (=y)'), and by shortening stuff like
'(value: "y")' to just '(=y)'.
- Misc. internal cleanup.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-10 06:04:23 +02:00
|
|
|
if not _conf_changed:
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
return "No changes to save (for '{}')".format(_conf_filename)
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
kconfiglib/menuconfig: Add functionality and improve symbol information
Update Kconfiglib and menuconfig to upstream revision 6aea8d06b637e.
Kconfiglib changes:
- Kconfig files are now looked up just relative to $srctree (if set).
Previously, each source'd Kconfig file was also looked up in the
current directory, and Kconfig files there could override Kconfig
files in $srctree. This is what the C tools do.
I'm pretty sure that behavior was a bug in the C tools all along, and
only meant for .config files. It caused problems (and an ugly
workaround) for the undefined Kconfig symbol CI check in an external
project.
The new behavior also saves a bunch of open()'s, though it's probably
not noticeable.
- Setting the KCONFIG_STRICT environment variable to 'y' now makes
Kconfiglib itself warn for references to undefined symbols. This
isn't safe in general, as some projects use multiple Kconfig trees
with shared Kconfig files (e.g. the Linux kernel).
This will be used to simplify the undefined Kconfig symbol CI check.
- It's now possible to customize how symbols and choices are printed
within expressions.
This will be used to make the RST link generation in genrest.py less
hacky.
- Instead of having 'gsource', a plain 'source' is now globbing, and
requires at least one match. There's also 'osource', for when it's
okay for a glob pattern to match no files.
'gsource' had the design flaw that there was no way to require at
least one file to match. I plan on replacing all 'gsource' statements
with plain 'source's later, but 'gsource' is still supported for
backwards compatibility.
- def_int, def_hex, and def_string are now available as a Kconfig
extensions, analogous to def_bool (set type and add default).
- Misc. internal cleanup.
menuconfig changes:
- Boolean value hints are no longer shown to the right of defaults in
the symbol information for int/hex symbols. Stuff like
'- 74 (value: "n")' wasn't helpful, and looked confusing.
- Symbol information has been made more compact in general, e.g. by
skipping value hints where they aren't helpful
('FOO(=y)' instead of 'FOO(=y) (=y)'), and by shortening stuff like
'(value: "y")' to just '(=y)'.
- Misc. internal cleanup.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-10 06:04:23 +02:00
|
|
|
while True:
|
|
|
|
c = _key_dialog(
|
|
|
|
"Quit",
|
|
|
|
" Save configuration?\n"
|
|
|
|
"\n"
|
|
|
|
"(Y)es (N)o (C)ancel",
|
|
|
|
"ync")
|
|
|
|
|
|
|
|
if c is None or c == "c":
|
|
|
|
return None
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
kconfiglib/menuconfig: Add functionality and improve symbol information
Update Kconfiglib and menuconfig to upstream revision 6aea8d06b637e.
Kconfiglib changes:
- Kconfig files are now looked up just relative to $srctree (if set).
Previously, each source'd Kconfig file was also looked up in the
current directory, and Kconfig files there could override Kconfig
files in $srctree. This is what the C tools do.
I'm pretty sure that behavior was a bug in the C tools all along, and
only meant for .config files. It caused problems (and an ugly
workaround) for the undefined Kconfig symbol CI check in an external
project.
The new behavior also saves a bunch of open()'s, though it's probably
not noticeable.
- Setting the KCONFIG_STRICT environment variable to 'y' now makes
Kconfiglib itself warn for references to undefined symbols. This
isn't safe in general, as some projects use multiple Kconfig trees
with shared Kconfig files (e.g. the Linux kernel).
This will be used to simplify the undefined Kconfig symbol CI check.
- It's now possible to customize how symbols and choices are printed
within expressions.
This will be used to make the RST link generation in genrest.py less
hacky.
- Instead of having 'gsource', a plain 'source' is now globbing, and
requires at least one match. There's also 'osource', for when it's
okay for a glob pattern to match no files.
'gsource' had the design flaw that there was no way to require at
least one file to match. I plan on replacing all 'gsource' statements
with plain 'source's later, but 'gsource' is still supported for
backwards compatibility.
- def_int, def_hex, and def_string are now available as a Kconfig
extensions, analogous to def_bool (set type and add default).
- Misc. internal cleanup.
menuconfig changes:
- Boolean value hints are no longer shown to the right of defaults in
the symbol information for int/hex symbols. Stuff like
'- 74 (value: "n")' wasn't helpful, and looked confusing.
- Symbol information has been made more compact in general, e.g. by
skipping value hints where they aren't helpful
('FOO(=y)' instead of 'FOO(=y) (=y)'), and by shortening stuff like
'(value: "y")' to just '(=y)'.
- Misc. internal cleanup.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-10 06:04:23 +02:00
|
|
|
if c == "y":
|
kconfiglib: Unclutter symbol strings, avoid redundant writes, misc.
Update kconfiglib, menuconfig, and guiconfig to upstream revision
5c904f4549 to get various improvements and fixes in:
- Marc Herbert found an issue involving symlinks, absolute paths,
and rsource that could lead to files not being found. The root cause
was relpath() assuming that symlink/../bar is the same as bar/, which
isn't guaranteed.
Fix it by handling paths in a simpler, more textual way.
- Propagated dependencies from 'depends on' are now stripped from
properties when symbols are printed (e.g. in information dialogs and
generated documentation).
The printed representation now also uses shorthands.
Before:
config A
bool
prompt "foo" if C && D
default A if B && C && D
depends on C && D
After:
config A
bool "foo"
default A if B
depends on C && D
- Before writing a configuration file or header, Kconfiglib now
compares the previous contents of the file against the new contents,
and skips the write if there's no change. This avoids updating the
modification time, and can save work.
A message like "No change to '.config'" is shown when there's no
change.
- .config now has '# end of <menu>' comments to make it easier to see
where a menu ends. This was taken from a change to the C tools.
- load_config() and write_(min_)config() now return a message that can
be printed with print(kconf.load_config()). This allows messages to
be reused in e.g. the configuration interfaces (nice now that there's
also a "No change to..." string).
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-06-03 19:57:27 +02:00
|
|
|
# Returns a message to print
|
|
|
|
msg = _try_save(_kconf.write_config, _conf_filename, "configuration")
|
|
|
|
if msg:
|
|
|
|
return msg
|
2018-05-07 13:02:22 +02:00
|
|
|
|
kconfiglib/menuconfig: Add functionality and improve symbol information
Update Kconfiglib and menuconfig to upstream revision 6aea8d06b637e.
Kconfiglib changes:
- Kconfig files are now looked up just relative to $srctree (if set).
Previously, each source'd Kconfig file was also looked up in the
current directory, and Kconfig files there could override Kconfig
files in $srctree. This is what the C tools do.
I'm pretty sure that behavior was a bug in the C tools all along, and
only meant for .config files. It caused problems (and an ugly
workaround) for the undefined Kconfig symbol CI check in an external
project.
The new behavior also saves a bunch of open()'s, though it's probably
not noticeable.
- Setting the KCONFIG_STRICT environment variable to 'y' now makes
Kconfiglib itself warn for references to undefined symbols. This
isn't safe in general, as some projects use multiple Kconfig trees
with shared Kconfig files (e.g. the Linux kernel).
This will be used to simplify the undefined Kconfig symbol CI check.
- It's now possible to customize how symbols and choices are printed
within expressions.
This will be used to make the RST link generation in genrest.py less
hacky.
- Instead of having 'gsource', a plain 'source' is now globbing, and
requires at least one match. There's also 'osource', for when it's
okay for a glob pattern to match no files.
'gsource' had the design flaw that there was no way to require at
least one file to match. I plan on replacing all 'gsource' statements
with plain 'source's later, but 'gsource' is still supported for
backwards compatibility.
- def_int, def_hex, and def_string are now available as a Kconfig
extensions, analogous to def_bool (set type and add default).
- Misc. internal cleanup.
menuconfig changes:
- Boolean value hints are no longer shown to the right of defaults in
the symbol information for int/hex symbols. Stuff like
'- 74 (value: "n")' wasn't helpful, and looked confusing.
- Symbol information has been made more compact in general, e.g. by
skipping value hints where they aren't helpful
('FOO(=y)' instead of 'FOO(=y) (=y)'), and by shortening stuff like
'(value: "y")' to just '(=y)'.
- Misc. internal cleanup.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-10 06:04:23 +02:00
|
|
|
elif c == "n":
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
return "Configuration ({}) was not saved".format(_conf_filename)
|
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
def _init():
|
|
|
|
# Initializes the main display with the list of symbols, etc. Also does
|
|
|
|
# misc. global initialization that needs to happen after initializing
|
|
|
|
# curses.
|
|
|
|
|
|
|
|
global _ERASE_CHAR
|
|
|
|
|
|
|
|
global _path_win
|
|
|
|
global _top_sep_win
|
|
|
|
global _menu_win
|
|
|
|
global _bot_sep_win
|
|
|
|
global _help_win
|
|
|
|
|
|
|
|
global _parent_screen_rows
|
|
|
|
global _cur_menu
|
2018-05-07 13:02:22 +02:00
|
|
|
global _shown
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
global _sel_node_i
|
|
|
|
global _menu_scroll
|
|
|
|
|
2018-12-17 14:03:58 +01:00
|
|
|
global _show_help
|
2018-05-25 20:12:25 +02:00
|
|
|
global _show_name
|
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
# Looking for this in addition to KEY_BACKSPACE (which is unreliable) makes
|
|
|
|
# backspace work with TERM=vt100. That makes it likely to work in sane
|
|
|
|
# environments.
|
2019-06-24 08:01:09 +02:00
|
|
|
_ERASE_CHAR = curses.erasechar()
|
|
|
|
if sys.version_info[0] >= 3:
|
|
|
|
# erasechar() returns a one-byte bytes object on Python 3. This sets
|
|
|
|
# _ERASE_CHAR to a blank string if it can't be decoded, which should be
|
|
|
|
# harmless.
|
|
|
|
_ERASE_CHAR = _ERASE_CHAR.decode("utf-8", "ignore")
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
_init_styles()
|
|
|
|
|
|
|
|
# Hide the cursor
|
|
|
|
_safe_curs_set(0)
|
|
|
|
|
|
|
|
# Initialize windows
|
|
|
|
|
|
|
|
# Top row, with menu path
|
2018-09-15 08:45:50 +02:00
|
|
|
_path_win = _styled_win("path")
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
# Separator below menu path, with title and arrows pointing up
|
2018-09-15 08:45:50 +02:00
|
|
|
_top_sep_win = _styled_win("separator")
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
# List of menu entries with symbols, etc.
|
2018-09-15 08:45:50 +02:00
|
|
|
_menu_win = _styled_win("list")
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
_menu_win.keypad(True)
|
|
|
|
|
|
|
|
# Row below menu list, with arrows pointing down
|
2018-09-15 08:45:50 +02:00
|
|
|
_bot_sep_win = _styled_win("separator")
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
2018-12-17 14:03:58 +01:00
|
|
|
# Help window with keys at the bottom. Shows help texts in show-help mode.
|
2018-09-15 08:45:50 +02:00
|
|
|
_help_win = _styled_win("help")
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
# The rows we'd like the nodes in the parent menus to appear on. This
|
|
|
|
# prevents the scroll from jumping around when going in and out of menus.
|
|
|
|
_parent_screen_rows = []
|
|
|
|
|
|
|
|
# Initial state
|
2018-05-25 20:12:25 +02:00
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
_cur_menu = _kconf.top_node
|
2018-05-07 13:02:22 +02:00
|
|
|
_shown = _shown_nodes(_cur_menu)
|
2018-09-15 08:45:50 +02:00
|
|
|
_sel_node_i = _menu_scroll = 0
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
2018-12-17 14:03:58 +01:00
|
|
|
_show_help = _show_name = False
|
2018-05-25 20:12:25 +02:00
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
# Give windows their initial size
|
|
|
|
_resize_main()
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
def _resize_main():
|
2018-05-07 13:02:22 +02:00
|
|
|
# Resizes the main display, with the list of symbols, etc., to fill the
|
|
|
|
# terminal
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
global _menu_scroll
|
|
|
|
|
menuconfig: Fix a case of visible symbols not being shown
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
78682a8e3c4fe to get the following fix in, which could cause certain
visible symbols to not show up in the menuconfig interface:
menuconfig: Always show implicit submenus with visible nodes
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
parent 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.
(Some other tweaks were made later to avoid showing red outside show-all
mode, because it might look confusing/broken.)
A new color scheme for the menuconfig has been added as well,
contributed by Mitja Horvat (pinkfluid). It can be enabled by setting
the environment variable MENUCONFIG_THEME to 'aquatic'.
The default theme has been tweaked to use bold text for the selected
item too.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-29 10:16:51 +02:00
|
|
|
screen_height, screen_width = _stdscr.getmaxyx()
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
_path_win.resize(1, screen_width)
|
|
|
|
_top_sep_win.resize(1, screen_width)
|
|
|
|
_bot_sep_win.resize(1, screen_width)
|
|
|
|
|
2018-12-17 14:03:58 +01:00
|
|
|
help_win_height = _SHOW_HELP_HEIGHT if _show_help else \
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
len(_MAIN_HELP_LINES)
|
2018-12-17 14:03:58 +01:00
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
menu_win_height = screen_height - help_win_height - 3
|
|
|
|
|
|
|
|
if menu_win_height >= 1:
|
|
|
|
_menu_win.resize(menu_win_height, screen_width)
|
|
|
|
_help_win.resize(help_win_height, screen_width)
|
|
|
|
|
|
|
|
_top_sep_win.mvwin(1, 0)
|
|
|
|
_menu_win.mvwin(2, 0)
|
|
|
|
_bot_sep_win.mvwin(2 + menu_win_height, 0)
|
|
|
|
_help_win.mvwin(2 + menu_win_height + 1, 0)
|
|
|
|
else:
|
|
|
|
# Degenerate case. Give up on nice rendering and just prevent errors.
|
|
|
|
|
|
|
|
menu_win_height = 1
|
|
|
|
|
|
|
|
_menu_win.resize(1, screen_width)
|
|
|
|
_help_win.resize(1, screen_width)
|
|
|
|
|
|
|
|
for win in _top_sep_win, _menu_win, _bot_sep_win, _help_win:
|
|
|
|
win.mvwin(0, 0)
|
|
|
|
|
2018-05-07 13:02:22 +02:00
|
|
|
# Adjust the scroll so that the selected node is still within the window,
|
|
|
|
# if needed
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
if _sel_node_i - _menu_scroll >= menu_win_height:
|
|
|
|
_menu_scroll = _sel_node_i - menu_win_height + 1
|
|
|
|
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
def _height(win):
|
|
|
|
# Returns the height of 'win'
|
|
|
|
|
|
|
|
return win.getmaxyx()[0]
|
|
|
|
|
|
|
|
|
|
|
|
def _width(win):
|
|
|
|
# Returns the width of 'win'
|
|
|
|
|
|
|
|
return win.getmaxyx()[1]
|
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
def _enter_menu(menu):
|
2019-05-06 17:12:27 +02:00
|
|
|
# Makes 'menu' the currently displayed menu. In addition to actual 'menu's,
|
|
|
|
# "menu" here includes choices and symbols defined with the 'menuconfig'
|
|
|
|
# keyword.
|
|
|
|
#
|
|
|
|
# Returns False if 'menu' can't be entered.
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
global _cur_menu
|
2018-05-07 13:02:22 +02:00
|
|
|
global _shown
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
global _sel_node_i
|
|
|
|
global _menu_scroll
|
|
|
|
|
2019-05-06 17:12:27 +02:00
|
|
|
if not menu.is_menuconfig:
|
2020-01-13 10:38:45 +01:00
|
|
|
return False # Not a menu
|
2019-05-06 17:12:27 +02:00
|
|
|
|
2018-05-07 13:02:22 +02:00
|
|
|
shown_sub = _shown_nodes(menu)
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
# Never enter empty menus. We depend on having a current node.
|
2019-05-06 17:12:27 +02:00
|
|
|
if not shown_sub:
|
|
|
|
return False
|
|
|
|
|
|
|
|
# Remember where the current node appears on the screen, so we can try
|
|
|
|
# to get it to appear in the same place when we leave the menu
|
|
|
|
_parent_screen_rows.append(_sel_node_i - _menu_scroll)
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
2019-05-06 17:12:27 +02:00
|
|
|
# Jump into menu
|
|
|
|
_cur_menu = menu
|
|
|
|
_shown = shown_sub
|
|
|
|
_sel_node_i = _menu_scroll = 0
|
|
|
|
|
|
|
|
if isinstance(menu.item, Choice):
|
|
|
|
_select_selected_choice_sym()
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
2019-05-06 17:12:27 +02:00
|
|
|
return True
|
2018-11-04 01:58:08 +01:00
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
2018-11-04 01:58:08 +01:00
|
|
|
def _select_selected_choice_sym():
|
|
|
|
# Puts the cursor on the currently selected (y-valued) choice symbol, if
|
|
|
|
# any. Does nothing if if the choice has no selection (is not visible/in y
|
|
|
|
# mode).
|
|
|
|
|
|
|
|
global _sel_node_i
|
|
|
|
|
|
|
|
choice = _cur_menu.item
|
|
|
|
if choice.selection:
|
|
|
|
# Search through all menu nodes to handle choice symbols being defined
|
|
|
|
# in multiple locations
|
|
|
|
for node in choice.selection.nodes:
|
|
|
|
if node in _shown:
|
|
|
|
_sel_node_i = _shown.index(node)
|
|
|
|
_center_vertically()
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
return
|
|
|
|
|
2018-11-04 01:58:08 +01:00
|
|
|
|
2018-05-07 13:02:22 +02:00
|
|
|
def _jump_to(node):
|
|
|
|
# Jumps directly to the menu node 'node'
|
|
|
|
|
|
|
|
global _cur_menu
|
|
|
|
global _shown
|
|
|
|
global _sel_node_i
|
|
|
|
global _menu_scroll
|
|
|
|
global _show_all
|
|
|
|
global _parent_screen_rows
|
|
|
|
|
|
|
|
# Clear remembered menu locations. We might not even have been in the
|
|
|
|
# parent menus before.
|
|
|
|
_parent_screen_rows = []
|
|
|
|
|
menuconfig: Add jump-to for choices, menus, and comments
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
bf1701b36634b, to add this commit:
menuconfig: Add jump-to for choices, menus, and comments
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.
Previously, only symbols could be jumped to.
Various other small fixes/improvements are included too:
- The "no range constraints" text was dropped from the input dialog
when settings int/hex symbols without an active 'range'. It might be
more confusing than helpful.
- A crash when pressing Ctrl-F (the view-help shortcut) with no matches
in the jump-to dialog was fixed
- Some gnome-terminal shoddiness was worked around to remove minor
jumpiness when reducing the height of the terminal
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-10-15 02:05:45 +02:00
|
|
|
old_show_all = _show_all
|
|
|
|
jump_into = (isinstance(node.item, Choice) or node.item == MENU) and \
|
|
|
|
node.list
|
|
|
|
|
|
|
|
# If we're jumping to a non-empty choice or menu, jump to the first entry
|
|
|
|
# in it instead of jumping to its menu node
|
|
|
|
if jump_into:
|
|
|
|
_cur_menu = node
|
|
|
|
node = node.list
|
|
|
|
else:
|
|
|
|
_cur_menu = _parent_menu(node)
|
|
|
|
|
2018-05-07 13:02:22 +02:00
|
|
|
_shown = _shown_nodes(_cur_menu)
|
menuconfig: Fix a case of visible symbols not being shown
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
78682a8e3c4fe to get the following fix in, which could cause certain
visible symbols to not show up in the menuconfig interface:
menuconfig: Always show implicit submenus with visible nodes
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
parent 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.
(Some other tweaks were made later to avoid showing red outside show-all
mode, because it might look confusing/broken.)
A new color scheme for the menuconfig has been added as well,
contributed by Mitja Horvat (pinkfluid). It can be enabled by setting
the environment variable MENUCONFIG_THEME to 'aquatic'.
The default theme has been tweaked to use bold text for the selected
item too.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-29 10:16:51 +02:00
|
|
|
if node not in _shown:
|
menuconfig: Add jump-to for choices, menus, and comments
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
bf1701b36634b, to add this commit:
menuconfig: Add jump-to for choices, menus, and comments
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.
Previously, only symbols could be jumped to.
Various other small fixes/improvements are included too:
- The "no range constraints" text was dropped from the input dialog
when settings int/hex symbols without an active 'range'. It might be
more confusing than helpful.
- A crash when pressing Ctrl-F (the view-help shortcut) with no matches
in the jump-to dialog was fixed
- Some gnome-terminal shoddiness was worked around to remove minor
jumpiness when reducing the height of the terminal
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-10-15 02:05:45 +02:00
|
|
|
# The node wouldn't be shown. Turn on show-all to show it.
|
menuconfig: Fix a case of visible symbols not being shown
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
78682a8e3c4fe to get the following fix in, which could cause certain
visible symbols to not show up in the menuconfig interface:
menuconfig: Always show implicit submenus with visible nodes
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
parent 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.
(Some other tweaks were made later to avoid showing red outside show-all
mode, because it might look confusing/broken.)
A new color scheme for the menuconfig has been added as well,
contributed by Mitja Horvat (pinkfluid). It can be enabled by setting
the environment variable MENUCONFIG_THEME to 'aquatic'.
The default theme has been tweaked to use bold text for the selected
item too.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-29 10:16:51 +02:00
|
|
|
_show_all = True
|
|
|
|
_shown = _shown_nodes(_cur_menu)
|
|
|
|
|
2018-05-07 13:02:22 +02:00
|
|
|
_sel_node_i = _shown.index(node)
|
|
|
|
|
menuconfig: Add jump-to for choices, menus, and comments
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
bf1701b36634b, to add this commit:
menuconfig: Add jump-to for choices, menus, and comments
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.
Previously, only symbols could be jumped to.
Various other small fixes/improvements are included too:
- The "no range constraints" text was dropped from the input dialog
when settings int/hex symbols without an active 'range'. It might be
more confusing than helpful.
- A crash when pressing Ctrl-F (the view-help shortcut) with no matches
in the jump-to dialog was fixed
- Some gnome-terminal shoddiness was worked around to remove minor
jumpiness when reducing the height of the terminal
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-10-15 02:05:45 +02:00
|
|
|
if jump_into and not old_show_all and _show_all:
|
|
|
|
# If we're jumping into a choice or menu and were forced to turn on
|
|
|
|
# show-all because the first entry wasn't visible, try turning it off.
|
|
|
|
# That will land us at the first visible node if there are visible
|
|
|
|
# nodes, and is a no-op otherwise.
|
|
|
|
_toggle_show_all()
|
|
|
|
|
menuconfig: Fix a case of visible symbols not being shown
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
78682a8e3c4fe to get the following fix in, which could cause certain
visible symbols to not show up in the menuconfig interface:
menuconfig: Always show implicit submenus with visible nodes
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
parent 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.
(Some other tweaks were made later to avoid showing red outside show-all
mode, because it might look confusing/broken.)
A new color scheme for the menuconfig has been added as well,
contributed by Mitja Horvat (pinkfluid). It can be enabled by setting
the environment variable MENUCONFIG_THEME to 'aquatic'.
The default theme has been tweaked to use bold text for the selected
item too.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-29 10:16:51 +02:00
|
|
|
_center_vertically()
|
2018-05-07 13:02:22 +02:00
|
|
|
|
2018-11-04 01:58:08 +01:00
|
|
|
# If we're jumping to a non-empty choice, jump to the selected symbol, if
|
|
|
|
# any
|
|
|
|
if jump_into and isinstance(_cur_menu.item, Choice):
|
|
|
|
_select_selected_choice_sym()
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
def _leave_menu():
|
|
|
|
# Jumps to the parent menu of the current menu. Does nothing if we're in
|
|
|
|
# the top menu.
|
|
|
|
|
|
|
|
global _cur_menu
|
2018-05-07 13:02:22 +02:00
|
|
|
global _shown
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
global _sel_node_i
|
|
|
|
global _menu_scroll
|
|
|
|
|
|
|
|
if _cur_menu is _kconf.top_node:
|
|
|
|
return
|
|
|
|
|
|
|
|
# Jump to parent menu
|
|
|
|
parent = _parent_menu(_cur_menu)
|
2018-05-07 13:02:22 +02:00
|
|
|
_shown = _shown_nodes(parent)
|
|
|
|
_sel_node_i = _shown.index(_cur_menu)
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
_cur_menu = parent
|
|
|
|
|
|
|
|
# Try to make the menu entry appear on the same row on the screen as it did
|
2018-05-07 13:02:22 +02:00
|
|
|
# before we entered the menu.
|
|
|
|
|
|
|
|
if _parent_screen_rows:
|
|
|
|
# The terminal might have shrunk since we were last in the parent menu
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
screen_row = min(_parent_screen_rows.pop(), _height(_menu_win) - 1)
|
2018-05-07 13:02:22 +02:00
|
|
|
_menu_scroll = max(_sel_node_i - screen_row, 0)
|
|
|
|
else:
|
|
|
|
# No saved parent menu locations, meaning we jumped directly to some
|
menuconfig: Fix a case of visible symbols not being shown
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
78682a8e3c4fe to get the following fix in, which could cause certain
visible symbols to not show up in the menuconfig interface:
menuconfig: Always show implicit submenus with visible nodes
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
parent 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.
(Some other tweaks were made later to avoid showing red outside show-all
mode, because it might look confusing/broken.)
A new color scheme for the menuconfig has been added as well,
contributed by Mitja Horvat (pinkfluid). It can be enabled by setting
the environment variable MENUCONFIG_THEME to 'aquatic'.
The default theme has been tweaked to use bold text for the selected
item too.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-29 10:16:51 +02:00
|
|
|
# node earlier
|
|
|
|
_center_vertically()
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
def _select_next_menu_entry():
|
|
|
|
# Selects the menu entry after the current one, adjusting the scroll if
|
|
|
|
# necessary. Does nothing if we're already at the last menu entry.
|
|
|
|
|
|
|
|
global _sel_node_i
|
|
|
|
global _menu_scroll
|
|
|
|
|
2018-05-07 13:02:22 +02:00
|
|
|
if _sel_node_i < len(_shown) - 1:
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
# Jump to the next node
|
|
|
|
_sel_node_i += 1
|
|
|
|
|
|
|
|
# If the new node is sufficiently close to the edge of the menu window
|
|
|
|
# (as determined by _SCROLL_OFFSET), increase the scroll by one. This
|
|
|
|
# gives nice and non-jumpy behavior even when
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
# _SCROLL_OFFSET >= _height(_menu_win).
|
|
|
|
if _sel_node_i >= _menu_scroll + _height(_menu_win) - _SCROLL_OFFSET \
|
2018-11-17 20:28:09 +01:00
|
|
|
and _menu_scroll < _max_scroll(_shown, _menu_win):
|
|
|
|
|
|
|
|
_menu_scroll += 1
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
def _select_prev_menu_entry():
|
|
|
|
# Selects the menu entry before the current one, adjusting the scroll if
|
|
|
|
# necessary. Does nothing if we're already at the first menu entry.
|
|
|
|
|
|
|
|
global _sel_node_i
|
|
|
|
global _menu_scroll
|
|
|
|
|
|
|
|
if _sel_node_i > 0:
|
|
|
|
# Jump to the previous node
|
|
|
|
_sel_node_i -= 1
|
|
|
|
|
|
|
|
# See _select_next_menu_entry()
|
2019-05-06 17:12:27 +02:00
|
|
|
if _sel_node_i < _menu_scroll + _SCROLL_OFFSET:
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
_menu_scroll = max(_menu_scroll - 1, 0)
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
def _select_last_menu_entry():
|
|
|
|
# Selects the last menu entry in the current menu
|
|
|
|
|
|
|
|
global _sel_node_i
|
|
|
|
global _menu_scroll
|
|
|
|
|
2018-05-07 13:02:22 +02:00
|
|
|
_sel_node_i = len(_shown) - 1
|
|
|
|
_menu_scroll = _max_scroll(_shown, _menu_win)
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
def _select_first_menu_entry():
|
|
|
|
# Selects the first menu entry in the current menu
|
|
|
|
|
|
|
|
global _sel_node_i
|
|
|
|
global _menu_scroll
|
|
|
|
|
|
|
|
_sel_node_i = _menu_scroll = 0
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
2018-05-07 13:02:22 +02:00
|
|
|
def _toggle_show_all():
|
menuconfig: Add jump-to for choices, menus, and comments
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
bf1701b36634b, to add this commit:
menuconfig: Add jump-to for choices, menus, and comments
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.
Previously, only symbols could be jumped to.
Various other small fixes/improvements are included too:
- The "no range constraints" text was dropped from the input dialog
when settings int/hex symbols without an active 'range'. It might be
more confusing than helpful.
- A crash when pressing Ctrl-F (the view-help shortcut) with no matches
in the jump-to dialog was fixed
- Some gnome-terminal shoddiness was worked around to remove minor
jumpiness when reducing the height of the terminal
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-10-15 02:05:45 +02:00
|
|
|
# Toggles show-all mode on/off. If turning it off would give no visible
|
|
|
|
# items in the current menu, it is left on.
|
2018-05-07 13:02:22 +02:00
|
|
|
|
|
|
|
global _show_all
|
|
|
|
global _shown
|
|
|
|
global _sel_node_i
|
|
|
|
global _menu_scroll
|
|
|
|
|
|
|
|
# Row on the screen the cursor is on. Preferably we want the same row to
|
|
|
|
# stay highlighted.
|
|
|
|
old_row = _sel_node_i - _menu_scroll
|
|
|
|
|
|
|
|
_show_all = not _show_all
|
|
|
|
# List of new nodes to be shown after toggling _show_all
|
|
|
|
new_shown = _shown_nodes(_cur_menu)
|
|
|
|
|
|
|
|
# Find a good node to select. The selected node might disappear if show-all
|
|
|
|
# mode is turned off.
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
# Select the previously selected node itself if it is still visible. If
|
|
|
|
# there are visible nodes before it, select the closest one.
|
|
|
|
for node in _shown[_sel_node_i::-1]:
|
2018-05-07 13:02:22 +02:00
|
|
|
if node in new_shown:
|
|
|
|
_sel_node_i = new_shown.index(node)
|
|
|
|
break
|
|
|
|
else:
|
|
|
|
# No visible nodes before the previously selected node. Select the
|
|
|
|
# closest visible node after it instead.
|
|
|
|
for node in _shown[_sel_node_i + 1:]:
|
|
|
|
if node in new_shown:
|
|
|
|
_sel_node_i = new_shown.index(node)
|
|
|
|
break
|
|
|
|
else:
|
|
|
|
# No visible nodes at all, meaning show-all was turned off inside
|
|
|
|
# an invisible menu. Don't allow that, as the implementation relies
|
|
|
|
# on always having a selected node.
|
|
|
|
_show_all = True
|
|
|
|
return
|
|
|
|
|
|
|
|
_shown = new_shown
|
|
|
|
|
|
|
|
# Try to make the cursor stay on the same row in the menu window. This
|
|
|
|
# might be impossible if too many nodes have disappeared above the node.
|
|
|
|
_menu_scroll = max(_sel_node_i - old_row, 0)
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
menuconfig: Fix a case of visible symbols not being shown
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
78682a8e3c4fe to get the following fix in, which could cause certain
visible symbols to not show up in the menuconfig interface:
menuconfig: Always show implicit submenus with visible nodes
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
parent 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.
(Some other tweaks were made later to avoid showing red outside show-all
mode, because it might look confusing/broken.)
A new color scheme for the menuconfig has been added as well,
contributed by Mitja Horvat (pinkfluid). It can be enabled by setting
the environment variable MENUCONFIG_THEME to 'aquatic'.
The default theme has been tweaked to use bold text for the selected
item too.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-29 10:16:51 +02:00
|
|
|
def _center_vertically():
|
|
|
|
# Centers the selected node vertically, if possible
|
|
|
|
|
|
|
|
global _menu_scroll
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
_menu_scroll = min(max(_sel_node_i - _height(_menu_win)//2, 0),
|
2018-11-04 01:58:08 +01:00
|
|
|
_max_scroll(_shown, _menu_win))
|
menuconfig: Fix a case of visible symbols not being shown
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
78682a8e3c4fe to get the following fix in, which could cause certain
visible symbols to not show up in the menuconfig interface:
menuconfig: Always show implicit submenus with visible nodes
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
parent 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.
(Some other tweaks were made later to avoid showing red outside show-all
mode, because it might look confusing/broken.)
A new color scheme for the menuconfig has been added as well,
contributed by Mitja Horvat (pinkfluid). It can be enabled by setting
the environment variable MENUCONFIG_THEME to 'aquatic'.
The default theme has been tweaked to use bold text for the selected
item too.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-29 10:16:51 +02:00
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
def _draw_main():
|
|
|
|
# Draws the "main" display, with the list of symbols, the header, and the
|
|
|
|
# footer.
|
|
|
|
#
|
|
|
|
# This could be optimized to only update the windows that have actually
|
|
|
|
# changed, but keep it simple for now and let curses sort it out.
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
term_width = _width(_stdscr)
|
2018-05-07 13:02:22 +02:00
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
#
|
|
|
|
# Update the separator row below the menu path
|
|
|
|
#
|
|
|
|
|
|
|
|
_top_sep_win.erase()
|
|
|
|
|
|
|
|
# Draw arrows pointing up if the symbol window is scrolled down. Draw them
|
|
|
|
# before drawing the title, so the title ends up on top for small windows.
|
|
|
|
if _menu_scroll > 0:
|
|
|
|
_safe_hline(_top_sep_win, 0, 4, curses.ACS_UARROW, _N_SCROLL_ARROWS)
|
|
|
|
|
|
|
|
# Add the 'mainmenu' text as the title, centered at the top
|
|
|
|
_safe_addstr(_top_sep_win,
|
2018-09-15 08:45:50 +02:00
|
|
|
0, max((term_width - len(_kconf.mainmenu_text))//2, 0),
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
_kconf.mainmenu_text)
|
|
|
|
|
|
|
|
_top_sep_win.noutrefresh()
|
|
|
|
|
menuconfig: Add jump-to for choices, menus, and comments
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
bf1701b36634b, to add this commit:
menuconfig: Add jump-to for choices, menus, and comments
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.
Previously, only symbols could be jumped to.
Various other small fixes/improvements are included too:
- The "no range constraints" text was dropped from the input dialog
when settings int/hex symbols without an active 'range'. It might be
more confusing than helpful.
- A crash when pressing Ctrl-F (the view-help shortcut) with no matches
in the jump-to dialog was fixed
- Some gnome-terminal shoddiness was worked around to remove minor
jumpiness when reducing the height of the terminal
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-10-15 02:05:45 +02:00
|
|
|
# Note: The menu path at the top is deliberately updated last. See below.
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# Update the symbol window
|
|
|
|
#
|
|
|
|
|
|
|
|
_menu_win.erase()
|
|
|
|
|
2018-05-07 13:02:22 +02:00
|
|
|
# Draw the _shown nodes starting from index _menu_scroll up to either as
|
|
|
|
# many as fit in the window, or to the end of _shown
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
for i in range(_menu_scroll,
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
min(_menu_scroll + _height(_menu_win), len(_shown))):
|
2018-05-07 13:02:22 +02:00
|
|
|
|
|
|
|
node = _shown[i]
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
menuconfig: Fix a case of visible symbols not being shown
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
78682a8e3c4fe to get the following fix in, which could cause certain
visible symbols to not show up in the menuconfig interface:
menuconfig: Always show implicit submenus with visible nodes
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
parent 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.
(Some other tweaks were made later to avoid showing red outside show-all
mode, because it might look confusing/broken.)
A new color scheme for the menuconfig has been added as well,
contributed by Mitja Horvat (pinkfluid). It can be enabled by setting
the environment variable MENUCONFIG_THEME to 'aquatic'.
The default theme has been tweaked to use bold text for the selected
item too.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-29 10:16:51 +02:00
|
|
|
# The 'not _show_all' test avoids showing invisible items in red
|
|
|
|
# outside show-all mode, which could look confusing/broken. Invisible
|
|
|
|
# symbols show up outside show-all mode if an invisible symbol has
|
|
|
|
# visible children in an implicit (indented) menu.
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
if _visible(node) or not _show_all:
|
2018-09-15 08:45:50 +02:00
|
|
|
style = _style["selection" if i == _sel_node_i else "list"]
|
2018-05-07 13:02:22 +02:00
|
|
|
else:
|
2018-09-15 08:45:50 +02:00
|
|
|
style = _style["inv-selection" if i == _sel_node_i else "inv-list"]
|
2018-05-07 13:02:22 +02:00
|
|
|
|
|
|
|
_safe_addstr(_menu_win, i - _menu_scroll, 0, _node_str(node), style)
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
_menu_win.noutrefresh()
|
|
|
|
|
|
|
|
#
|
|
|
|
# Update the bottom separator window
|
|
|
|
#
|
|
|
|
|
|
|
|
_bot_sep_win.erase()
|
|
|
|
|
|
|
|
# Draw arrows pointing down if the symbol window is scrolled up
|
2018-05-07 13:02:22 +02:00
|
|
|
if _menu_scroll < _max_scroll(_shown, _menu_win):
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
_safe_hline(_bot_sep_win, 0, 4, curses.ACS_DARROW, _N_SCROLL_ARROWS)
|
|
|
|
|
2018-12-17 14:03:58 +01:00
|
|
|
# Indicate when show-name/show-help/show-all mode is enabled
|
2018-05-25 20:12:25 +02:00
|
|
|
enabled_modes = []
|
2018-12-17 14:03:58 +01:00
|
|
|
if _show_help:
|
|
|
|
enabled_modes.append("show-help (toggle with [F])")
|
2018-05-25 20:12:25 +02:00
|
|
|
if _show_name:
|
|
|
|
enabled_modes.append("show-name")
|
2018-12-17 14:03:58 +01:00
|
|
|
if _show_all:
|
|
|
|
enabled_modes.append("show-all")
|
2018-05-25 20:12:25 +02:00
|
|
|
if enabled_modes:
|
|
|
|
s = " and ".join(enabled_modes) + " mode enabled"
|
2018-12-17 14:03:58 +01:00
|
|
|
_safe_addstr(_bot_sep_win, 0, max(term_width - len(s) - 2, 0), s)
|
2018-05-07 13:02:22 +02:00
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
_bot_sep_win.noutrefresh()
|
|
|
|
|
|
|
|
#
|
2018-12-17 14:03:58 +01:00
|
|
|
# Update the help window, which shows either key bindings or help texts
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
#
|
|
|
|
|
|
|
|
_help_win.erase()
|
|
|
|
|
2018-12-17 14:03:58 +01:00
|
|
|
if _show_help:
|
|
|
|
node = _shown[_sel_node_i]
|
|
|
|
if isinstance(node.item, (Symbol, Choice)) and node.help:
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
help_lines = textwrap.wrap(node.help, _width(_help_win))
|
|
|
|
for i in range(min(_height(_help_win), len(help_lines))):
|
2018-12-17 14:03:58 +01:00
|
|
|
_safe_addstr(_help_win, i, 0, help_lines[i])
|
|
|
|
else:
|
|
|
|
_safe_addstr(_help_win, 0, 0, "(no help)")
|
|
|
|
else:
|
|
|
|
for i, line in enumerate(_MAIN_HELP_LINES):
|
|
|
|
_safe_addstr(_help_win, i, 0, line)
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
_help_win.noutrefresh()
|
|
|
|
|
menuconfig: Add jump-to for choices, menus, and comments
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
bf1701b36634b, to add this commit:
menuconfig: Add jump-to for choices, menus, and comments
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.
Previously, only symbols could be jumped to.
Various other small fixes/improvements are included too:
- The "no range constraints" text was dropped from the input dialog
when settings int/hex symbols without an active 'range'. It might be
more confusing than helpful.
- A crash when pressing Ctrl-F (the view-help shortcut) with no matches
in the jump-to dialog was fixed
- Some gnome-terminal shoddiness was worked around to remove minor
jumpiness when reducing the height of the terminal
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-10-15 02:05:45 +02:00
|
|
|
#
|
|
|
|
# Update the top row with the menu path.
|
|
|
|
#
|
|
|
|
# Doing this last leaves the cursor on the top row, which avoids some minor
|
|
|
|
# annoying jumpiness in gnome-terminal when reducing the height of the
|
|
|
|
# terminal. It seems to happen whenever the row with the cursor on it
|
|
|
|
# disappears.
|
|
|
|
#
|
|
|
|
|
|
|
|
_path_win.erase()
|
|
|
|
|
2019-05-06 17:12:27 +02:00
|
|
|
# Draw the menu path ("(Top) -> Menu -> Submenu -> ...")
|
menuconfig: Add jump-to for choices, menus, and comments
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
bf1701b36634b, to add this commit:
menuconfig: Add jump-to for choices, menus, and comments
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.
Previously, only symbols could be jumped to.
Various other small fixes/improvements are included too:
- The "no range constraints" text was dropped from the input dialog
when settings int/hex symbols without an active 'range'. It might be
more confusing than helpful.
- A crash when pressing Ctrl-F (the view-help shortcut) with no matches
in the jump-to dialog was fixed
- Some gnome-terminal shoddiness was worked around to remove minor
jumpiness when reducing the height of the terminal
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-10-15 02:05:45 +02:00
|
|
|
|
|
|
|
menu_prompts = []
|
|
|
|
|
|
|
|
menu = _cur_menu
|
|
|
|
while menu is not _kconf.top_node:
|
|
|
|
# Promptless choices can be entered in show-all mode. Use
|
|
|
|
# standard_sc_expr_str() for them, so they show up as
|
|
|
|
# '<choice (name if any)>'.
|
|
|
|
menu_prompts.append(menu.prompt[0] if menu.prompt else
|
|
|
|
standard_sc_expr_str(menu.item))
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
menu = menu.parent
|
2019-05-06 17:12:27 +02:00
|
|
|
menu_prompts.append("(Top)")
|
menuconfig: Add jump-to for choices, menus, and comments
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
bf1701b36634b, to add this commit:
menuconfig: Add jump-to for choices, menus, and comments
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.
Previously, only symbols could be jumped to.
Various other small fixes/improvements are included too:
- The "no range constraints" text was dropped from the input dialog
when settings int/hex symbols without an active 'range'. It might be
more confusing than helpful.
- A crash when pressing Ctrl-F (the view-help shortcut) with no matches
in the jump-to dialog was fixed
- Some gnome-terminal shoddiness was worked around to remove minor
jumpiness when reducing the height of the terminal
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-10-15 02:05:45 +02:00
|
|
|
menu_prompts.reverse()
|
|
|
|
|
|
|
|
# Hack: We can't put ACS_RARROW directly in the string. Temporarily
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
# represent it with NULL.
|
menuconfig: Add jump-to for choices, menus, and comments
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
bf1701b36634b, to add this commit:
menuconfig: Add jump-to for choices, menus, and comments
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.
Previously, only symbols could be jumped to.
Various other small fixes/improvements are included too:
- The "no range constraints" text was dropped from the input dialog
when settings int/hex symbols without an active 'range'. It might be
more confusing than helpful.
- A crash when pressing Ctrl-F (the view-help shortcut) with no matches
in the jump-to dialog was fixed
- Some gnome-terminal shoddiness was worked around to remove minor
jumpiness when reducing the height of the terminal
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-10-15 02:05:45 +02:00
|
|
|
menu_path_str = " \0 ".join(menu_prompts)
|
|
|
|
|
|
|
|
# Scroll the menu path to the right if needed to make the current menu's
|
|
|
|
# title visible
|
|
|
|
if len(menu_path_str) > term_width:
|
|
|
|
menu_path_str = menu_path_str[len(menu_path_str) - term_width:]
|
|
|
|
|
|
|
|
# Print the path with the arrows reinserted
|
|
|
|
split_path = menu_path_str.split("\0")
|
|
|
|
_safe_addstr(_path_win, split_path[0])
|
|
|
|
for s in split_path[1:]:
|
|
|
|
_safe_addch(_path_win, curses.ACS_RARROW)
|
|
|
|
_safe_addstr(_path_win, s)
|
|
|
|
|
|
|
|
_path_win.noutrefresh()
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
def _parent_menu(node):
|
|
|
|
# Returns the menu node of the menu that contains 'node'. In addition to
|
|
|
|
# proper 'menu's, this might also be a 'menuconfig' symbol or a 'choice'.
|
2018-05-11 00:22:32 +02:00
|
|
|
# "Menu" here means a menu in the interface.
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
menu = node.parent
|
|
|
|
while not menu.is_menuconfig:
|
|
|
|
menu = menu.parent
|
|
|
|
return menu
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
2018-05-07 13:02:22 +02:00
|
|
|
def _shown_nodes(menu):
|
menuconfig: Fix a case of visible symbols not being shown
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
78682a8e3c4fe to get the following fix in, which could cause certain
visible symbols to not show up in the menuconfig interface:
menuconfig: Always show implicit submenus with visible nodes
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
parent 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.
(Some other tweaks were made later to avoid showing red outside show-all
mode, because it might look confusing/broken.)
A new color scheme for the menuconfig has been added as well,
contributed by Mitja Horvat (pinkfluid). It can be enabled by setting
the environment variable MENUCONFIG_THEME to 'aquatic'.
The default theme has been tweaked to use bold text for the selected
item too.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-29 10:16:51 +02:00
|
|
|
# Returns the list of menu nodes from 'menu' (see _parent_menu()) that
|
|
|
|
# would be shown when entering it
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
def rec(node):
|
menuconfig: Fix a case of visible symbols not being shown
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
78682a8e3c4fe to get the following fix in, which could cause certain
visible symbols to not show up in the menuconfig interface:
menuconfig: Always show implicit submenus with visible nodes
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
parent 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.
(Some other tweaks were made later to avoid showing red outside show-all
mode, because it might look confusing/broken.)
A new color scheme for the menuconfig has been added as well,
contributed by Mitja Horvat (pinkfluid). It can be enabled by setting
the environment variable MENUCONFIG_THEME to 'aquatic'.
The default theme has been tweaked to use bold text for the selected
item too.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-29 10:16:51 +02:00
|
|
|
res = []
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
while node:
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
if _visible(node) or _show_all:
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
res.append(node)
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
if node.list and not node.is_menuconfig:
|
|
|
|
# Nodes from implicit menu created from dependencies. Will
|
|
|
|
# be shown indented. Note that is_menuconfig is True for
|
|
|
|
# menus and choices as well as 'menuconfig' symbols.
|
|
|
|
res += rec(node.list)
|
|
|
|
|
2019-05-06 17:12:27 +02:00
|
|
|
elif node.list and isinstance(node.item, Symbol):
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
# Show invisible symbols if they have visible children. This
|
|
|
|
# can happen for an m/y-valued symbol with an optional prompt
|
2019-05-06 17:12:27 +02:00
|
|
|
# ('prompt "foo" is COND') that is currently disabled. Note
|
|
|
|
# that it applies to both 'config' and 'menuconfig' symbols.
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
shown_children = rec(node.list)
|
|
|
|
if shown_children:
|
|
|
|
res.append(node)
|
|
|
|
if not node.is_menuconfig:
|
|
|
|
res += shown_children
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
node = node.next
|
|
|
|
|
menuconfig: Fix a case of visible symbols not being shown
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
78682a8e3c4fe to get the following fix in, which could cause certain
visible symbols to not show up in the menuconfig interface:
menuconfig: Always show implicit submenus with visible nodes
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
parent 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.
(Some other tweaks were made later to avoid showing red outside show-all
mode, because it might look confusing/broken.)
A new color scheme for the menuconfig has been added as well,
contributed by Mitja Horvat (pinkfluid). It can be enabled by setting
the environment variable MENUCONFIG_THEME to 'aquatic'.
The default theme has been tweaked to use bold text for the selected
item too.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-29 10:16:51 +02:00
|
|
|
return res
|
|
|
|
|
|
|
|
if isinstance(menu.item, Choice):
|
|
|
|
# For named choices defined in multiple locations, entering the choice
|
|
|
|
# at a particular menu node would normally only show the choice symbols
|
|
|
|
# defined there (because that's what the MenuNode tree looks like).
|
|
|
|
#
|
|
|
|
# That might look confusing, and makes extending choices by defining
|
|
|
|
# them in multiple locations less useful. Instead, gather all the child
|
|
|
|
# menu nodes for all the choices whenever a choice is entered. That
|
|
|
|
# makes all choice symbols visible at all locations.
|
|
|
|
#
|
|
|
|
# Choices can contain non-symbol items (people do all sorts of weird
|
|
|
|
# stuff with them), hence the generality here. We really need to
|
|
|
|
# preserve the menu tree at each choice location.
|
|
|
|
#
|
|
|
|
# Note: Named choices are pretty broken in the C tools, and this is
|
|
|
|
# super obscure, so you probably won't find much that relies on this.
|
2018-12-08 05:32:00 +01:00
|
|
|
# This whole 'if' could be deleted if you don't care about defining
|
|
|
|
# choices in multiple locations to add symbols (which will still work,
|
|
|
|
# just with things being displayed in a way that might be unexpected).
|
2018-11-28 15:15:56 +01:00
|
|
|
|
|
|
|
# Do some additional work to avoid listing choice symbols twice if all
|
|
|
|
# or part of the choice is copied in multiple locations (e.g. by
|
|
|
|
# including some Kconfig file multiple times). We give the prompts at
|
|
|
|
# the current location precedence.
|
|
|
|
seen_syms = {node.item for node in rec(menu.list)
|
|
|
|
if isinstance(node.item, Symbol)}
|
|
|
|
res = []
|
|
|
|
for choice_node in menu.item.nodes:
|
|
|
|
for node in rec(choice_node.list):
|
|
|
|
# 'choice_node is menu' checks if we're dealing with the
|
|
|
|
# current location
|
|
|
|
if node.item not in seen_syms or choice_node is menu:
|
|
|
|
res.append(node)
|
|
|
|
if isinstance(node.item, Symbol):
|
|
|
|
seen_syms.add(node.item)
|
|
|
|
return res
|
menuconfig: Fix a case of visible symbols not being shown
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
78682a8e3c4fe to get the following fix in, which could cause certain
visible symbols to not show up in the menuconfig interface:
menuconfig: Always show implicit submenus with visible nodes
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
parent 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.
(Some other tweaks were made later to avoid showing red outside show-all
mode, because it might look confusing/broken.)
A new color scheme for the menuconfig has been added as well,
contributed by Mitja Horvat (pinkfluid). It can be enabled by setting
the environment variable MENUCONFIG_THEME to 'aquatic'.
The default theme has been tweaked to use bold text for the selected
item too.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-29 10:16:51 +02:00
|
|
|
|
|
|
|
return rec(menu.list)
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
|
|
|
def _visible(node):
|
|
|
|
# Returns True if the node should appear in the menu (outside show-all
|
|
|
|
# mode)
|
|
|
|
|
|
|
|
return node.prompt and expr_value(node.prompt[1]) and not \
|
|
|
|
(node.item == MENU and not expr_value(node.visibility))
|
|
|
|
|
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
def _change_node(node):
|
|
|
|
# Changes the value of the menu node 'node' if it is a symbol. Bools and
|
|
|
|
# tristates are toggled, while other symbol types pop up a text entry
|
|
|
|
# dialog.
|
2019-05-06 17:12:27 +02:00
|
|
|
#
|
|
|
|
# Returns False if the value of 'node' can't be changed.
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
2019-05-06 17:12:27 +02:00
|
|
|
if not _changeable(node):
|
|
|
|
return False
|
2018-05-07 13:02:22 +02:00
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
# sc = symbol/choice
|
|
|
|
sc = node.item
|
|
|
|
|
2019-05-06 17:12:27 +02:00
|
|
|
if sc.orig_type in (INT, HEX, STRING):
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
s = sc.str_value
|
|
|
|
|
|
|
|
while True:
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
s = _input_dialog(
|
2019-05-06 17:12:27 +02:00
|
|
|
"{} ({})".format(node.prompt[0], TYPE_TO_STR[sc.orig_type]),
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
s, _range_info(sc))
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
if s is None:
|
|
|
|
break
|
|
|
|
|
2019-05-06 17:12:27 +02:00
|
|
|
if sc.orig_type in (INT, HEX):
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
s = s.strip()
|
|
|
|
|
|
|
|
# 'make menuconfig' does this too. Hex values not starting with
|
|
|
|
# '0x' are accepted when loading .config files though.
|
2019-05-06 17:12:27 +02:00
|
|
|
if sc.orig_type == HEX and not s.startswith(("0x", "0X")):
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
s = "0x" + s
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
if _check_valid(sc, s):
|
2018-05-07 13:02:22 +02:00
|
|
|
_set_val(sc, s)
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
break
|
|
|
|
|
|
|
|
elif len(sc.assignable) == 1:
|
|
|
|
# Handles choice symbols for choices in y mode, which are a special
|
|
|
|
# case: .assignable can be (2,) while .tri_value is 0.
|
2018-05-07 13:02:22 +02:00
|
|
|
_set_val(sc, sc.assignable[0])
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
2019-05-06 17:12:27 +02:00
|
|
|
else:
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
# Set the symbol to the value after the current value in
|
|
|
|
# sc.assignable, with wrapping
|
|
|
|
val_index = sc.assignable.index(sc.tri_value)
|
2018-05-07 13:02:22 +02:00
|
|
|
_set_val(sc, sc.assignable[(val_index + 1) % len(sc.assignable)])
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
2019-05-06 17:12:27 +02:00
|
|
|
if _is_y_mode_choice_sym(sc) and not node.list:
|
|
|
|
# Immediately jump to the parent menu after making a choice selection,
|
|
|
|
# like 'make menuconfig' does, except if the menu node has children
|
|
|
|
# (which can happen if a symbol 'depends on' a choice symbol that
|
|
|
|
# immediately precedes it).
|
|
|
|
_leave_menu()
|
|
|
|
|
|
|
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
def _changeable(node):
|
|
|
|
# Returns True if the value if 'node' can be changed
|
|
|
|
|
|
|
|
sc = node.item
|
|
|
|
|
|
|
|
if not isinstance(sc, (Symbol, Choice)):
|
|
|
|
return False
|
|
|
|
|
|
|
|
# This will hit for invisible symbols, which appear in show-all mode and
|
|
|
|
# when an invisible symbol has visible children (which can happen e.g. for
|
|
|
|
# symbols with optional prompts)
|
|
|
|
if not (node.prompt and expr_value(node.prompt[1])):
|
|
|
|
return False
|
|
|
|
|
|
|
|
return sc.orig_type in (STRING, INT, HEX) or len(sc.assignable) > 1 \
|
|
|
|
or _is_y_mode_choice_sym(sc)
|
|
|
|
|
|
|
|
|
kconfiglib/menuconfig: Add functionality and improve symbol information
Update Kconfiglib and menuconfig to upstream revision 6aea8d06b637e.
Kconfiglib changes:
- Kconfig files are now looked up just relative to $srctree (if set).
Previously, each source'd Kconfig file was also looked up in the
current directory, and Kconfig files there could override Kconfig
files in $srctree. This is what the C tools do.
I'm pretty sure that behavior was a bug in the C tools all along, and
only meant for .config files. It caused problems (and an ugly
workaround) for the undefined Kconfig symbol CI check in an external
project.
The new behavior also saves a bunch of open()'s, though it's probably
not noticeable.
- Setting the KCONFIG_STRICT environment variable to 'y' now makes
Kconfiglib itself warn for references to undefined symbols. This
isn't safe in general, as some projects use multiple Kconfig trees
with shared Kconfig files (e.g. the Linux kernel).
This will be used to simplify the undefined Kconfig symbol CI check.
- It's now possible to customize how symbols and choices are printed
within expressions.
This will be used to make the RST link generation in genrest.py less
hacky.
- Instead of having 'gsource', a plain 'source' is now globbing, and
requires at least one match. There's also 'osource', for when it's
okay for a glob pattern to match no files.
'gsource' had the design flaw that there was no way to require at
least one file to match. I plan on replacing all 'gsource' statements
with plain 'source's later, but 'gsource' is still supported for
backwards compatibility.
- def_int, def_hex, and def_string are now available as a Kconfig
extensions, analogous to def_bool (set type and add default).
- Misc. internal cleanup.
menuconfig changes:
- Boolean value hints are no longer shown to the right of defaults in
the symbol information for int/hex symbols. Stuff like
'- 74 (value: "n")' wasn't helpful, and looked confusing.
- Symbol information has been made more compact in general, e.g. by
skipping value hints where they aren't helpful
('FOO(=y)' instead of 'FOO(=y) (=y)'), and by shortening stuff like
'(value: "y")' to just '(=y)'.
- Misc. internal cleanup.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-10 06:04:23 +02:00
|
|
|
def _set_sel_node_tri_val(tri_val):
|
|
|
|
# Sets the value of the currently selected menu entry to 'tri_val', if that
|
|
|
|
# value can be assigned
|
2018-05-07 13:02:22 +02:00
|
|
|
|
kconfiglib/menuconfig: Add functionality and improve symbol information
Update Kconfiglib and menuconfig to upstream revision 6aea8d06b637e.
Kconfiglib changes:
- Kconfig files are now looked up just relative to $srctree (if set).
Previously, each source'd Kconfig file was also looked up in the
current directory, and Kconfig files there could override Kconfig
files in $srctree. This is what the C tools do.
I'm pretty sure that behavior was a bug in the C tools all along, and
only meant for .config files. It caused problems (and an ugly
workaround) for the undefined Kconfig symbol CI check in an external
project.
The new behavior also saves a bunch of open()'s, though it's probably
not noticeable.
- Setting the KCONFIG_STRICT environment variable to 'y' now makes
Kconfiglib itself warn for references to undefined symbols. This
isn't safe in general, as some projects use multiple Kconfig trees
with shared Kconfig files (e.g. the Linux kernel).
This will be used to simplify the undefined Kconfig symbol CI check.
- It's now possible to customize how symbols and choices are printed
within expressions.
This will be used to make the RST link generation in genrest.py less
hacky.
- Instead of having 'gsource', a plain 'source' is now globbing, and
requires at least one match. There's also 'osource', for when it's
okay for a glob pattern to match no files.
'gsource' had the design flaw that there was no way to require at
least one file to match. I plan on replacing all 'gsource' statements
with plain 'source's later, but 'gsource' is still supported for
backwards compatibility.
- def_int, def_hex, and def_string are now available as a Kconfig
extensions, analogous to def_bool (set type and add default).
- Misc. internal cleanup.
menuconfig changes:
- Boolean value hints are no longer shown to the right of defaults in
the symbol information for int/hex symbols. Stuff like
'- 74 (value: "n")' wasn't helpful, and looked confusing.
- Symbol information has been made more compact in general, e.g. by
skipping value hints where they aren't helpful
('FOO(=y)' instead of 'FOO(=y) (=y)'), and by shortening stuff like
'(value: "y")' to just '(=y)'.
- Misc. internal cleanup.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-10 06:04:23 +02:00
|
|
|
sc = _shown[_sel_node_i].item
|
|
|
|
if isinstance(sc, (Symbol, Choice)) and tri_val in sc.assignable:
|
|
|
|
_set_val(sc, tri_val)
|
2018-05-07 13:02:22 +02:00
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
2018-05-07 13:02:22 +02:00
|
|
|
def _set_val(sc, val):
|
|
|
|
# Wrapper around Symbol/Choice.set_value() for updating the menu state and
|
|
|
|
# _conf_changed
|
|
|
|
|
|
|
|
global _conf_changed
|
|
|
|
|
|
|
|
# Use the string representation of tristate values. This makes the format
|
|
|
|
# consistent for all symbol types.
|
|
|
|
if val in TRI_TO_STR:
|
|
|
|
val = TRI_TO_STR[val]
|
|
|
|
|
|
|
|
if val != sc.str_value:
|
|
|
|
sc.set_value(val)
|
|
|
|
_conf_changed = True
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
2018-05-07 13:02:22 +02:00
|
|
|
# Changing the value of the symbol might have changed what items in the
|
|
|
|
# current menu are visible. Recalculate the state.
|
|
|
|
_update_menu()
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
2018-05-07 13:02:22 +02:00
|
|
|
def _update_menu():
|
|
|
|
# Updates the current menu after the value of a symbol or choice has been
|
|
|
|
# changed. Changing a value might change which items in the menu are
|
|
|
|
# visible.
|
|
|
|
#
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
# If possible, preserves the location of the cursor on the screen when
|
|
|
|
# items are added/removed above the selected item.
|
2018-05-07 13:02:22 +02:00
|
|
|
|
|
|
|
global _shown
|
|
|
|
global _sel_node_i
|
|
|
|
global _menu_scroll
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
# Row on the screen the cursor was on
|
|
|
|
old_row = _sel_node_i - _menu_scroll
|
|
|
|
|
2018-05-07 13:02:22 +02:00
|
|
|
sel_node = _shown[_sel_node_i]
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
# New visible nodes
|
2018-05-07 13:02:22 +02:00
|
|
|
_shown = _shown_nodes(_cur_menu)
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
# New index of selected node
|
2018-05-07 13:02:22 +02:00
|
|
|
_sel_node_i = _shown.index(sel_node)
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
# Try to make the cursor stay on the same row in the menu window. This
|
|
|
|
# might be impossible if too many nodes have disappeared above the node.
|
|
|
|
_menu_scroll = max(_sel_node_i - old_row, 0)
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
def _input_dialog(title, initial_text, info_text=None):
|
|
|
|
# Pops up a dialog that prompts the user for a string
|
|
|
|
#
|
|
|
|
# title:
|
|
|
|
# Title to display at the top of the dialog window's border
|
|
|
|
#
|
|
|
|
# initial_text:
|
|
|
|
# Initial text to prefill the input field with
|
|
|
|
#
|
|
|
|
# info_text:
|
|
|
|
# String to show next to the input field. If None, just the input field
|
|
|
|
# is shown.
|
|
|
|
|
2018-09-15 08:45:50 +02:00
|
|
|
win = _styled_win("body")
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
win.keypad(True)
|
|
|
|
|
2018-05-21 15:48:23 +02:00
|
|
|
info_lines = info_text.split("\n") if info_text else []
|
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
# Give the input dialog its initial size
|
2018-05-21 15:48:23 +02:00
|
|
|
_resize_input_dialog(win, title, info_lines)
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
_safe_curs_set(2)
|
|
|
|
|
|
|
|
# Input field text
|
|
|
|
s = initial_text
|
|
|
|
|
|
|
|
# Cursor position
|
|
|
|
i = len(initial_text)
|
|
|
|
|
2018-05-09 19:11:05 +02:00
|
|
|
def edit_width():
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
return _width(win) - 4
|
2018-05-09 19:11:05 +02:00
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
# Horizontal scroll offset
|
2018-05-09 19:11:05 +02:00
|
|
|
hscroll = max(i - edit_width() + 1, 0)
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
while True:
|
|
|
|
# Draw the "main" display with the menu, etc., so that resizing still
|
|
|
|
# works properly. This is like a stack of windows, only hardcoded for
|
|
|
|
# now.
|
|
|
|
_draw_main()
|
2018-05-21 15:48:23 +02:00
|
|
|
_draw_input_dialog(win, title, info_lines, s, i, hscroll)
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
curses.doupdate()
|
|
|
|
|
|
|
|
|
2019-06-24 08:01:09 +02:00
|
|
|
c = _getch_compat(win)
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
2018-09-15 08:45:50 +02:00
|
|
|
if c == curses.KEY_RESIZE:
|
|
|
|
# Resize the main display too. The dialog floats above it.
|
|
|
|
_resize_main()
|
|
|
|
_resize_input_dialog(win, title, info_lines)
|
|
|
|
|
|
|
|
elif c == "\n":
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
_safe_curs_set(0)
|
|
|
|
return s
|
|
|
|
|
2018-09-15 08:45:50 +02:00
|
|
|
elif c == "\x1B": # \x1B = ESC
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
_safe_curs_set(0)
|
|
|
|
return None
|
|
|
|
|
2021-03-15 14:55:27 +01:00
|
|
|
elif c == "\0": # \0 = NUL, ignore
|
|
|
|
pass
|
|
|
|
|
2018-05-07 13:02:22 +02:00
|
|
|
else:
|
2018-05-09 19:11:05 +02:00
|
|
|
s, i, hscroll = _edit_text(c, s, i, hscroll, edit_width())
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
2018-05-21 15:48:23 +02:00
|
|
|
def _resize_input_dialog(win, title, info_lines):
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
# Resizes the input dialog to a size appropriate for the terminal size
|
|
|
|
|
menuconfig: Fix a case of visible symbols not being shown
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
78682a8e3c4fe to get the following fix in, which could cause certain
visible symbols to not show up in the menuconfig interface:
menuconfig: Always show implicit submenus with visible nodes
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
parent 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.
(Some other tweaks were made later to avoid showing red outside show-all
mode, because it might look confusing/broken.)
A new color scheme for the menuconfig has been added as well,
contributed by Mitja Horvat (pinkfluid). It can be enabled by setting
the environment variable MENUCONFIG_THEME to 'aquatic'.
The default theme has been tweaked to use bold text for the selected
item too.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-29 10:16:51 +02:00
|
|
|
screen_height, screen_width = _stdscr.getmaxyx()
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
2018-05-21 15:48:23 +02:00
|
|
|
win_height = 5
|
|
|
|
if info_lines:
|
|
|
|
win_height += len(info_lines) + 1
|
|
|
|
win_height = min(win_height, screen_height)
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
2018-05-21 15:48:23 +02:00
|
|
|
win_width = max(_INPUT_DIALOG_MIN_WIDTH,
|
|
|
|
len(title) + 4,
|
|
|
|
*(len(line) + 4 for line in info_lines))
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
win_width = min(win_width, screen_width)
|
|
|
|
|
|
|
|
win.resize(win_height, win_width)
|
|
|
|
win.mvwin((screen_height - win_height)//2,
|
|
|
|
(screen_width - win_width)//2)
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
2018-05-21 15:48:23 +02:00
|
|
|
def _draw_input_dialog(win, title, info_lines, s, i, hscroll):
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
edit_width = _width(win) - 4
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
win.erase()
|
|
|
|
|
|
|
|
# Note: Perhaps having a separate window for the input field would be nicer
|
|
|
|
visible_s = s[hscroll:hscroll + edit_width]
|
|
|
|
_safe_addstr(win, 2, 2, visible_s + " "*(edit_width - len(visible_s)),
|
2018-09-15 08:45:50 +02:00
|
|
|
_style["edit"])
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
2018-05-21 15:48:23 +02:00
|
|
|
for linenr, line in enumerate(info_lines):
|
|
|
|
_safe_addstr(win, 4 + linenr, 2, line)
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
2018-09-15 08:45:50 +02:00
|
|
|
# Draw the frame last so that it overwrites the body text for small windows
|
|
|
|
_draw_frame(win, title)
|
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
_safe_move(win, 2, 2 + i - hscroll)
|
|
|
|
|
|
|
|
win.noutrefresh()
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
2018-05-18 10:04:26 +02:00
|
|
|
def _load_dialog():
|
|
|
|
# Dialog for loading a new configuration
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
global _conf_changed
|
|
|
|
global _conf_filename
|
2018-05-18 10:04:26 +02:00
|
|
|
global _show_all
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
if _conf_changed:
|
|
|
|
c = _key_dialog(
|
|
|
|
"Load",
|
|
|
|
"You have unsaved changes. Load new\n"
|
|
|
|
"configuration anyway?\n"
|
|
|
|
"\n"
|
|
|
|
" (O)K (C)ancel",
|
|
|
|
"oc")
|
|
|
|
|
|
|
|
if c is None or c == "c":
|
|
|
|
return
|
|
|
|
|
|
|
|
filename = _conf_filename
|
2018-05-18 10:04:26 +02:00
|
|
|
while True:
|
2018-05-21 15:48:23 +02:00
|
|
|
filename = _input_dialog("File to load", filename, _load_save_info())
|
2018-05-18 10:04:26 +02:00
|
|
|
if filename is None:
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
return
|
2018-05-18 10:04:26 +02:00
|
|
|
|
2018-05-21 15:48:23 +02:00
|
|
|
filename = os.path.expanduser(filename)
|
|
|
|
|
2018-05-18 10:04:26 +02:00
|
|
|
if _try_load(filename):
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
_conf_filename = filename
|
|
|
|
_conf_changed = _needs_save()
|
2018-05-18 10:04:26 +02:00
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
# Turn on show-all mode if the selected node is not visible after
|
|
|
|
# loading the new configuration. _shown still holds the old state.
|
|
|
|
if _shown[_sel_node_i] not in _shown_nodes(_cur_menu):
|
2018-05-18 10:04:26 +02:00
|
|
|
_show_all = True
|
|
|
|
|
|
|
|
_update_menu()
|
|
|
|
|
|
|
|
# The message dialog indirectly updates the menu display, so _msg()
|
|
|
|
# must be called after the new state has been initialized
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
_msg("Success", "Loaded " + filename)
|
|
|
|
return
|
|
|
|
|
2018-05-18 10:04:26 +02:00
|
|
|
|
|
|
|
def _try_load(filename):
|
|
|
|
# Tries to load a configuration file. Pops up an error and returns False on
|
|
|
|
# failure.
|
|
|
|
#
|
|
|
|
# filename:
|
|
|
|
# Configuration file to load
|
|
|
|
|
|
|
|
try:
|
|
|
|
_kconf.load_config(filename)
|
|
|
|
return True
|
2019-09-04 21:48:27 +02:00
|
|
|
except EnvironmentError as e:
|
2018-11-04 01:58:08 +01:00
|
|
|
_error("Error loading '{}'\n\n{} (errno: {})"
|
|
|
|
.format(filename, e.strerror, errno.errorcode[e.errno]))
|
2018-05-18 10:04:26 +02:00
|
|
|
return False
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
def _save_dialog(save_fn, default_filename, description):
|
2018-05-18 10:04:26 +02:00
|
|
|
# Dialog for saving the current configuration
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
#
|
|
|
|
# save_fn:
|
|
|
|
# Function to call with 'filename' to save the file
|
|
|
|
#
|
|
|
|
# default_filename:
|
|
|
|
# Prefilled filename in the input field
|
|
|
|
#
|
|
|
|
# description:
|
|
|
|
# String describing the thing being saved
|
2018-05-07 13:02:22 +02:00
|
|
|
#
|
|
|
|
# Return value:
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
# The path to the saved file, or None if no file was saved
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
filename = default_filename
|
|
|
|
while True:
|
2018-05-21 15:48:23 +02:00
|
|
|
filename = _input_dialog("Filename to save {} to".format(description),
|
kconfiglib/menuconfig: Add functionality and improve symbol information
Update Kconfiglib and menuconfig to upstream revision 6aea8d06b637e.
Kconfiglib changes:
- Kconfig files are now looked up just relative to $srctree (if set).
Previously, each source'd Kconfig file was also looked up in the
current directory, and Kconfig files there could override Kconfig
files in $srctree. This is what the C tools do.
I'm pretty sure that behavior was a bug in the C tools all along, and
only meant for .config files. It caused problems (and an ugly
workaround) for the undefined Kconfig symbol CI check in an external
project.
The new behavior also saves a bunch of open()'s, though it's probably
not noticeable.
- Setting the KCONFIG_STRICT environment variable to 'y' now makes
Kconfiglib itself warn for references to undefined symbols. This
isn't safe in general, as some projects use multiple Kconfig trees
with shared Kconfig files (e.g. the Linux kernel).
This will be used to simplify the undefined Kconfig symbol CI check.
- It's now possible to customize how symbols and choices are printed
within expressions.
This will be used to make the RST link generation in genrest.py less
hacky.
- Instead of having 'gsource', a plain 'source' is now globbing, and
requires at least one match. There's also 'osource', for when it's
okay for a glob pattern to match no files.
'gsource' had the design flaw that there was no way to require at
least one file to match. I plan on replacing all 'gsource' statements
with plain 'source's later, but 'gsource' is still supported for
backwards compatibility.
- def_int, def_hex, and def_string are now available as a Kconfig
extensions, analogous to def_bool (set type and add default).
- Misc. internal cleanup.
menuconfig changes:
- Boolean value hints are no longer shown to the right of defaults in
the symbol information for int/hex symbols. Stuff like
'- 74 (value: "n")' wasn't helpful, and looked confusing.
- Symbol information has been made more compact in general, e.g. by
skipping value hints where they aren't helpful
('FOO(=y)' instead of 'FOO(=y) (=y)'), and by shortening stuff like
'(value: "y")' to just '(=y)'.
- Misc. internal cleanup.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-10 06:04:23 +02:00
|
|
|
filename, _load_save_info())
|
2018-05-07 13:02:22 +02:00
|
|
|
if filename is None:
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
return None
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
2018-05-21 15:48:23 +02:00
|
|
|
filename = os.path.expanduser(filename)
|
|
|
|
|
kconfiglib: Unclutter symbol strings, avoid redundant writes, misc.
Update kconfiglib, menuconfig, and guiconfig to upstream revision
5c904f4549 to get various improvements and fixes in:
- Marc Herbert found an issue involving symlinks, absolute paths,
and rsource that could lead to files not being found. The root cause
was relpath() assuming that symlink/../bar is the same as bar/, which
isn't guaranteed.
Fix it by handling paths in a simpler, more textual way.
- Propagated dependencies from 'depends on' are now stripped from
properties when symbols are printed (e.g. in information dialogs and
generated documentation).
The printed representation now also uses shorthands.
Before:
config A
bool
prompt "foo" if C && D
default A if B && C && D
depends on C && D
After:
config A
bool "foo"
default A if B
depends on C && D
- Before writing a configuration file or header, Kconfiglib now
compares the previous contents of the file against the new contents,
and skips the write if there's no change. This avoids updating the
modification time, and can save work.
A message like "No change to '.config'" is shown when there's no
change.
- .config now has '# end of <menu>' comments to make it easier to see
where a menu ends. This was taken from a change to the C tools.
- load_config() and write_(min_)config() now return a message that can
be printed with print(kconf.load_config()). This allows messages to
be reused in e.g. the configuration interfaces (nice now that there's
also a "No change to..." string).
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-06-03 19:57:27 +02:00
|
|
|
msg = _try_save(save_fn, filename, description)
|
|
|
|
if msg:
|
|
|
|
_msg("Success", msg)
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
return filename
|
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
def _try_save(save_fn, filename, description):
|
kconfiglib: Unclutter symbol strings, avoid redundant writes, misc.
Update kconfiglib, menuconfig, and guiconfig to upstream revision
5c904f4549 to get various improvements and fixes in:
- Marc Herbert found an issue involving symlinks, absolute paths,
and rsource that could lead to files not being found. The root cause
was relpath() assuming that symlink/../bar is the same as bar/, which
isn't guaranteed.
Fix it by handling paths in a simpler, more textual way.
- Propagated dependencies from 'depends on' are now stripped from
properties when symbols are printed (e.g. in information dialogs and
generated documentation).
The printed representation now also uses shorthands.
Before:
config A
bool
prompt "foo" if C && D
default A if B && C && D
depends on C && D
After:
config A
bool "foo"
default A if B
depends on C && D
- Before writing a configuration file or header, Kconfiglib now
compares the previous contents of the file against the new contents,
and skips the write if there's no change. This avoids updating the
modification time, and can save work.
A message like "No change to '.config'" is shown when there's no
change.
- .config now has '# end of <menu>' comments to make it easier to see
where a menu ends. This was taken from a change to the C tools.
- load_config() and write_(min_)config() now return a message that can
be printed with print(kconf.load_config()). This allows messages to
be reused in e.g. the configuration interfaces (nice now that there's
also a "No change to..." string).
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-06-03 19:57:27 +02:00
|
|
|
# Tries to save a configuration file. Returns a message to print on
|
|
|
|
# success.
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
#
|
|
|
|
# save_fn:
|
|
|
|
# Function to call with 'filename' to save the file
|
|
|
|
#
|
|
|
|
# description:
|
|
|
|
# String describing the thing being saved
|
kconfiglib: Unclutter symbol strings, avoid redundant writes, misc.
Update kconfiglib, menuconfig, and guiconfig to upstream revision
5c904f4549 to get various improvements and fixes in:
- Marc Herbert found an issue involving symlinks, absolute paths,
and rsource that could lead to files not being found. The root cause
was relpath() assuming that symlink/../bar is the same as bar/, which
isn't guaranteed.
Fix it by handling paths in a simpler, more textual way.
- Propagated dependencies from 'depends on' are now stripped from
properties when symbols are printed (e.g. in information dialogs and
generated documentation).
The printed representation now also uses shorthands.
Before:
config A
bool
prompt "foo" if C && D
default A if B && C && D
depends on C && D
After:
config A
bool "foo"
default A if B
depends on C && D
- Before writing a configuration file or header, Kconfiglib now
compares the previous contents of the file against the new contents,
and skips the write if there's no change. This avoids updating the
modification time, and can save work.
A message like "No change to '.config'" is shown when there's no
change.
- .config now has '# end of <menu>' comments to make it easier to see
where a menu ends. This was taken from a change to the C tools.
- load_config() and write_(min_)config() now return a message that can
be printed with print(kconf.load_config()). This allows messages to
be reused in e.g. the configuration interfaces (nice now that there's
also a "No change to..." string).
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-06-03 19:57:27 +02:00
|
|
|
#
|
|
|
|
# Return value:
|
|
|
|
# A message to print on success, and None on failure
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
try:
|
kconfiglib: Unclutter symbol strings, avoid redundant writes, misc.
Update kconfiglib, menuconfig, and guiconfig to upstream revision
5c904f4549 to get various improvements and fixes in:
- Marc Herbert found an issue involving symlinks, absolute paths,
and rsource that could lead to files not being found. The root cause
was relpath() assuming that symlink/../bar is the same as bar/, which
isn't guaranteed.
Fix it by handling paths in a simpler, more textual way.
- Propagated dependencies from 'depends on' are now stripped from
properties when symbols are printed (e.g. in information dialogs and
generated documentation).
The printed representation now also uses shorthands.
Before:
config A
bool
prompt "foo" if C && D
default A if B && C && D
depends on C && D
After:
config A
bool "foo"
default A if B
depends on C && D
- Before writing a configuration file or header, Kconfiglib now
compares the previous contents of the file against the new contents,
and skips the write if there's no change. This avoids updating the
modification time, and can save work.
A message like "No change to '.config'" is shown when there's no
change.
- .config now has '# end of <menu>' comments to make it easier to see
where a menu ends. This was taken from a change to the C tools.
- load_config() and write_(min_)config() now return a message that can
be printed with print(kconf.load_config()). This allows messages to
be reused in e.g. the configuration interfaces (nice now that there's
also a "No change to..." string).
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-06-03 19:57:27 +02:00
|
|
|
# save_fn() returns a message to print
|
|
|
|
return save_fn(filename)
|
2019-09-04 21:48:27 +02:00
|
|
|
except EnvironmentError as e:
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
_error("Error saving {} to '{}'\n\n{} (errno: {})"
|
|
|
|
.format(description, e.filename, e.strerror,
|
|
|
|
errno.errorcode[e.errno]))
|
kconfiglib: Unclutter symbol strings, avoid redundant writes, misc.
Update kconfiglib, menuconfig, and guiconfig to upstream revision
5c904f4549 to get various improvements and fixes in:
- Marc Herbert found an issue involving symlinks, absolute paths,
and rsource that could lead to files not being found. The root cause
was relpath() assuming that symlink/../bar is the same as bar/, which
isn't guaranteed.
Fix it by handling paths in a simpler, more textual way.
- Propagated dependencies from 'depends on' are now stripped from
properties when symbols are printed (e.g. in information dialogs and
generated documentation).
The printed representation now also uses shorthands.
Before:
config A
bool
prompt "foo" if C && D
default A if B && C && D
depends on C && D
After:
config A
bool "foo"
default A if B
depends on C && D
- Before writing a configuration file or header, Kconfiglib now
compares the previous contents of the file against the new contents,
and skips the write if there's no change. This avoids updating the
modification time, and can save work.
A message like "No change to '.config'" is shown when there's no
change.
- .config now has '# end of <menu>' comments to make it easier to see
where a menu ends. This was taken from a change to the C tools.
- load_config() and write_(min_)config() now return a message that can
be printed with print(kconf.load_config()). This allows messages to
be reused in e.g. the configuration interfaces (nice now that there's
also a "No change to..." string).
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-06-03 19:57:27 +02:00
|
|
|
return None
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
def _key_dialog(title, text, keys):
|
|
|
|
# Pops up a dialog that can be closed by pressing a key
|
|
|
|
#
|
|
|
|
# title:
|
|
|
|
# Title to display at the top of the dialog window's border
|
|
|
|
#
|
|
|
|
# text:
|
|
|
|
# Text to show in the dialog
|
|
|
|
#
|
|
|
|
# keys:
|
|
|
|
# List of keys that will close the dialog. Other keys (besides ESC) are
|
|
|
|
# ignored. The caller is responsible for providing a hint about which
|
|
|
|
# keys can be pressed in 'text'.
|
|
|
|
#
|
|
|
|
# Return value:
|
|
|
|
# The key that was pressed to close the dialog. Uppercase characters are
|
|
|
|
# converted to lowercase. ESC will always close the dialog, and returns
|
|
|
|
# None.
|
|
|
|
|
2018-09-15 08:45:50 +02:00
|
|
|
win = _styled_win("body")
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
win.keypad(True)
|
|
|
|
|
|
|
|
_resize_key_dialog(win, text)
|
|
|
|
|
|
|
|
while True:
|
|
|
|
# See _input_dialog()
|
|
|
|
_draw_main()
|
|
|
|
_draw_key_dialog(win, title, text)
|
|
|
|
curses.doupdate()
|
|
|
|
|
|
|
|
|
2019-06-24 08:01:09 +02:00
|
|
|
c = _getch_compat(win)
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
if c == curses.KEY_RESIZE:
|
|
|
|
# Resize the main display too. The dialog floats above it.
|
|
|
|
_resize_main()
|
|
|
|
_resize_key_dialog(win, text)
|
|
|
|
|
2018-09-15 08:45:50 +02:00
|
|
|
elif c == "\x1B": # \x1B = ESC
|
|
|
|
return None
|
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
elif isinstance(c, str):
|
|
|
|
c = c.lower()
|
|
|
|
if c in keys:
|
|
|
|
return c
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
def _resize_key_dialog(win, text):
|
|
|
|
# Resizes the key dialog to a size appropriate for the terminal size
|
|
|
|
|
menuconfig: Fix a case of visible symbols not being shown
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
78682a8e3c4fe to get the following fix in, which could cause certain
visible symbols to not show up in the menuconfig interface:
menuconfig: Always show implicit submenus with visible nodes
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
parent 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.
(Some other tweaks were made later to avoid showing red outside show-all
mode, because it might look confusing/broken.)
A new color scheme for the menuconfig has been added as well,
contributed by Mitja Horvat (pinkfluid). It can be enabled by setting
the environment variable MENUCONFIG_THEME to 'aquatic'.
The default theme has been tweaked to use bold text for the selected
item too.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-29 10:16:51 +02:00
|
|
|
screen_height, screen_width = _stdscr.getmaxyx()
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
lines = text.split("\n")
|
|
|
|
|
|
|
|
win_height = min(len(lines) + 4, screen_height)
|
|
|
|
win_width = min(max(len(line) for line in lines) + 4, screen_width)
|
|
|
|
|
|
|
|
win.resize(win_height, win_width)
|
|
|
|
win.mvwin((screen_height - win_height)//2,
|
|
|
|
(screen_width - win_width)//2)
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
def _draw_key_dialog(win, title, text):
|
|
|
|
win.erase()
|
|
|
|
|
|
|
|
for i, line in enumerate(text.split("\n")):
|
|
|
|
_safe_addstr(win, 2 + i, 2, line)
|
|
|
|
|
2018-09-15 08:45:50 +02:00
|
|
|
# Draw the frame last so that it overwrites the body text for small windows
|
|
|
|
_draw_frame(win, title)
|
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
win.noutrefresh()
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
def _draw_frame(win, title):
|
|
|
|
# Draw a frame around the inner edges of 'win', with 'title' at the top
|
|
|
|
|
|
|
|
win_height, win_width = win.getmaxyx()
|
|
|
|
|
2018-09-15 08:45:50 +02:00
|
|
|
win.attron(_style["frame"])
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
# Draw top/bottom edge
|
|
|
|
_safe_hline(win, 0, 0, " ", win_width)
|
|
|
|
_safe_hline(win, win_height - 1, 0, " ", win_width)
|
|
|
|
|
|
|
|
# Draw left/right edge
|
|
|
|
_safe_vline(win, 0, 0, " ", win_height)
|
|
|
|
_safe_vline(win, 0, win_width - 1, " ", win_height)
|
|
|
|
|
|
|
|
# Draw title
|
2018-09-15 08:45:50 +02:00
|
|
|
_safe_addstr(win, 0, max((win_width - len(title))//2, 0), title)
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
2018-09-15 08:45:50 +02:00
|
|
|
win.attroff(_style["frame"])
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
2018-05-07 13:02:22 +02:00
|
|
|
def _jump_to_dialog():
|
2018-06-15 19:30:34 +02:00
|
|
|
# Implements the jump-to dialog, where symbols can be looked up via
|
|
|
|
# incremental search and jumped to.
|
|
|
|
#
|
|
|
|
# Returns True if the user jumped to a symbol, and False if the dialog was
|
|
|
|
# canceled.
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
s = "" # Search text
|
|
|
|
prev_s = None # Previous search text
|
|
|
|
s_i = 0 # Search text cursor position
|
|
|
|
hscroll = 0 # Horizontal scroll offset
|
2018-05-07 13:02:22 +02:00
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
sel_node_i = 0 # Index of selected row
|
|
|
|
scroll = 0 # Index in 'matches' of the top row of the list
|
2018-05-07 13:02:22 +02:00
|
|
|
|
|
|
|
# Edit box at the top
|
2018-09-15 08:45:50 +02:00
|
|
|
edit_box = _styled_win("jump-edit")
|
2018-05-07 13:02:22 +02:00
|
|
|
edit_box.keypad(True)
|
|
|
|
|
|
|
|
# List of matches
|
2018-09-15 08:45:50 +02:00
|
|
|
matches_win = _styled_win("list")
|
2018-05-07 13:02:22 +02:00
|
|
|
|
|
|
|
# Bottom separator, with arrows pointing down
|
2018-09-15 08:45:50 +02:00
|
|
|
bot_sep_win = _styled_win("separator")
|
2018-05-07 13:02:22 +02:00
|
|
|
|
|
|
|
# Help window with instructions at the bottom
|
2018-09-15 08:45:50 +02:00
|
|
|
help_win = _styled_win("help")
|
2018-05-07 13:02:22 +02:00
|
|
|
|
|
|
|
# Give windows their initial size
|
|
|
|
_resize_jump_to_dialog(edit_box, matches_win, bot_sep_win, help_win,
|
|
|
|
sel_node_i, scroll)
|
|
|
|
|
|
|
|
_safe_curs_set(2)
|
|
|
|
|
2019-06-24 08:01:09 +02:00
|
|
|
# Logic duplication with _select_{next,prev}_menu_entry(), except we do a
|
|
|
|
# functional variant that returns the new (sel_node_i, scroll) values to
|
|
|
|
# avoid 'nonlocal'. TODO: Can this be factored out in some nice way?
|
2018-05-07 13:02:22 +02:00
|
|
|
|
|
|
|
def select_next_match():
|
2019-06-24 08:01:09 +02:00
|
|
|
if sel_node_i == len(matches) - 1:
|
|
|
|
return sel_node_i, scroll
|
2018-05-07 13:02:22 +02:00
|
|
|
|
2019-06-24 08:01:09 +02:00
|
|
|
if sel_node_i + 1 >= scroll + _height(matches_win) - _SCROLL_OFFSET \
|
|
|
|
and scroll < _max_scroll(matches, matches_win):
|
2018-05-07 13:02:22 +02:00
|
|
|
|
2019-06-24 08:01:09 +02:00
|
|
|
return sel_node_i + 1, scroll + 1
|
2018-11-17 20:28:09 +01:00
|
|
|
|
2019-06-24 08:01:09 +02:00
|
|
|
return sel_node_i + 1, scroll
|
2018-05-07 13:02:22 +02:00
|
|
|
|
|
|
|
def select_prev_match():
|
2019-06-24 08:01:09 +02:00
|
|
|
if sel_node_i == 0:
|
|
|
|
return sel_node_i, scroll
|
2018-05-07 13:02:22 +02:00
|
|
|
|
2019-06-24 08:01:09 +02:00
|
|
|
if sel_node_i - 1 < scroll + _SCROLL_OFFSET:
|
|
|
|
return sel_node_i - 1, max(scroll - 1, 0)
|
2018-05-07 13:02:22 +02:00
|
|
|
|
2019-06-24 08:01:09 +02:00
|
|
|
return sel_node_i - 1, scroll
|
2018-05-07 13:02:22 +02:00
|
|
|
|
|
|
|
while True:
|
|
|
|
if s != prev_s:
|
|
|
|
# The search text changed. Find new matching nodes.
|
|
|
|
|
|
|
|
prev_s = s
|
|
|
|
|
|
|
|
try:
|
2018-05-21 15:48:23 +02:00
|
|
|
# We could use re.IGNORECASE here instead of lower(), but this
|
|
|
|
# is noticeably less jerky while inputting regexes like
|
|
|
|
# '.*debug$' (though the '.*' is redundant there). Those
|
|
|
|
# probably have bad interactions with re.search(), which
|
|
|
|
# matches anywhere in the string.
|
|
|
|
#
|
|
|
|
# It's not horrible either way. Just a bit smoother.
|
|
|
|
regex_searches = [re.compile(regex).search
|
|
|
|
for regex in s.lower().split()]
|
2018-05-07 13:02:22 +02:00
|
|
|
|
2018-05-11 00:22:32 +02:00
|
|
|
# No exception thrown, so the regexes are okay
|
2018-05-07 13:02:22 +02:00
|
|
|
bad_re = None
|
|
|
|
|
2018-05-21 15:48:23 +02:00
|
|
|
# List of matching nodes
|
2018-05-11 00:22:32 +02:00
|
|
|
matches = []
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
add_match = matches.append
|
2018-05-07 13:02:22 +02:00
|
|
|
|
menuconfig: Add jump-to for choices, menus, and comments
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
bf1701b36634b, to add this commit:
menuconfig: Add jump-to for choices, menus, and comments
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.
Previously, only symbols could be jumped to.
Various other small fixes/improvements are included too:
- The "no range constraints" text was dropped from the input dialog
when settings int/hex symbols without an active 'range'. It might be
more confusing than helpful.
- A crash when pressing Ctrl-F (the view-help shortcut) with no matches
in the jump-to dialog was fixed
- Some gnome-terminal shoddiness was worked around to remove minor
jumpiness when reducing the height of the terminal
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-10-15 02:05:45 +02:00
|
|
|
# Search symbols and choices
|
|
|
|
|
|
|
|
for node in _sorted_sc_nodes():
|
|
|
|
# Symbol/choice
|
|
|
|
sc = node.item
|
|
|
|
|
2018-05-11 00:22:32 +02:00
|
|
|
for search in regex_searches:
|
menuconfig: Add jump-to for choices, menus, and comments
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
bf1701b36634b, to add this commit:
menuconfig: Add jump-to for choices, menus, and comments
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.
Previously, only symbols could be jumped to.
Various other small fixes/improvements are included too:
- The "no range constraints" text was dropped from the input dialog
when settings int/hex symbols without an active 'range'. It might be
more confusing than helpful.
- A crash when pressing Ctrl-F (the view-help shortcut) with no matches
in the jump-to dialog was fixed
- Some gnome-terminal shoddiness was worked around to remove minor
jumpiness when reducing the height of the terminal
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-10-15 02:05:45 +02:00
|
|
|
# Both the name and the prompt might be missing, since
|
|
|
|
# we're searching both symbols and choices
|
|
|
|
|
2018-05-21 15:48:23 +02:00
|
|
|
# Does the regex match either the symbol name or the
|
|
|
|
# prompt (if any)?
|
menuconfig: Add jump-to for choices, menus, and comments
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
bf1701b36634b, to add this commit:
menuconfig: Add jump-to for choices, menus, and comments
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.
Previously, only symbols could be jumped to.
Various other small fixes/improvements are included too:
- The "no range constraints" text was dropped from the input dialog
when settings int/hex symbols without an active 'range'. It might be
more confusing than helpful.
- A crash when pressing Ctrl-F (the view-help shortcut) with no matches
in the jump-to dialog was fixed
- Some gnome-terminal shoddiness was worked around to remove minor
jumpiness when reducing the height of the terminal
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-10-15 02:05:45 +02:00
|
|
|
if not (sc.name and search(sc.name.lower()) or
|
|
|
|
node.prompt and search(node.prompt[0].lower())):
|
2018-05-21 15:48:23 +02:00
|
|
|
|
|
|
|
# Give up on the first regex that doesn't match, to
|
|
|
|
# speed things up a bit when multiple regexes are
|
|
|
|
# entered
|
2018-05-11 00:22:32 +02:00
|
|
|
break
|
2018-05-21 15:48:23 +02:00
|
|
|
|
2018-05-11 00:22:32 +02:00
|
|
|
else:
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
add_match(node)
|
2018-05-07 13:02:22 +02:00
|
|
|
|
menuconfig: Add jump-to for choices, menus, and comments
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
bf1701b36634b, to add this commit:
menuconfig: Add jump-to for choices, menus, and comments
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.
Previously, only symbols could be jumped to.
Various other small fixes/improvements are included too:
- The "no range constraints" text was dropped from the input dialog
when settings int/hex symbols without an active 'range'. It might be
more confusing than helpful.
- A crash when pressing Ctrl-F (the view-help shortcut) with no matches
in the jump-to dialog was fixed
- Some gnome-terminal shoddiness was worked around to remove minor
jumpiness when reducing the height of the terminal
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-10-15 02:05:45 +02:00
|
|
|
# Search menus and comments
|
|
|
|
|
|
|
|
for node in _sorted_menu_comment_nodes():
|
|
|
|
for search in regex_searches:
|
|
|
|
if not search(node.prompt[0].lower()):
|
|
|
|
break
|
|
|
|
else:
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
add_match(node)
|
menuconfig: Add jump-to for choices, menus, and comments
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
bf1701b36634b, to add this commit:
menuconfig: Add jump-to for choices, menus, and comments
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.
Previously, only symbols could be jumped to.
Various other small fixes/improvements are included too:
- The "no range constraints" text was dropped from the input dialog
when settings int/hex symbols without an active 'range'. It might be
more confusing than helpful.
- A crash when pressing Ctrl-F (the view-help shortcut) with no matches
in the jump-to dialog was fixed
- Some gnome-terminal shoddiness was worked around to remove minor
jumpiness when reducing the height of the terminal
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-10-15 02:05:45 +02:00
|
|
|
|
2018-05-07 13:02:22 +02:00
|
|
|
except re.error as e:
|
|
|
|
# Bad regex. Remember the error message so we can show it.
|
2018-05-21 15:48:23 +02:00
|
|
|
bad_re = "Bad regular expression"
|
|
|
|
# re.error.msg was added in Python 3.5
|
|
|
|
if hasattr(e, "msg"):
|
|
|
|
bad_re += ": " + e.msg
|
|
|
|
|
2018-05-07 13:02:22 +02:00
|
|
|
matches = []
|
|
|
|
|
|
|
|
# Reset scroll and jump to the top of the list of matches
|
|
|
|
sel_node_i = scroll = 0
|
|
|
|
|
|
|
|
_draw_jump_to_dialog(edit_box, matches_win, bot_sep_win, help_win,
|
|
|
|
s, s_i, hscroll,
|
|
|
|
bad_re, matches, sel_node_i, scroll)
|
|
|
|
curses.doupdate()
|
|
|
|
|
|
|
|
|
2019-06-24 08:01:09 +02:00
|
|
|
c = _getch_compat(edit_box)
|
2018-05-07 13:02:22 +02:00
|
|
|
|
|
|
|
if c == "\n":
|
2018-05-11 00:22:32 +02:00
|
|
|
if matches:
|
2018-05-21 15:48:23 +02:00
|
|
|
_jump_to(matches[sel_node_i])
|
2018-05-11 00:22:32 +02:00
|
|
|
_safe_curs_set(0)
|
2018-06-15 19:30:34 +02:00
|
|
|
return True
|
2018-05-07 13:02:22 +02:00
|
|
|
|
2018-06-12 10:55:15 +02:00
|
|
|
elif c == "\x1B": # \x1B = ESC
|
2018-05-07 13:02:22 +02:00
|
|
|
_safe_curs_set(0)
|
2018-06-15 19:30:34 +02:00
|
|
|
return False
|
2018-05-07 13:02:22 +02:00
|
|
|
|
2018-06-12 10:55:15 +02:00
|
|
|
elif c == curses.KEY_RESIZE:
|
2018-05-07 13:02:22 +02:00
|
|
|
# We adjust the scroll so that the selected node stays visible in
|
|
|
|
# the list when the terminal is resized, hence the 'scroll'
|
|
|
|
# assignment
|
|
|
|
scroll = _resize_jump_to_dialog(
|
|
|
|
edit_box, matches_win, bot_sep_win, help_win,
|
|
|
|
sel_node_i, scroll)
|
|
|
|
|
2018-06-15 19:30:34 +02:00
|
|
|
elif c == "\x06": # \x06 = Ctrl-F
|
menuconfig: Add jump-to for choices, menus, and comments
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
bf1701b36634b, to add this commit:
menuconfig: Add jump-to for choices, menus, and comments
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.
Previously, only symbols could be jumped to.
Various other small fixes/improvements are included too:
- The "no range constraints" text was dropped from the input dialog
when settings int/hex symbols without an active 'range'. It might be
more confusing than helpful.
- A crash when pressing Ctrl-F (the view-help shortcut) with no matches
in the jump-to dialog was fixed
- Some gnome-terminal shoddiness was worked around to remove minor
jumpiness when reducing the height of the terminal
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-10-15 02:05:45 +02:00
|
|
|
if matches:
|
|
|
|
_safe_curs_set(0)
|
|
|
|
_info_dialog(matches[sel_node_i], True)
|
|
|
|
_safe_curs_set(2)
|
2018-06-15 19:30:34 +02:00
|
|
|
|
menuconfig: Add jump-to for choices, menus, and comments
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
bf1701b36634b, to add this commit:
menuconfig: Add jump-to for choices, menus, and comments
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.
Previously, only symbols could be jumped to.
Various other small fixes/improvements are included too:
- The "no range constraints" text was dropped from the input dialog
when settings int/hex symbols without an active 'range'. It might be
more confusing than helpful.
- A crash when pressing Ctrl-F (the view-help shortcut) with no matches
in the jump-to dialog was fixed
- Some gnome-terminal shoddiness was worked around to remove minor
jumpiness when reducing the height of the terminal
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-10-15 02:05:45 +02:00
|
|
|
scroll = _resize_jump_to_dialog(
|
|
|
|
edit_box, matches_win, bot_sep_win, help_win,
|
|
|
|
sel_node_i, scroll)
|
2018-06-15 19:30:34 +02:00
|
|
|
|
2018-05-07 13:02:22 +02:00
|
|
|
elif c == curses.KEY_DOWN:
|
2019-06-24 08:01:09 +02:00
|
|
|
sel_node_i, scroll = select_next_match()
|
2018-05-07 13:02:22 +02:00
|
|
|
|
|
|
|
elif c == curses.KEY_UP:
|
2019-06-24 08:01:09 +02:00
|
|
|
sel_node_i, scroll = select_prev_match()
|
2018-05-07 13:02:22 +02:00
|
|
|
|
2018-11-17 20:28:09 +01:00
|
|
|
elif c in (curses.KEY_NPAGE, "\x04"): # Page Down/Ctrl-D
|
2018-05-07 13:02:22 +02:00
|
|
|
# Keep it simple. This way we get sane behavior for small windows,
|
|
|
|
# etc., for free.
|
|
|
|
for _ in range(_PG_JUMP):
|
2019-06-24 08:01:09 +02:00
|
|
|
sel_node_i, scroll = select_next_match()
|
2018-05-07 13:02:22 +02:00
|
|
|
|
2018-11-17 20:28:09 +01:00
|
|
|
# Page Up (no Ctrl-U, as it's already used by the edit box)
|
|
|
|
elif c == curses.KEY_PPAGE:
|
2018-05-07 13:02:22 +02:00
|
|
|
for _ in range(_PG_JUMP):
|
2019-06-24 08:01:09 +02:00
|
|
|
sel_node_i, scroll = select_prev_match()
|
2018-05-07 13:02:22 +02:00
|
|
|
|
2018-11-17 20:28:09 +01:00
|
|
|
elif c == curses.KEY_END:
|
|
|
|
sel_node_i = len(matches) - 1
|
|
|
|
scroll = _max_scroll(matches, matches_win)
|
|
|
|
|
|
|
|
elif c == curses.KEY_HOME:
|
|
|
|
sel_node_i = scroll = 0
|
|
|
|
|
2021-03-15 14:55:27 +01:00
|
|
|
elif c == "\0": # \0 = NUL, ignore
|
|
|
|
pass
|
|
|
|
|
2018-05-07 13:02:22 +02:00
|
|
|
else:
|
|
|
|
s, s_i, hscroll = _edit_text(c, s, s_i, hscroll,
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
_width(edit_box) - 2)
|
|
|
|
|
2018-05-07 13:02:22 +02:00
|
|
|
|
menuconfig: Add jump-to for choices, menus, and comments
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
bf1701b36634b, to add this commit:
menuconfig: Add jump-to for choices, menus, and comments
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.
Previously, only symbols could be jumped to.
Various other small fixes/improvements are included too:
- The "no range constraints" text was dropped from the input dialog
when settings int/hex symbols without an active 'range'. It might be
more confusing than helpful.
- A crash when pressing Ctrl-F (the view-help shortcut) with no matches
in the jump-to dialog was fixed
- Some gnome-terminal shoddiness was worked around to remove minor
jumpiness when reducing the height of the terminal
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-10-15 02:05:45 +02:00
|
|
|
# Obscure Python: We never pass a value for cached_nodes, and it keeps pointing
|
|
|
|
# to the same list. This avoids a global.
|
|
|
|
def _sorted_sc_nodes(cached_nodes=[]):
|
|
|
|
# Returns a sorted list of symbol and choice nodes to search. The symbol
|
|
|
|
# nodes appear first, sorted by name, and then the choice nodes, sorted by
|
|
|
|
# prompt and (secondarily) name.
|
2018-05-21 15:48:23 +02:00
|
|
|
|
menuconfig: Add jump-to for choices, menus, and comments
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
bf1701b36634b, to add this commit:
menuconfig: Add jump-to for choices, menus, and comments
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.
Previously, only symbols could be jumped to.
Various other small fixes/improvements are included too:
- The "no range constraints" text was dropped from the input dialog
when settings int/hex symbols without an active 'range'. It might be
more confusing than helpful.
- A crash when pressing Ctrl-F (the view-help shortcut) with no matches
in the jump-to dialog was fixed
- Some gnome-terminal shoddiness was worked around to remove minor
jumpiness when reducing the height of the terminal
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-10-15 02:05:45 +02:00
|
|
|
if not cached_nodes:
|
|
|
|
# Add symbol nodes
|
2018-08-24 01:31:41 +02:00
|
|
|
for sym in sorted(_kconf.unique_defined_syms,
|
|
|
|
key=lambda sym: sym.name):
|
|
|
|
# += is in-place for lists
|
menuconfig: Add jump-to for choices, menus, and comments
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
bf1701b36634b, to add this commit:
menuconfig: Add jump-to for choices, menus, and comments
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.
Previously, only symbols could be jumped to.
Various other small fixes/improvements are included too:
- The "no range constraints" text was dropped from the input dialog
when settings int/hex symbols without an active 'range'. It might be
more confusing than helpful.
- A crash when pressing Ctrl-F (the view-help shortcut) with no matches
in the jump-to dialog was fixed
- Some gnome-terminal shoddiness was worked around to remove minor
jumpiness when reducing the height of the terminal
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-10-15 02:05:45 +02:00
|
|
|
cached_nodes += sym.nodes
|
|
|
|
|
|
|
|
# Add choice nodes
|
|
|
|
|
|
|
|
choices = sorted(_kconf.unique_choices,
|
|
|
|
key=lambda choice: choice.name or "")
|
|
|
|
|
|
|
|
cached_nodes += sorted(
|
2019-10-29 19:32:17 +01:00
|
|
|
[node for choice in choices for node in choice.nodes],
|
menuconfig: Add jump-to for choices, menus, and comments
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
bf1701b36634b, to add this commit:
menuconfig: Add jump-to for choices, menus, and comments
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.
Previously, only symbols could be jumped to.
Various other small fixes/improvements are included too:
- The "no range constraints" text was dropped from the input dialog
when settings int/hex symbols without an active 'range'. It might be
more confusing than helpful.
- A crash when pressing Ctrl-F (the view-help shortcut) with no matches
in the jump-to dialog was fixed
- Some gnome-terminal shoddiness was worked around to remove minor
jumpiness when reducing the height of the terminal
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-10-15 02:05:45 +02:00
|
|
|
key=lambda node: node.prompt[0] if node.prompt else "")
|
|
|
|
|
|
|
|
return cached_nodes
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
menuconfig: Add jump-to for choices, menus, and comments
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
bf1701b36634b, to add this commit:
menuconfig: Add jump-to for choices, menus, and comments
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.
Previously, only symbols could be jumped to.
Various other small fixes/improvements are included too:
- The "no range constraints" text was dropped from the input dialog
when settings int/hex symbols without an active 'range'. It might be
more confusing than helpful.
- A crash when pressing Ctrl-F (the view-help shortcut) with no matches
in the jump-to dialog was fixed
- Some gnome-terminal shoddiness was worked around to remove minor
jumpiness when reducing the height of the terminal
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-10-15 02:05:45 +02:00
|
|
|
def _sorted_menu_comment_nodes(cached_nodes=[]):
|
|
|
|
# Returns a list of menu and comment nodes to search, sorted by prompt,
|
|
|
|
# with the menus first
|
|
|
|
|
|
|
|
if not cached_nodes:
|
|
|
|
def prompt_text(mc):
|
|
|
|
return mc.prompt[0]
|
|
|
|
|
2018-11-17 20:28:09 +01:00
|
|
|
cached_nodes += sorted(_kconf.menus, key=prompt_text)
|
|
|
|
cached_nodes += sorted(_kconf.comments, key=prompt_text)
|
2018-05-11 00:22:32 +02:00
|
|
|
|
menuconfig: Add jump-to for choices, menus, and comments
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
bf1701b36634b, to add this commit:
menuconfig: Add jump-to for choices, menus, and comments
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.
Previously, only symbols could be jumped to.
Various other small fixes/improvements are included too:
- The "no range constraints" text was dropped from the input dialog
when settings int/hex symbols without an active 'range'. It might be
more confusing than helpful.
- A crash when pressing Ctrl-F (the view-help shortcut) with no matches
in the jump-to dialog was fixed
- Some gnome-terminal shoddiness was worked around to remove minor
jumpiness when reducing the height of the terminal
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-10-15 02:05:45 +02:00
|
|
|
return cached_nodes
|
2018-05-11 00:22:32 +02:00
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
2018-05-07 13:02:22 +02:00
|
|
|
def _resize_jump_to_dialog(edit_box, matches_win, bot_sep_win, help_win,
|
|
|
|
sel_node_i, scroll):
|
|
|
|
# Resizes the jump-to dialog to fill the terminal.
|
|
|
|
#
|
|
|
|
# Returns the new scroll index. We adjust the scroll if needed so that the
|
|
|
|
# selected node stays visible.
|
|
|
|
|
menuconfig: Fix a case of visible symbols not being shown
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
78682a8e3c4fe to get the following fix in, which could cause certain
visible symbols to not show up in the menuconfig interface:
menuconfig: Always show implicit submenus with visible nodes
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
parent 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.
(Some other tweaks were made later to avoid showing red outside show-all
mode, because it might look confusing/broken.)
A new color scheme for the menuconfig has been added as well,
contributed by Mitja Horvat (pinkfluid). It can be enabled by setting
the environment variable MENUCONFIG_THEME to 'aquatic'.
The default theme has been tweaked to use bold text for the selected
item too.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-29 10:16:51 +02:00
|
|
|
screen_height, screen_width = _stdscr.getmaxyx()
|
2018-05-07 13:02:22 +02:00
|
|
|
|
|
|
|
bot_sep_win.resize(1, screen_width)
|
|
|
|
|
|
|
|
help_win_height = len(_JUMP_TO_HELP_LINES)
|
|
|
|
matches_win_height = screen_height - help_win_height - 4
|
|
|
|
|
|
|
|
if matches_win_height >= 1:
|
|
|
|
edit_box.resize(3, screen_width)
|
|
|
|
matches_win.resize(matches_win_height, screen_width)
|
|
|
|
help_win.resize(help_win_height, screen_width)
|
|
|
|
|
|
|
|
matches_win.mvwin(3, 0)
|
|
|
|
bot_sep_win.mvwin(3 + matches_win_height, 0)
|
|
|
|
help_win.mvwin(3 + matches_win_height + 1, 0)
|
|
|
|
else:
|
|
|
|
# Degenerate case. Give up on nice rendering and just prevent errors.
|
|
|
|
|
|
|
|
matches_win_height = 1
|
|
|
|
|
|
|
|
edit_box.resize(screen_height, screen_width)
|
|
|
|
matches_win.resize(1, screen_width)
|
|
|
|
help_win.resize(1, screen_width)
|
|
|
|
|
|
|
|
for win in matches_win, bot_sep_win, help_win:
|
|
|
|
win.mvwin(0, 0)
|
|
|
|
|
|
|
|
# Adjust the scroll so that the selected row is still within the window, if
|
|
|
|
# needed
|
|
|
|
if sel_node_i - scroll >= matches_win_height:
|
|
|
|
return sel_node_i - matches_win_height + 1
|
|
|
|
return scroll
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
2018-05-07 13:02:22 +02:00
|
|
|
def _draw_jump_to_dialog(edit_box, matches_win, bot_sep_win, help_win,
|
|
|
|
s, s_i, hscroll,
|
|
|
|
bad_re, matches, sel_node_i, scroll):
|
2018-05-21 15:48:23 +02:00
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
edit_width = _width(edit_box) - 2
|
2018-05-07 13:02:22 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# Update list of matches
|
|
|
|
#
|
|
|
|
|
|
|
|
matches_win.erase()
|
|
|
|
|
2018-05-16 21:05:48 +02:00
|
|
|
if matches:
|
2018-05-07 13:02:22 +02:00
|
|
|
for i in range(scroll,
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
min(scroll + _height(matches_win), len(matches))):
|
2018-05-07 13:02:22 +02:00
|
|
|
|
menuconfig: Add jump-to for choices, menus, and comments
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
bf1701b36634b, to add this commit:
menuconfig: Add jump-to for choices, menus, and comments
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.
Previously, only symbols could be jumped to.
Various other small fixes/improvements are included too:
- The "no range constraints" text was dropped from the input dialog
when settings int/hex symbols without an active 'range'. It might be
more confusing than helpful.
- A crash when pressing Ctrl-F (the view-help shortcut) with no matches
in the jump-to dialog was fixed
- Some gnome-terminal shoddiness was worked around to remove minor
jumpiness when reducing the height of the terminal
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-10-15 02:05:45 +02:00
|
|
|
node = matches[i]
|
2018-05-21 15:48:23 +02:00
|
|
|
|
menuconfig: Add jump-to for choices, menus, and comments
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
bf1701b36634b, to add this commit:
menuconfig: Add jump-to for choices, menus, and comments
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.
Previously, only symbols could be jumped to.
Various other small fixes/improvements are included too:
- The "no range constraints" text was dropped from the input dialog
when settings int/hex symbols without an active 'range'. It might be
more confusing than helpful.
- A crash when pressing Ctrl-F (the view-help shortcut) with no matches
in the jump-to dialog was fixed
- Some gnome-terminal shoddiness was worked around to remove minor
jumpiness when reducing the height of the terminal
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-10-15 02:05:45 +02:00
|
|
|
if isinstance(node.item, (Symbol, Choice)):
|
|
|
|
node_str = _name_and_val_str(node.item)
|
|
|
|
if node.prompt:
|
|
|
|
node_str += ' "{}"'.format(node.prompt[0])
|
|
|
|
elif node.item == MENU:
|
|
|
|
node_str = 'menu "{}"'.format(node.prompt[0])
|
|
|
|
else: # node.item == COMMENT
|
|
|
|
node_str = 'comment "{}"'.format(node.prompt[0])
|
2018-05-21 15:48:23 +02:00
|
|
|
|
menuconfig: Add jump-to for choices, menus, and comments
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
bf1701b36634b, to add this commit:
menuconfig: Add jump-to for choices, menus, and comments
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.
Previously, only symbols could be jumped to.
Various other small fixes/improvements are included too:
- The "no range constraints" text was dropped from the input dialog
when settings int/hex symbols without an active 'range'. It might be
more confusing than helpful.
- A crash when pressing Ctrl-F (the view-help shortcut) with no matches
in the jump-to dialog was fixed
- Some gnome-terminal shoddiness was worked around to remove minor
jumpiness when reducing the height of the terminal
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-10-15 02:05:45 +02:00
|
|
|
_safe_addstr(matches_win, i - scroll, 0, node_str,
|
2018-09-15 08:45:50 +02:00
|
|
|
_style["selection" if i == sel_node_i else "list"])
|
2018-05-07 13:02:22 +02:00
|
|
|
|
2018-05-16 21:05:48 +02:00
|
|
|
else:
|
|
|
|
# bad_re holds the error message from the re.error exception on errors
|
2018-05-21 15:48:23 +02:00
|
|
|
_safe_addstr(matches_win, 0, 0, bad_re or "No matches")
|
2018-05-16 21:05:48 +02:00
|
|
|
|
2018-05-07 13:02:22 +02:00
|
|
|
matches_win.noutrefresh()
|
|
|
|
|
|
|
|
#
|
|
|
|
# Update bottom separator line
|
|
|
|
#
|
|
|
|
|
|
|
|
bot_sep_win.erase()
|
|
|
|
|
|
|
|
# Draw arrows pointing down if the symbol list is scrolled up
|
|
|
|
if scroll < _max_scroll(matches, matches_win):
|
|
|
|
_safe_hline(bot_sep_win, 0, 4, curses.ACS_DARROW, _N_SCROLL_ARROWS)
|
|
|
|
|
|
|
|
bot_sep_win.noutrefresh()
|
|
|
|
|
|
|
|
#
|
|
|
|
# Update help window at bottom
|
|
|
|
#
|
|
|
|
|
|
|
|
help_win.erase()
|
|
|
|
|
|
|
|
for i, line in enumerate(_JUMP_TO_HELP_LINES):
|
|
|
|
_safe_addstr(help_win, i, 0, line)
|
|
|
|
|
|
|
|
help_win.noutrefresh()
|
|
|
|
|
|
|
|
#
|
|
|
|
# Update edit box. We do this last since it makes it handy to position the
|
|
|
|
# cursor.
|
|
|
|
#
|
|
|
|
|
|
|
|
edit_box.erase()
|
|
|
|
|
2018-11-17 20:28:09 +01:00
|
|
|
_draw_frame(edit_box, "Jump to symbol/choice/menu/comment")
|
2018-05-07 13:02:22 +02:00
|
|
|
|
|
|
|
# Draw arrows pointing up if the symbol list is scrolled down
|
|
|
|
if scroll > 0:
|
2018-09-15 08:45:50 +02:00
|
|
|
# TODO: Bit ugly that _style["frame"] is repeated here
|
2018-05-07 13:02:22 +02:00
|
|
|
_safe_hline(edit_box, 2, 4, curses.ACS_UARROW, _N_SCROLL_ARROWS,
|
2018-09-15 08:45:50 +02:00
|
|
|
_style["frame"])
|
2018-05-07 13:02:22 +02:00
|
|
|
|
|
|
|
visible_s = s[hscroll:hscroll + edit_width]
|
menuconfig: Fix a case of visible symbols not being shown
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
78682a8e3c4fe to get the following fix in, which could cause certain
visible symbols to not show up in the menuconfig interface:
menuconfig: Always show implicit submenus with visible nodes
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
parent 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.
(Some other tweaks were made later to avoid showing red outside show-all
mode, because it might look confusing/broken.)
A new color scheme for the menuconfig has been added as well,
contributed by Mitja Horvat (pinkfluid). It can be enabled by setting
the environment variable MENUCONFIG_THEME to 'aquatic'.
The default theme has been tweaked to use bold text for the selected
item too.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-29 10:16:51 +02:00
|
|
|
_safe_addstr(edit_box, 1, 1, visible_s)
|
2018-05-07 13:02:22 +02:00
|
|
|
|
|
|
|
_safe_move(edit_box, 1, 1 + s_i - hscroll)
|
|
|
|
|
|
|
|
edit_box.noutrefresh()
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
2018-06-15 19:30:34 +02:00
|
|
|
def _info_dialog(node, from_jump_to_dialog):
|
|
|
|
# Shows a fullscreen window with information about 'node'.
|
|
|
|
#
|
|
|
|
# If 'from_jump_to_dialog' is True, the information dialog was opened from
|
|
|
|
# within the jump-to-dialog. In this case, we make '/' from within the
|
|
|
|
# information dialog just return, to avoid a confusing recursive invocation
|
|
|
|
# of the jump-to-dialog.
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
# Top row, with title and arrows point up
|
2018-09-15 08:45:50 +02:00
|
|
|
top_line_win = _styled_win("separator")
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
# Text display
|
2018-09-15 08:45:50 +02:00
|
|
|
text_win = _styled_win("text")
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
text_win.keypad(True)
|
|
|
|
|
|
|
|
# Bottom separator, with arrows pointing down
|
2018-09-15 08:45:50 +02:00
|
|
|
bot_sep_win = _styled_win("separator")
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
# Help window with keys at the bottom
|
2018-09-15 08:45:50 +02:00
|
|
|
help_win = _styled_win("help")
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
# Give windows their initial size
|
2018-05-07 13:02:22 +02:00
|
|
|
_resize_info_dialog(top_line_win, text_win, bot_sep_win, help_win)
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
|
|
|
|
# Get lines of help text
|
2018-05-07 13:02:22 +02:00
|
|
|
lines = _info_str(node).split("\n")
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
# Index of first row in 'lines' to show
|
|
|
|
scroll = 0
|
|
|
|
|
|
|
|
while True:
|
2018-05-07 13:02:22 +02:00
|
|
|
_draw_info_dialog(node, lines, scroll, top_line_win, text_win,
|
|
|
|
bot_sep_win, help_win)
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
curses.doupdate()
|
|
|
|
|
|
|
|
|
2019-06-24 08:01:09 +02:00
|
|
|
c = _getch_compat(text_win)
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
if c == curses.KEY_RESIZE:
|
2018-05-07 13:02:22 +02:00
|
|
|
_resize_info_dialog(top_line_win, text_win, bot_sep_win, help_win)
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
elif c in (curses.KEY_DOWN, "j", "J"):
|
2018-05-07 13:02:22 +02:00
|
|
|
if scroll < _max_scroll(lines, text_win):
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
scroll += 1
|
|
|
|
|
|
|
|
elif c in (curses.KEY_NPAGE, "\x04"): # Page Down/Ctrl-D
|
2018-05-07 13:02:22 +02:00
|
|
|
scroll = min(scroll + _PG_JUMP, _max_scroll(lines, text_win))
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
elif c in (curses.KEY_PPAGE, "\x15"): # Page Up/Ctrl-U
|
|
|
|
scroll = max(scroll - _PG_JUMP, 0)
|
|
|
|
|
|
|
|
elif c in (curses.KEY_END, "G"):
|
2018-05-07 13:02:22 +02:00
|
|
|
scroll = _max_scroll(lines, text_win)
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
elif c in (curses.KEY_HOME, "g"):
|
|
|
|
scroll = 0
|
|
|
|
|
|
|
|
elif c in (curses.KEY_UP, "k", "K"):
|
|
|
|
if scroll > 0:
|
|
|
|
scroll -= 1
|
|
|
|
|
2018-06-15 19:30:34 +02:00
|
|
|
elif c == "/":
|
|
|
|
# Support starting a search from within the information dialog
|
|
|
|
|
|
|
|
if from_jump_to_dialog:
|
2020-01-13 10:38:45 +01:00
|
|
|
return # Avoid recursion
|
2018-06-15 19:30:34 +02:00
|
|
|
|
|
|
|
if _jump_to_dialog():
|
2020-01-13 10:38:45 +01:00
|
|
|
return # Jumped to a symbol. Cancel the information dialog.
|
2018-06-15 19:30:34 +02:00
|
|
|
|
|
|
|
# Stay in the information dialog if the jump-to dialog was
|
|
|
|
# canceled. Resize it in case the terminal was resized while the
|
|
|
|
# fullscreen jump-to dialog was open.
|
|
|
|
_resize_info_dialog(top_line_win, text_win, bot_sep_win, help_win)
|
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
elif c in (curses.KEY_LEFT, curses.KEY_BACKSPACE, _ERASE_CHAR,
|
|
|
|
"\x1B", # \x1B = ESC
|
|
|
|
"q", "Q", "h", "H"):
|
|
|
|
|
|
|
|
return
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
2018-05-07 13:02:22 +02:00
|
|
|
def _resize_info_dialog(top_line_win, text_win, bot_sep_win, help_win):
|
|
|
|
# Resizes the info dialog to fill the terminal
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
menuconfig: Fix a case of visible symbols not being shown
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
78682a8e3c4fe to get the following fix in, which could cause certain
visible symbols to not show up in the menuconfig interface:
menuconfig: Always show implicit submenus with visible nodes
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
parent 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.
(Some other tweaks were made later to avoid showing red outside show-all
mode, because it might look confusing/broken.)
A new color scheme for the menuconfig has been added as well,
contributed by Mitja Horvat (pinkfluid). It can be enabled by setting
the environment variable MENUCONFIG_THEME to 'aquatic'.
The default theme has been tweaked to use bold text for the selected
item too.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-29 10:16:51 +02:00
|
|
|
screen_height, screen_width = _stdscr.getmaxyx()
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
top_line_win.resize(1, screen_width)
|
|
|
|
bot_sep_win.resize(1, screen_width)
|
|
|
|
|
|
|
|
help_win_height = len(_INFO_HELP_LINES)
|
|
|
|
text_win_height = screen_height - help_win_height - 2
|
|
|
|
|
|
|
|
if text_win_height >= 1:
|
|
|
|
text_win.resize(text_win_height, screen_width)
|
|
|
|
help_win.resize(help_win_height, screen_width)
|
|
|
|
|
|
|
|
text_win.mvwin(1, 0)
|
|
|
|
bot_sep_win.mvwin(1 + text_win_height, 0)
|
|
|
|
help_win.mvwin(1 + text_win_height + 1, 0)
|
|
|
|
else:
|
|
|
|
# Degenerate case. Give up on nice rendering and just prevent errors.
|
|
|
|
|
|
|
|
text_win.resize(1, screen_width)
|
|
|
|
help_win.resize(1, screen_width)
|
|
|
|
|
|
|
|
for win in text_win, bot_sep_win, help_win:
|
|
|
|
win.mvwin(0, 0)
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
2018-05-07 13:02:22 +02:00
|
|
|
def _draw_info_dialog(node, lines, scroll, top_line_win, text_win,
|
|
|
|
bot_sep_win, help_win):
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
text_win_height, text_win_width = text_win.getmaxyx()
|
|
|
|
|
menuconfig: Add jump-to for choices, menus, and comments
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
bf1701b36634b, to add this commit:
menuconfig: Add jump-to for choices, menus, and comments
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.
Previously, only symbols could be jumped to.
Various other small fixes/improvements are included too:
- The "no range constraints" text was dropped from the input dialog
when settings int/hex symbols without an active 'range'. It might be
more confusing than helpful.
- A crash when pressing Ctrl-F (the view-help shortcut) with no matches
in the jump-to dialog was fixed
- Some gnome-terminal shoddiness was worked around to remove minor
jumpiness when reducing the height of the terminal
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-10-15 02:05:45 +02:00
|
|
|
# Note: The top row is deliberately updated last. See _draw_main().
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# Update text display
|
|
|
|
#
|
|
|
|
|
|
|
|
text_win.erase()
|
|
|
|
|
|
|
|
for i, line in enumerate(lines[scroll:scroll + text_win_height]):
|
|
|
|
_safe_addstr(text_win, i, 0, line)
|
|
|
|
|
|
|
|
text_win.noutrefresh()
|
|
|
|
|
|
|
|
#
|
|
|
|
# Update bottom separator line
|
|
|
|
#
|
|
|
|
|
|
|
|
bot_sep_win.erase()
|
|
|
|
|
|
|
|
# Draw arrows pointing down if the symbol window is scrolled up
|
2018-05-07 13:02:22 +02:00
|
|
|
if scroll < _max_scroll(lines, text_win):
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
_safe_hline(bot_sep_win, 0, 4, curses.ACS_DARROW, _N_SCROLL_ARROWS)
|
|
|
|
|
|
|
|
bot_sep_win.noutrefresh()
|
|
|
|
|
|
|
|
#
|
|
|
|
# Update help window at bottom
|
|
|
|
#
|
|
|
|
|
|
|
|
help_win.erase()
|
|
|
|
|
|
|
|
for i, line in enumerate(_INFO_HELP_LINES):
|
|
|
|
_safe_addstr(help_win, i, 0, line)
|
|
|
|
|
|
|
|
help_win.noutrefresh()
|
|
|
|
|
menuconfig: Add jump-to for choices, menus, and comments
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
bf1701b36634b, to add this commit:
menuconfig: Add jump-to for choices, menus, and comments
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.
Previously, only symbols could be jumped to.
Various other small fixes/improvements are included too:
- The "no range constraints" text was dropped from the input dialog
when settings int/hex symbols without an active 'range'. It might be
more confusing than helpful.
- A crash when pressing Ctrl-F (the view-help shortcut) with no matches
in the jump-to dialog was fixed
- Some gnome-terminal shoddiness was worked around to remove minor
jumpiness when reducing the height of the terminal
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-10-15 02:05:45 +02:00
|
|
|
#
|
|
|
|
# Update top row
|
|
|
|
#
|
|
|
|
|
|
|
|
top_line_win.erase()
|
|
|
|
|
|
|
|
# Draw arrows pointing up if the information window is scrolled down. Draw
|
|
|
|
# them before drawing the title, so the title ends up on top for small
|
|
|
|
# windows.
|
|
|
|
if scroll > 0:
|
|
|
|
_safe_hline(top_line_win, 0, 4, curses.ACS_UARROW, _N_SCROLL_ARROWS)
|
|
|
|
|
|
|
|
title = ("Symbol" if isinstance(node.item, Symbol) else
|
|
|
|
"Choice" if isinstance(node.item, Choice) else
|
|
|
|
"Menu" if node.item == MENU else
|
|
|
|
"Comment") + " information"
|
|
|
|
_safe_addstr(top_line_win, 0, max((text_win_width - len(title))//2, 0),
|
|
|
|
title)
|
|
|
|
|
|
|
|
top_line_win.noutrefresh()
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
2018-05-07 13:02:22 +02:00
|
|
|
def _info_str(node):
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
# Returns information about the menu node 'node' as a string.
|
|
|
|
#
|
|
|
|
# The helper functions are responsible for adding newlines. This allows
|
|
|
|
# them to return "" if they don't want to add any output.
|
|
|
|
|
|
|
|
if isinstance(node.item, Symbol):
|
|
|
|
sym = node.item
|
|
|
|
|
|
|
|
return (
|
2018-05-25 20:12:25 +02:00
|
|
|
_name_info(sym) +
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
_prompt_info(sym) +
|
|
|
|
"Type: {}\n".format(TYPE_TO_STR[sym.type]) +
|
kconfiglib/menuconfig: Add functionality and improve symbol information
Update Kconfiglib and menuconfig to upstream revision 6aea8d06b637e.
Kconfiglib changes:
- Kconfig files are now looked up just relative to $srctree (if set).
Previously, each source'd Kconfig file was also looked up in the
current directory, and Kconfig files there could override Kconfig
files in $srctree. This is what the C tools do.
I'm pretty sure that behavior was a bug in the C tools all along, and
only meant for .config files. It caused problems (and an ugly
workaround) for the undefined Kconfig symbol CI check in an external
project.
The new behavior also saves a bunch of open()'s, though it's probably
not noticeable.
- Setting the KCONFIG_STRICT environment variable to 'y' now makes
Kconfiglib itself warn for references to undefined symbols. This
isn't safe in general, as some projects use multiple Kconfig trees
with shared Kconfig files (e.g. the Linux kernel).
This will be used to simplify the undefined Kconfig symbol CI check.
- It's now possible to customize how symbols and choices are printed
within expressions.
This will be used to make the RST link generation in genrest.py less
hacky.
- Instead of having 'gsource', a plain 'source' is now globbing, and
requires at least one match. There's also 'osource', for when it's
okay for a glob pattern to match no files.
'gsource' had the design flaw that there was no way to require at
least one file to match. I plan on replacing all 'gsource' statements
with plain 'source's later, but 'gsource' is still supported for
backwards compatibility.
- def_int, def_hex, and def_string are now available as a Kconfig
extensions, analogous to def_bool (set type and add default).
- Misc. internal cleanup.
menuconfig changes:
- Boolean value hints are no longer shown to the right of defaults in
the symbol information for int/hex symbols. Stuff like
'- 74 (value: "n")' wasn't helpful, and looked confusing.
- Symbol information has been made more compact in general, e.g. by
skipping value hints where they aren't helpful
('FOO(=y)' instead of 'FOO(=y) (=y)'), and by shortening stuff like
'(value: "y")' to just '(=y)'.
- Misc. internal cleanup.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-10 06:04:23 +02:00
|
|
|
_value_info(sym) +
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
_help_info(sym) +
|
|
|
|
_direct_dep_info(sym) +
|
|
|
|
_defaults_info(sym) +
|
|
|
|
_select_imply_info(sym) +
|
|
|
|
_kconfig_def_info(sym)
|
|
|
|
)
|
|
|
|
|
|
|
|
if isinstance(node.item, Choice):
|
|
|
|
choice = node.item
|
|
|
|
|
|
|
|
return (
|
2018-05-25 20:12:25 +02:00
|
|
|
_name_info(choice) +
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
_prompt_info(choice) +
|
|
|
|
"Type: {}\n".format(TYPE_TO_STR[choice.type]) +
|
kconfiglib/menuconfig: Add functionality and improve symbol information
Update Kconfiglib and menuconfig to upstream revision 6aea8d06b637e.
Kconfiglib changes:
- Kconfig files are now looked up just relative to $srctree (if set).
Previously, each source'd Kconfig file was also looked up in the
current directory, and Kconfig files there could override Kconfig
files in $srctree. This is what the C tools do.
I'm pretty sure that behavior was a bug in the C tools all along, and
only meant for .config files. It caused problems (and an ugly
workaround) for the undefined Kconfig symbol CI check in an external
project.
The new behavior also saves a bunch of open()'s, though it's probably
not noticeable.
- Setting the KCONFIG_STRICT environment variable to 'y' now makes
Kconfiglib itself warn for references to undefined symbols. This
isn't safe in general, as some projects use multiple Kconfig trees
with shared Kconfig files (e.g. the Linux kernel).
This will be used to simplify the undefined Kconfig symbol CI check.
- It's now possible to customize how symbols and choices are printed
within expressions.
This will be used to make the RST link generation in genrest.py less
hacky.
- Instead of having 'gsource', a plain 'source' is now globbing, and
requires at least one match. There's also 'osource', for when it's
okay for a glob pattern to match no files.
'gsource' had the design flaw that there was no way to require at
least one file to match. I plan on replacing all 'gsource' statements
with plain 'source's later, but 'gsource' is still supported for
backwards compatibility.
- def_int, def_hex, and def_string are now available as a Kconfig
extensions, analogous to def_bool (set type and add default).
- Misc. internal cleanup.
menuconfig changes:
- Boolean value hints are no longer shown to the right of defaults in
the symbol information for int/hex symbols. Stuff like
'- 74 (value: "n")' wasn't helpful, and looked confusing.
- Symbol information has been made more compact in general, e.g. by
skipping value hints where they aren't helpful
('FOO(=y)' instead of 'FOO(=y) (=y)'), and by shortening stuff like
'(value: "y")' to just '(=y)'.
- Misc. internal cleanup.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-10 06:04:23 +02:00
|
|
|
'Mode: {}\n'.format(choice.str_value) +
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
_help_info(choice) +
|
|
|
|
_choice_syms_info(choice) +
|
|
|
|
_direct_dep_info(choice) +
|
|
|
|
_defaults_info(choice) +
|
|
|
|
_kconfig_def_info(choice)
|
|
|
|
)
|
|
|
|
|
2020-01-13 10:38:45 +01:00
|
|
|
return _kconfig_def_info(node) # node.item in (MENU, COMMENT)
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
2018-05-25 20:12:25 +02:00
|
|
|
def _name_info(sc):
|
|
|
|
# Returns a string with the name of the symbol/choice. Names are optional
|
|
|
|
# for choices.
|
|
|
|
|
|
|
|
return "Name: {}\n".format(sc.name) if sc.name else ""
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
def _prompt_info(sc):
|
|
|
|
# Returns a string listing the prompts of 'sc' (Symbol or Choice)
|
|
|
|
|
|
|
|
s = ""
|
|
|
|
|
|
|
|
for node in sc.nodes:
|
|
|
|
if node.prompt:
|
|
|
|
s += "Prompt: {}\n".format(node.prompt[0])
|
|
|
|
|
|
|
|
return s
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
kconfiglib/menuconfig: Add functionality and improve symbol information
Update Kconfiglib and menuconfig to upstream revision 6aea8d06b637e.
Kconfiglib changes:
- Kconfig files are now looked up just relative to $srctree (if set).
Previously, each source'd Kconfig file was also looked up in the
current directory, and Kconfig files there could override Kconfig
files in $srctree. This is what the C tools do.
I'm pretty sure that behavior was a bug in the C tools all along, and
only meant for .config files. It caused problems (and an ugly
workaround) for the undefined Kconfig symbol CI check in an external
project.
The new behavior also saves a bunch of open()'s, though it's probably
not noticeable.
- Setting the KCONFIG_STRICT environment variable to 'y' now makes
Kconfiglib itself warn for references to undefined symbols. This
isn't safe in general, as some projects use multiple Kconfig trees
with shared Kconfig files (e.g. the Linux kernel).
This will be used to simplify the undefined Kconfig symbol CI check.
- It's now possible to customize how symbols and choices are printed
within expressions.
This will be used to make the RST link generation in genrest.py less
hacky.
- Instead of having 'gsource', a plain 'source' is now globbing, and
requires at least one match. There's also 'osource', for when it's
okay for a glob pattern to match no files.
'gsource' had the design flaw that there was no way to require at
least one file to match. I plan on replacing all 'gsource' statements
with plain 'source's later, but 'gsource' is still supported for
backwards compatibility.
- def_int, def_hex, and def_string are now available as a Kconfig
extensions, analogous to def_bool (set type and add default).
- Misc. internal cleanup.
menuconfig changes:
- Boolean value hints are no longer shown to the right of defaults in
the symbol information for int/hex symbols. Stuff like
'- 74 (value: "n")' wasn't helpful, and looked confusing.
- Symbol information has been made more compact in general, e.g. by
skipping value hints where they aren't helpful
('FOO(=y)' instead of 'FOO(=y) (=y)'), and by shortening stuff like
'(value: "y")' to just '(=y)'.
- Misc. internal cleanup.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-10 06:04:23 +02:00
|
|
|
def _value_info(sym):
|
|
|
|
# Returns a string showing 'sym's value
|
|
|
|
|
|
|
|
# Only put quotes around the value for string symbols
|
|
|
|
return "Value: {}\n".format(
|
|
|
|
'"{}"'.format(sym.str_value)
|
|
|
|
if sym.orig_type == STRING
|
|
|
|
else sym.str_value)
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
def _choice_syms_info(choice):
|
|
|
|
# Returns a string listing the choice symbols in 'choice'. Adds
|
|
|
|
# "(selected)" next to the selected one.
|
|
|
|
|
|
|
|
s = "Choice symbols:\n"
|
|
|
|
|
|
|
|
for sym in choice.syms:
|
|
|
|
s += " - " + sym.name
|
|
|
|
if sym is choice.selection:
|
|
|
|
s += " (selected)"
|
|
|
|
s += "\n"
|
|
|
|
|
|
|
|
return s + "\n"
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
def _help_info(sc):
|
|
|
|
# Returns a string with the help text(s) of 'sc' (Symbol or Choice).
|
|
|
|
# Symbols and choices defined in multiple locations can have multiple help
|
|
|
|
# texts.
|
|
|
|
|
kconfiglib/menuconfig: Add functionality and improve symbol information
Update Kconfiglib and menuconfig to upstream revision 6aea8d06b637e.
Kconfiglib changes:
- Kconfig files are now looked up just relative to $srctree (if set).
Previously, each source'd Kconfig file was also looked up in the
current directory, and Kconfig files there could override Kconfig
files in $srctree. This is what the C tools do.
I'm pretty sure that behavior was a bug in the C tools all along, and
only meant for .config files. It caused problems (and an ugly
workaround) for the undefined Kconfig symbol CI check in an external
project.
The new behavior also saves a bunch of open()'s, though it's probably
not noticeable.
- Setting the KCONFIG_STRICT environment variable to 'y' now makes
Kconfiglib itself warn for references to undefined symbols. This
isn't safe in general, as some projects use multiple Kconfig trees
with shared Kconfig files (e.g. the Linux kernel).
This will be used to simplify the undefined Kconfig symbol CI check.
- It's now possible to customize how symbols and choices are printed
within expressions.
This will be used to make the RST link generation in genrest.py less
hacky.
- Instead of having 'gsource', a plain 'source' is now globbing, and
requires at least one match. There's also 'osource', for when it's
okay for a glob pattern to match no files.
'gsource' had the design flaw that there was no way to require at
least one file to match. I plan on replacing all 'gsource' statements
with plain 'source's later, but 'gsource' is still supported for
backwards compatibility.
- def_int, def_hex, and def_string are now available as a Kconfig
extensions, analogous to def_bool (set type and add default).
- Misc. internal cleanup.
menuconfig changes:
- Boolean value hints are no longer shown to the right of defaults in
the symbol information for int/hex symbols. Stuff like
'- 74 (value: "n")' wasn't helpful, and looked confusing.
- Symbol information has been made more compact in general, e.g. by
skipping value hints where they aren't helpful
('FOO(=y)' instead of 'FOO(=y) (=y)'), and by shortening stuff like
'(value: "y")' to just '(=y)'.
- Misc. internal cleanup.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-10 06:04:23 +02:00
|
|
|
s = "\n"
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
for node in sc.nodes:
|
|
|
|
if node.help is not None:
|
2019-06-24 08:01:09 +02:00
|
|
|
s += "Help:\n\n{}\n\n".format(_indent(node.help, 2))
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
return s
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
def _direct_dep_info(sc):
|
|
|
|
# Returns a string describing the direct dependencies of 'sc' (Symbol or
|
|
|
|
# Choice). The direct dependencies are the OR of the dependencies from each
|
|
|
|
# definition location. The dependencies at each definition location come
|
|
|
|
# from 'depends on' and dependencies inherited from parent items.
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
return "" if sc.direct_dep is _kconf.y else \
|
|
|
|
'Direct dependencies (={}):\n{}\n' \
|
|
|
|
.format(TRI_TO_STR[expr_value(sc.direct_dep)],
|
|
|
|
_split_expr_info(sc.direct_dep, 2))
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
|
|
|
|
def _defaults_info(sc):
|
|
|
|
# Returns a string describing the defaults of 'sc' (Symbol or Choice)
|
|
|
|
|
|
|
|
if not sc.defaults:
|
|
|
|
return ""
|
|
|
|
|
2019-09-04 21:48:27 +02:00
|
|
|
s = "Default"
|
|
|
|
if len(sc.defaults) > 1:
|
|
|
|
s += "s"
|
|
|
|
s += ":\n"
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
2019-06-24 08:01:09 +02:00
|
|
|
for val, cond in sc.orig_defaults:
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
s += " - "
|
|
|
|
if isinstance(sc, Symbol):
|
kconfiglib/menuconfig: Add functionality and improve symbol information
Update Kconfiglib and menuconfig to upstream revision 6aea8d06b637e.
Kconfiglib changes:
- Kconfig files are now looked up just relative to $srctree (if set).
Previously, each source'd Kconfig file was also looked up in the
current directory, and Kconfig files there could override Kconfig
files in $srctree. This is what the C tools do.
I'm pretty sure that behavior was a bug in the C tools all along, and
only meant for .config files. It caused problems (and an ugly
workaround) for the undefined Kconfig symbol CI check in an external
project.
The new behavior also saves a bunch of open()'s, though it's probably
not noticeable.
- Setting the KCONFIG_STRICT environment variable to 'y' now makes
Kconfiglib itself warn for references to undefined symbols. This
isn't safe in general, as some projects use multiple Kconfig trees
with shared Kconfig files (e.g. the Linux kernel).
This will be used to simplify the undefined Kconfig symbol CI check.
- It's now possible to customize how symbols and choices are printed
within expressions.
This will be used to make the RST link generation in genrest.py less
hacky.
- Instead of having 'gsource', a plain 'source' is now globbing, and
requires at least one match. There's also 'osource', for when it's
okay for a glob pattern to match no files.
'gsource' had the design flaw that there was no way to require at
least one file to match. I plan on replacing all 'gsource' statements
with plain 'source's later, but 'gsource' is still supported for
backwards compatibility.
- def_int, def_hex, and def_string are now available as a Kconfig
extensions, analogous to def_bool (set type and add default).
- Misc. internal cleanup.
menuconfig changes:
- Boolean value hints are no longer shown to the right of defaults in
the symbol information for int/hex symbols. Stuff like
'- 74 (value: "n")' wasn't helpful, and looked confusing.
- Symbol information has been made more compact in general, e.g. by
skipping value hints where they aren't helpful
('FOO(=y)' instead of 'FOO(=y) (=y)'), and by shortening stuff like
'(value: "y")' to just '(=y)'.
- Misc. internal cleanup.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-10 06:04:23 +02:00
|
|
|
s += _expr_str(val)
|
|
|
|
|
menuconfig: Fix a case of visible symbols not being shown
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
78682a8e3c4fe to get the following fix in, which could cause certain
visible symbols to not show up in the menuconfig interface:
menuconfig: Always show implicit submenus with visible nodes
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
parent 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.
(Some other tweaks were made later to avoid showing red outside show-all
mode, because it might look confusing/broken.)
A new color scheme for the menuconfig has been added as well,
contributed by Mitja Horvat (pinkfluid). It can be enabled by setting
the environment variable MENUCONFIG_THEME to 'aquatic'.
The default theme has been tweaked to use bold text for the selected
item too.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-29 10:16:51 +02:00
|
|
|
# Skip the tristate value hint if the expression is just a single
|
|
|
|
# symbol. _expr_str() already shows its value as a string.
|
kconfiglib/menuconfig: Add functionality and improve symbol information
Update Kconfiglib and menuconfig to upstream revision 6aea8d06b637e.
Kconfiglib changes:
- Kconfig files are now looked up just relative to $srctree (if set).
Previously, each source'd Kconfig file was also looked up in the
current directory, and Kconfig files there could override Kconfig
files in $srctree. This is what the C tools do.
I'm pretty sure that behavior was a bug in the C tools all along, and
only meant for .config files. It caused problems (and an ugly
workaround) for the undefined Kconfig symbol CI check in an external
project.
The new behavior also saves a bunch of open()'s, though it's probably
not noticeable.
- Setting the KCONFIG_STRICT environment variable to 'y' now makes
Kconfiglib itself warn for references to undefined symbols. This
isn't safe in general, as some projects use multiple Kconfig trees
with shared Kconfig files (e.g. the Linux kernel).
This will be used to simplify the undefined Kconfig symbol CI check.
- It's now possible to customize how symbols and choices are printed
within expressions.
This will be used to make the RST link generation in genrest.py less
hacky.
- Instead of having 'gsource', a plain 'source' is now globbing, and
requires at least one match. There's also 'osource', for when it's
okay for a glob pattern to match no files.
'gsource' had the design flaw that there was no way to require at
least one file to match. I plan on replacing all 'gsource' statements
with plain 'source's later, but 'gsource' is still supported for
backwards compatibility.
- def_int, def_hex, and def_string are now available as a Kconfig
extensions, analogous to def_bool (set type and add default).
- Misc. internal cleanup.
menuconfig changes:
- Boolean value hints are no longer shown to the right of defaults in
the symbol information for int/hex symbols. Stuff like
'- 74 (value: "n")' wasn't helpful, and looked confusing.
- Symbol information has been made more compact in general, e.g. by
skipping value hints where they aren't helpful
('FOO(=y)' instead of 'FOO(=y) (=y)'), and by shortening stuff like
'(value: "y")' to just '(=y)'.
- Misc. internal cleanup.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-10 06:04:23 +02:00
|
|
|
#
|
menuconfig: Fix a case of visible symbols not being shown
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
78682a8e3c4fe to get the following fix in, which could cause certain
visible symbols to not show up in the menuconfig interface:
menuconfig: Always show implicit submenus with visible nodes
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
parent 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.
(Some other tweaks were made later to avoid showing red outside show-all
mode, because it might look confusing/broken.)
A new color scheme for the menuconfig has been added as well,
contributed by Mitja Horvat (pinkfluid). It can be enabled by setting
the environment variable MENUCONFIG_THEME to 'aquatic'.
The default theme has been tweaked to use bold text for the selected
item too.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-29 10:16:51 +02:00
|
|
|
# This also avoids showing the tristate value for string/int/hex
|
|
|
|
# defaults, which wouldn't make any sense.
|
|
|
|
if isinstance(val, tuple):
|
kconfiglib/menuconfig: Add functionality and improve symbol information
Update Kconfiglib and menuconfig to upstream revision 6aea8d06b637e.
Kconfiglib changes:
- Kconfig files are now looked up just relative to $srctree (if set).
Previously, each source'd Kconfig file was also looked up in the
current directory, and Kconfig files there could override Kconfig
files in $srctree. This is what the C tools do.
I'm pretty sure that behavior was a bug in the C tools all along, and
only meant for .config files. It caused problems (and an ugly
workaround) for the undefined Kconfig symbol CI check in an external
project.
The new behavior also saves a bunch of open()'s, though it's probably
not noticeable.
- Setting the KCONFIG_STRICT environment variable to 'y' now makes
Kconfiglib itself warn for references to undefined symbols. This
isn't safe in general, as some projects use multiple Kconfig trees
with shared Kconfig files (e.g. the Linux kernel).
This will be used to simplify the undefined Kconfig symbol CI check.
- It's now possible to customize how symbols and choices are printed
within expressions.
This will be used to make the RST link generation in genrest.py less
hacky.
- Instead of having 'gsource', a plain 'source' is now globbing, and
requires at least one match. There's also 'osource', for when it's
okay for a glob pattern to match no files.
'gsource' had the design flaw that there was no way to require at
least one file to match. I plan on replacing all 'gsource' statements
with plain 'source's later, but 'gsource' is still supported for
backwards compatibility.
- def_int, def_hex, and def_string are now available as a Kconfig
extensions, analogous to def_bool (set type and add default).
- Misc. internal cleanup.
menuconfig changes:
- Boolean value hints are no longer shown to the right of defaults in
the symbol information for int/hex symbols. Stuff like
'- 74 (value: "n")' wasn't helpful, and looked confusing.
- Symbol information has been made more compact in general, e.g. by
skipping value hints where they aren't helpful
('FOO(=y)' instead of 'FOO(=y) (=y)'), and by shortening stuff like
'(value: "y")' to just '(=y)'.
- Misc. internal cleanup.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-10 06:04:23 +02:00
|
|
|
s += ' (={})'.format(TRI_TO_STR[expr_value(val)])
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
else:
|
|
|
|
# Don't print the value next to the symbol name for choice
|
|
|
|
# defaults, as it looks a bit confusing
|
2018-05-07 13:02:22 +02:00
|
|
|
s += val.name
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
s += "\n"
|
|
|
|
|
|
|
|
if cond is not _kconf.y:
|
menuconfig: Fix a case of visible symbols not being shown
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
78682a8e3c4fe to get the following fix in, which could cause certain
visible symbols to not show up in the menuconfig interface:
menuconfig: Always show implicit submenus with visible nodes
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
parent 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.
(Some other tweaks were made later to avoid showing red outside show-all
mode, because it might look confusing/broken.)
A new color scheme for the menuconfig has been added as well,
contributed by Mitja Horvat (pinkfluid). It can be enabled by setting
the environment variable MENUCONFIG_THEME to 'aquatic'.
The default theme has been tweaked to use bold text for the selected
item too.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-29 10:16:51 +02:00
|
|
|
s += " Condition (={}):\n{}" \
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
.format(TRI_TO_STR[expr_value(cond)],
|
kconfiglib/menuconfig: Add functionality and improve symbol information
Update Kconfiglib and menuconfig to upstream revision 6aea8d06b637e.
Kconfiglib changes:
- Kconfig files are now looked up just relative to $srctree (if set).
Previously, each source'd Kconfig file was also looked up in the
current directory, and Kconfig files there could override Kconfig
files in $srctree. This is what the C tools do.
I'm pretty sure that behavior was a bug in the C tools all along, and
only meant for .config files. It caused problems (and an ugly
workaround) for the undefined Kconfig symbol CI check in an external
project.
The new behavior also saves a bunch of open()'s, though it's probably
not noticeable.
- Setting the KCONFIG_STRICT environment variable to 'y' now makes
Kconfiglib itself warn for references to undefined symbols. This
isn't safe in general, as some projects use multiple Kconfig trees
with shared Kconfig files (e.g. the Linux kernel).
This will be used to simplify the undefined Kconfig symbol CI check.
- It's now possible to customize how symbols and choices are printed
within expressions.
This will be used to make the RST link generation in genrest.py less
hacky.
- Instead of having 'gsource', a plain 'source' is now globbing, and
requires at least one match. There's also 'osource', for when it's
okay for a glob pattern to match no files.
'gsource' had the design flaw that there was no way to require at
least one file to match. I plan on replacing all 'gsource' statements
with plain 'source's later, but 'gsource' is still supported for
backwards compatibility.
- def_int, def_hex, and def_string are now available as a Kconfig
extensions, analogous to def_bool (set type and add default).
- Misc. internal cleanup.
menuconfig changes:
- Boolean value hints are no longer shown to the right of defaults in
the symbol information for int/hex symbols. Stuff like
'- 74 (value: "n")' wasn't helpful, and looked confusing.
- Symbol information has been made more compact in general, e.g. by
skipping value hints where they aren't helpful
('FOO(=y)' instead of 'FOO(=y) (=y)'), and by shortening stuff like
'(value: "y")' to just '(=y)'.
- Misc. internal cleanup.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-10 06:04:23 +02:00
|
|
|
_split_expr_info(cond, 4))
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
return s + "\n"
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
def _split_expr_info(expr, indent):
|
|
|
|
# Returns a string with 'expr' split into its top-level && or || operands,
|
|
|
|
# with one operand per line, together with the operand's value. This is
|
|
|
|
# usually enough to get something readable for long expressions. A fancier
|
|
|
|
# recursive thingy would be possible too.
|
|
|
|
#
|
|
|
|
# indent:
|
|
|
|
# Number of leading spaces to add before the split expression.
|
|
|
|
|
|
|
|
if len(split_expr(expr, AND)) > 1:
|
|
|
|
split_op = AND
|
|
|
|
op_str = "&&"
|
|
|
|
else:
|
|
|
|
split_op = OR
|
|
|
|
op_str = "||"
|
|
|
|
|
|
|
|
s = ""
|
|
|
|
for i, term in enumerate(split_expr(expr, split_op)):
|
2019-05-06 17:12:27 +02:00
|
|
|
s += "{}{} {}".format(indent*" ",
|
kconfiglib/menuconfig: Add functionality and improve symbol information
Update Kconfiglib and menuconfig to upstream revision 6aea8d06b637e.
Kconfiglib changes:
- Kconfig files are now looked up just relative to $srctree (if set).
Previously, each source'd Kconfig file was also looked up in the
current directory, and Kconfig files there could override Kconfig
files in $srctree. This is what the C tools do.
I'm pretty sure that behavior was a bug in the C tools all along, and
only meant for .config files. It caused problems (and an ugly
workaround) for the undefined Kconfig symbol CI check in an external
project.
The new behavior also saves a bunch of open()'s, though it's probably
not noticeable.
- Setting the KCONFIG_STRICT environment variable to 'y' now makes
Kconfiglib itself warn for references to undefined symbols. This
isn't safe in general, as some projects use multiple Kconfig trees
with shared Kconfig files (e.g. the Linux kernel).
This will be used to simplify the undefined Kconfig symbol CI check.
- It's now possible to customize how symbols and choices are printed
within expressions.
This will be used to make the RST link generation in genrest.py less
hacky.
- Instead of having 'gsource', a plain 'source' is now globbing, and
requires at least one match. There's also 'osource', for when it's
okay for a glob pattern to match no files.
'gsource' had the design flaw that there was no way to require at
least one file to match. I plan on replacing all 'gsource' statements
with plain 'source's later, but 'gsource' is still supported for
backwards compatibility.
- def_int, def_hex, and def_string are now available as a Kconfig
extensions, analogous to def_bool (set type and add default).
- Misc. internal cleanup.
menuconfig changes:
- Boolean value hints are no longer shown to the right of defaults in
the symbol information for int/hex symbols. Stuff like
'- 74 (value: "n")' wasn't helpful, and looked confusing.
- Symbol information has been made more compact in general, e.g. by
skipping value hints where they aren't helpful
('FOO(=y)' instead of 'FOO(=y) (=y)'), and by shortening stuff like
'(value: "y")' to just '(=y)'.
- Misc. internal cleanup.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-10 06:04:23 +02:00
|
|
|
" " if i == 0 else op_str,
|
|
|
|
_expr_str(term))
|
|
|
|
|
|
|
|
# Don't bother showing the value hint if the expression is just a
|
|
|
|
# single symbol. _expr_str() already shows its value.
|
|
|
|
if isinstance(term, tuple):
|
|
|
|
s += " (={})".format(TRI_TO_STR[expr_value(term)])
|
|
|
|
|
|
|
|
s += "\n"
|
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
return s
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
def _select_imply_info(sym):
|
|
|
|
# Returns a string with information about which symbols 'select' or 'imply'
|
|
|
|
# 'sym'. The selecting/implying symbols are grouped according to which
|
|
|
|
# value they select/imply 'sym' to (n/m/y).
|
|
|
|
|
2019-06-24 08:01:09 +02:00
|
|
|
def sis(expr, val, title):
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
# sis = selects/implies
|
|
|
|
sis = [si for si in split_expr(expr, OR) if expr_value(si) == val]
|
2019-06-24 08:01:09 +02:00
|
|
|
if not sis:
|
|
|
|
return ""
|
|
|
|
|
|
|
|
res = title
|
|
|
|
for si in sis:
|
|
|
|
res += " - {}\n".format(split_expr(si, AND)[0].name)
|
|
|
|
return res + "\n"
|
|
|
|
|
|
|
|
s = ""
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
if sym.rev_dep is not _kconf.n:
|
2019-06-24 08:01:09 +02:00
|
|
|
s += sis(sym.rev_dep, 2,
|
|
|
|
"Symbols currently y-selecting this symbol:\n")
|
|
|
|
s += sis(sym.rev_dep, 1,
|
|
|
|
"Symbols currently m-selecting this symbol:\n")
|
|
|
|
s += sis(sym.rev_dep, 0,
|
|
|
|
"Symbols currently n-selecting this symbol (no effect):\n")
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
if sym.weak_rev_dep is not _kconf.n:
|
2019-06-24 08:01:09 +02:00
|
|
|
s += sis(sym.weak_rev_dep, 2,
|
|
|
|
"Symbols currently y-implying this symbol:\n")
|
|
|
|
s += sis(sym.weak_rev_dep, 1,
|
|
|
|
"Symbols currently m-implying this symbol:\n")
|
|
|
|
s += sis(sym.weak_rev_dep, 0,
|
|
|
|
"Symbols currently n-implying this symbol (no effect):\n")
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
return s
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
2018-05-16 21:05:48 +02:00
|
|
|
def _kconfig_def_info(item):
|
|
|
|
# Returns a string with the definition of 'item' in Kconfig syntax,
|
2018-08-24 01:31:41 +02:00
|
|
|
# together with the definition location(s) and their include and menu paths
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
2018-05-16 21:05:48 +02:00
|
|
|
nodes = [item] if isinstance(item, MenuNode) else item.nodes
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
kconfiglib: Unclutter symbol strings, avoid redundant writes, misc.
Update kconfiglib, menuconfig, and guiconfig to upstream revision
5c904f4549 to get various improvements and fixes in:
- Marc Herbert found an issue involving symlinks, absolute paths,
and rsource that could lead to files not being found. The root cause
was relpath() assuming that symlink/../bar is the same as bar/, which
isn't guaranteed.
Fix it by handling paths in a simpler, more textual way.
- Propagated dependencies from 'depends on' are now stripped from
properties when symbols are printed (e.g. in information dialogs and
generated documentation).
The printed representation now also uses shorthands.
Before:
config A
bool
prompt "foo" if C && D
default A if B && C && D
depends on C && D
After:
config A
bool "foo"
default A if B
depends on C && D
- Before writing a configuration file or header, Kconfiglib now
compares the previous contents of the file against the new contents,
and skips the write if there's no change. This avoids updating the
modification time, and can save work.
A message like "No change to '.config'" is shown when there's no
change.
- .config now has '# end of <menu>' comments to make it easier to see
where a menu ends. This was taken from a change to the C tools.
- load_config() and write_(min_)config() now return a message that can
be printed with print(kconf.load_config()). This allows messages to
be reused in e.g. the configuration interfaces (nice now that there's
also a "No change to..." string).
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-06-03 19:57:27 +02:00
|
|
|
s = "Kconfig definition{}, with parent deps. propagated to 'depends on'\n" \
|
2018-05-16 21:05:48 +02:00
|
|
|
.format("s" if len(nodes) > 1 else "")
|
2018-08-24 01:31:41 +02:00
|
|
|
s += (len(s) - 1)*"="
|
|
|
|
|
|
|
|
for node in nodes:
|
|
|
|
s += "\n\n" \
|
|
|
|
"At {}:{}\n" \
|
menuconfig: Fix a case of visible symbols not being shown
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
78682a8e3c4fe to get the following fix in, which could cause certain
visible symbols to not show up in the menuconfig interface:
menuconfig: Always show implicit submenus with visible nodes
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
parent 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.
(Some other tweaks were made later to avoid showing red outside show-all
mode, because it might look confusing/broken.)
A new color scheme for the menuconfig has been added as well,
contributed by Mitja Horvat (pinkfluid). It can be enabled by setting
the environment variable MENUCONFIG_THEME to 'aquatic'.
The default theme has been tweaked to use bold text for the selected
item too.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-29 10:16:51 +02:00
|
|
|
"{}" \
|
2018-08-24 01:31:41 +02:00
|
|
|
"Menu path: {}\n\n" \
|
|
|
|
"{}" \
|
|
|
|
.format(node.filename, node.linenr,
|
|
|
|
_include_path_info(node),
|
|
|
|
_menu_path_info(node),
|
2019-06-24 08:01:09 +02:00
|
|
|
_indent(node.custom_str(_name_and_val_str), 2))
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
2018-05-16 21:05:48 +02:00
|
|
|
return s
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
2018-08-24 01:31:41 +02:00
|
|
|
def _include_path_info(node):
|
menuconfig: Fix a case of visible symbols not being shown
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
78682a8e3c4fe to get the following fix in, which could cause certain
visible symbols to not show up in the menuconfig interface:
menuconfig: Always show implicit submenus with visible nodes
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
parent 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.
(Some other tweaks were made later to avoid showing red outside show-all
mode, because it might look confusing/broken.)
A new color scheme for the menuconfig has been added as well,
contributed by Mitja Horvat (pinkfluid). It can be enabled by setting
the environment variable MENUCONFIG_THEME to 'aquatic'.
The default theme has been tweaked to use bold text for the selected
item too.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-29 10:16:51 +02:00
|
|
|
if not node.include_path:
|
|
|
|
# In the top-level Kconfig file
|
|
|
|
return ""
|
|
|
|
|
|
|
|
return "Included via {}\n".format(
|
|
|
|
" -> ".join("{}:{}".format(filename, linenr)
|
|
|
|
for filename, linenr in node.include_path))
|
2018-08-24 01:31:41 +02:00
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
def _menu_path_info(node):
|
|
|
|
# Returns a string describing the menu path leading up to 'node'
|
|
|
|
|
|
|
|
path = ""
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
while node.parent is not _kconf.top_node:
|
|
|
|
node = node.parent
|
|
|
|
|
2018-10-10 15:08:45 +02:00
|
|
|
# Promptless choices might appear among the parents. Use
|
|
|
|
# standard_sc_expr_str() for them, so that they show up as
|
|
|
|
# '<choice (name if any)>'.
|
|
|
|
path = " -> " + (node.prompt[0] if node.prompt else
|
|
|
|
standard_sc_expr_str(node.item)) + path
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
2019-05-06 17:12:27 +02:00
|
|
|
return "(Top)" + path
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
2019-06-24 08:01:09 +02:00
|
|
|
def _indent(s, n):
|
|
|
|
# Returns 's' with each line indented 'n' spaces. textwrap.indent() is not
|
|
|
|
# available in Python 2 (it's 3.3+).
|
|
|
|
|
|
|
|
return "\n".join(n*" " + line for line in s.split("\n"))
|
|
|
|
|
|
|
|
|
2018-09-15 08:45:50 +02:00
|
|
|
def _name_and_val_str(sc):
|
menuconfig: Add jump-to for choices, menus, and comments
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
bf1701b36634b, to add this commit:
menuconfig: Add jump-to for choices, menus, and comments
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.
Previously, only symbols could be jumped to.
Various other small fixes/improvements are included too:
- The "no range constraints" text was dropped from the input dialog
when settings int/hex symbols without an active 'range'. It might be
more confusing than helpful.
- A crash when pressing Ctrl-F (the view-help shortcut) with no matches
in the jump-to dialog was fixed
- Some gnome-terminal shoddiness was worked around to remove minor
jumpiness when reducing the height of the terminal
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-10-15 02:05:45 +02:00
|
|
|
# Custom symbol/choice printer that shows symbol values after symbols
|
2018-09-15 08:45:50 +02:00
|
|
|
|
|
|
|
# Show the values of non-constant (non-quoted) symbols that don't look like
|
|
|
|
# numbers. Things like 123 are actually symbol references, and only work as
|
|
|
|
# expected due to undefined symbols getting their name as their value.
|
|
|
|
# Showing the symbol value for those isn't helpful though.
|
menuconfig: Add jump-to for choices, menus, and comments
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
bf1701b36634b, to add this commit:
menuconfig: Add jump-to for choices, menus, and comments
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.
Previously, only symbols could be jumped to.
Various other small fixes/improvements are included too:
- The "no range constraints" text was dropped from the input dialog
when settings int/hex symbols without an active 'range'. It might be
more confusing than helpful.
- A crash when pressing Ctrl-F (the view-help shortcut) with no matches
in the jump-to dialog was fixed
- Some gnome-terminal shoddiness was worked around to remove minor
jumpiness when reducing the height of the terminal
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-10-15 02:05:45 +02:00
|
|
|
if isinstance(sc, Symbol) and not sc.is_constant and not _is_num(sc.name):
|
2018-09-15 08:45:50 +02:00
|
|
|
if not sc.nodes:
|
|
|
|
# Undefined symbol reference
|
|
|
|
return "{}(undefined/n)".format(sc.name)
|
|
|
|
|
|
|
|
return '{}(={})'.format(sc.name, sc.str_value)
|
|
|
|
|
menuconfig: Add jump-to for choices, menus, and comments
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
bf1701b36634b, to add this commit:
menuconfig: Add jump-to for choices, menus, and comments
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.
Previously, only symbols could be jumped to.
Various other small fixes/improvements are included too:
- The "no range constraints" text was dropped from the input dialog
when settings int/hex symbols without an active 'range'. It might be
more confusing than helpful.
- A crash when pressing Ctrl-F (the view-help shortcut) with no matches
in the jump-to dialog was fixed
- Some gnome-terminal shoddiness was worked around to remove minor
jumpiness when reducing the height of the terminal
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-10-15 02:05:45 +02:00
|
|
|
# For other items, use the standard format
|
2018-09-15 08:45:50 +02:00
|
|
|
return standard_sc_expr_str(sc)
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
2018-09-15 08:45:50 +02:00
|
|
|
def _expr_str(expr):
|
|
|
|
# Custom expression printer that shows symbol values
|
|
|
|
return expr_str(expr, _name_and_val_str)
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
def _styled_win(style):
|
2018-09-15 08:45:50 +02:00
|
|
|
# Returns a new curses window with style 'style' and space as the fill
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
# character. The initial dimensions are (1, 1), so the window needs to be
|
|
|
|
# sized and positioned separately.
|
|
|
|
|
|
|
|
win = curses.newwin(1, 1)
|
2018-12-17 14:03:58 +01:00
|
|
|
_set_style(win, style)
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
return win
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
2018-12-17 14:03:58 +01:00
|
|
|
def _set_style(win, style):
|
|
|
|
# Changes the style of an existing window
|
|
|
|
|
|
|
|
win.bkgdset(" ", _style[style])
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
2018-05-07 13:02:22 +02:00
|
|
|
def _max_scroll(lst, win):
|
|
|
|
# Assuming 'lst' is a list of items to be displayed in 'win',
|
|
|
|
# returns the maximum number of steps 'win' can be scrolled down.
|
|
|
|
# We stop scrolling when the bottom item is visible.
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
return max(0, len(lst) - _height(win))
|
|
|
|
|
2018-05-07 13:02:22 +02:00
|
|
|
|
|
|
|
def _edit_text(c, s, i, hscroll, width):
|
|
|
|
# Implements text editing commands for edit boxes. Takes a character (which
|
|
|
|
# could also be e.g. curses.KEY_LEFT) and the edit box state, and returns
|
|
|
|
# the new state after the character has been processed.
|
|
|
|
#
|
|
|
|
# c:
|
|
|
|
# Character from user
|
|
|
|
#
|
|
|
|
# s:
|
|
|
|
# Current contents of string
|
|
|
|
#
|
|
|
|
# i:
|
|
|
|
# Current cursor index in string
|
|
|
|
#
|
|
|
|
# hscroll:
|
|
|
|
# Index in s of the leftmost character in the edit box, for horizontal
|
|
|
|
# scrolling
|
|
|
|
#
|
|
|
|
# width:
|
|
|
|
# Width in characters of the edit box
|
|
|
|
#
|
|
|
|
# Return value:
|
|
|
|
# An (s, i, hscroll) tuple for the new state
|
|
|
|
|
|
|
|
if c == curses.KEY_LEFT:
|
|
|
|
if i > 0:
|
|
|
|
i -= 1
|
|
|
|
|
|
|
|
elif c == curses.KEY_RIGHT:
|
|
|
|
if i < len(s):
|
|
|
|
i += 1
|
|
|
|
|
|
|
|
elif c in (curses.KEY_HOME, "\x01"): # \x01 = CTRL-A
|
|
|
|
i = 0
|
|
|
|
|
|
|
|
elif c in (curses.KEY_END, "\x05"): # \x05 = CTRL-E
|
|
|
|
i = len(s)
|
|
|
|
|
|
|
|
elif c in (curses.KEY_BACKSPACE, _ERASE_CHAR):
|
|
|
|
if i > 0:
|
|
|
|
s = s[:i-1] + s[i:]
|
|
|
|
i -= 1
|
|
|
|
|
|
|
|
elif c == curses.KEY_DC:
|
|
|
|
s = s[:i] + s[i+1:]
|
|
|
|
|
2018-05-16 21:05:48 +02:00
|
|
|
elif c == "\x17": # \x17 = CTRL-W
|
|
|
|
# The \W removes characters like ',' one at a time
|
|
|
|
new_i = re.search(r"(?:\w*|\W)\s*$", s[:i]).start()
|
|
|
|
s = s[:new_i] + s[i:]
|
|
|
|
i = new_i
|
|
|
|
|
2018-05-07 13:02:22 +02:00
|
|
|
elif c == "\x0B": # \x0B = CTRL-K
|
|
|
|
s = s[:i]
|
|
|
|
|
|
|
|
elif c == "\x15": # \x15 = CTRL-U
|
|
|
|
s = s[i:]
|
|
|
|
i = 0
|
|
|
|
|
|
|
|
elif isinstance(c, str):
|
|
|
|
# Insert character
|
|
|
|
s = s[:i] + c + s[i:]
|
|
|
|
i += 1
|
|
|
|
|
2018-05-21 15:48:23 +02:00
|
|
|
# Adjust the horizontal scroll so that the cursor never touches the left or
|
|
|
|
# right edges of the edit box, except when it's at the beginning or the end
|
|
|
|
# of the string
|
|
|
|
if i < hscroll + _SCROLL_OFFSET:
|
|
|
|
hscroll = max(i - _SCROLL_OFFSET, 0)
|
|
|
|
elif i >= hscroll + width - _SCROLL_OFFSET:
|
|
|
|
max_scroll = max(len(s) - width + 1, 0)
|
|
|
|
hscroll = min(i - width + _SCROLL_OFFSET + 1, max_scroll)
|
2018-05-07 13:02:22 +02:00
|
|
|
|
|
|
|
return s, i, hscroll
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
2018-05-21 15:48:23 +02:00
|
|
|
def _load_save_info():
|
|
|
|
# Returns an information string for load/save dialog boxes
|
|
|
|
|
|
|
|
return "(Relative to {})\n\nRefer to your home directory with ~" \
|
|
|
|
.format(os.path.join(os.getcwd(), ""))
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
2018-05-07 13:02:22 +02:00
|
|
|
def _msg(title, text):
|
|
|
|
# Pops up a message dialog that can be dismissed with Space/Enter/ESC
|
|
|
|
|
|
|
|
_key_dialog(title, text, " \n")
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
2018-05-07 13:02:22 +02:00
|
|
|
def _error(text):
|
|
|
|
# Pops up an error dialog that can be dismissed with Space/Enter/ESC
|
|
|
|
|
|
|
|
_msg("Error", text)
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
def _node_str(node):
|
|
|
|
# Returns the complete menu entry text for a menu node.
|
|
|
|
#
|
|
|
|
# Example return value: "[*] Support for X"
|
|
|
|
|
|
|
|
# Calculate the indent to print the item with by checking how many levels
|
|
|
|
# above it the closest 'menuconfig' item is (this includes menus and
|
|
|
|
# choices as well as menuconfig symbols)
|
|
|
|
indent = 0
|
|
|
|
parent = node.parent
|
|
|
|
while not parent.is_menuconfig:
|
2018-05-08 17:51:11 +02:00
|
|
|
indent += _SUBMENU_INDENT
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
parent = parent.parent
|
|
|
|
|
|
|
|
# This approach gives nice alignment for empty string symbols ("() Foo")
|
2018-05-25 20:12:25 +02:00
|
|
|
s = "{:{}}".format(_value_str(node), 3 + indent)
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
2018-10-10 15:08:45 +02:00
|
|
|
if _should_show_name(node):
|
|
|
|
if isinstance(node.item, Symbol):
|
|
|
|
s += " <{}>".format(node.item.name)
|
|
|
|
else:
|
|
|
|
# For choices, use standard_sc_expr_str(). That way they show up as
|
|
|
|
# '<choice (name if any)>'.
|
|
|
|
s += " " + standard_sc_expr_str(node.item)
|
2018-05-25 20:12:25 +02:00
|
|
|
|
|
|
|
if node.prompt:
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
if node.item == COMMENT:
|
menuconfig: Add jump-to for choices, menus, and comments
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
bf1701b36634b, to add this commit:
menuconfig: Add jump-to for choices, menus, and comments
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.
Previously, only symbols could be jumped to.
Various other small fixes/improvements are included too:
- The "no range constraints" text was dropped from the input dialog
when settings int/hex symbols without an active 'range'. It might be
more confusing than helpful.
- A crash when pressing Ctrl-F (the view-help shortcut) with no matches
in the jump-to dialog was fixed
- Some gnome-terminal shoddiness was worked around to remove minor
jumpiness when reducing the height of the terminal
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-10-15 02:05:45 +02:00
|
|
|
s += " *** {} ***".format(node.prompt[0])
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
else:
|
menuconfig: Add jump-to for choices, menus, and comments
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
bf1701b36634b, to add this commit:
menuconfig: Add jump-to for choices, menus, and comments
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.
Previously, only symbols could be jumped to.
Various other small fixes/improvements are included too:
- The "no range constraints" text was dropped from the input dialog
when settings int/hex symbols without an active 'range'. It might be
more confusing than helpful.
- A crash when pressing Ctrl-F (the view-help shortcut) with no matches
in the jump-to dialog was fixed
- Some gnome-terminal shoddiness was worked around to remove minor
jumpiness when reducing the height of the terminal
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-10-15 02:05:45 +02:00
|
|
|
s += " " + node.prompt[0]
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
if isinstance(node.item, Symbol):
|
|
|
|
sym = node.item
|
|
|
|
|
|
|
|
# Print "(NEW)" next to symbols without a user value (from e.g. a
|
2018-11-04 01:58:08 +01:00
|
|
|
# .config), but skip it for choice symbols in choices in y mode,
|
|
|
|
# and for symbols of UNKNOWN type (which generate a warning though)
|
2019-05-06 17:12:27 +02:00
|
|
|
if sym.user_value is None and sym.orig_type and \
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
not (sym.choice and sym.choice.tri_value == 2):
|
|
|
|
|
|
|
|
s += " (NEW)"
|
|
|
|
|
menuconfig: Add jump-to for choices, menus, and comments
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
bf1701b36634b, to add this commit:
menuconfig: Add jump-to for choices, menus, and comments
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.
Previously, only symbols could be jumped to.
Various other small fixes/improvements are included too:
- The "no range constraints" text was dropped from the input dialog
when settings int/hex symbols without an active 'range'. It might be
more confusing than helpful.
- A crash when pressing Ctrl-F (the view-help shortcut) with no matches
in the jump-to dialog was fixed
- Some gnome-terminal shoddiness was worked around to remove minor
jumpiness when reducing the height of the terminal
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-10-15 02:05:45 +02:00
|
|
|
if isinstance(node.item, Choice) and node.item.tri_value == 2:
|
|
|
|
# Print the prompt of the selected symbol after the choice for
|
|
|
|
# choices in y mode
|
|
|
|
sym = node.item.selection
|
|
|
|
if sym:
|
2018-11-28 15:15:56 +01:00
|
|
|
for sym_node in sym.nodes:
|
|
|
|
# Use the prompt used at this choice location, in case the
|
|
|
|
# choice symbol is defined in multiple locations
|
|
|
|
if sym_node.parent is node and sym_node.prompt:
|
|
|
|
s += " ({})".format(sym_node.prompt[0])
|
|
|
|
break
|
|
|
|
else:
|
|
|
|
# If the symbol isn't defined at this choice location, then
|
|
|
|
# just use whatever prompt we can find for it
|
|
|
|
for sym_node in sym.nodes:
|
|
|
|
if sym_node.prompt:
|
|
|
|
s += " ({})".format(sym_node.prompt[0])
|
|
|
|
break
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
# Print "--->" next to nodes that have menus that can potentially be
|
2018-11-23 23:49:37 +01:00
|
|
|
# entered. Print "----" if the menu is empty. We don't allow those to be
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
# entered.
|
|
|
|
if node.is_menuconfig:
|
2018-11-23 23:49:37 +01:00
|
|
|
s += " --->" if _shown_nodes(node) else " ----"
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
|
|
|
return s
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
2018-10-10 15:08:45 +02:00
|
|
|
def _should_show_name(node):
|
|
|
|
# Returns True if 'node' is a symbol or choice whose name should shown (if
|
|
|
|
# any, as names are optional for choices)
|
|
|
|
|
|
|
|
# The 'not node.prompt' case only hits in show-all mode, for promptless
|
|
|
|
# symbols and choices
|
|
|
|
return not node.prompt or \
|
|
|
|
(_show_name and isinstance(node.item, (Symbol, Choice)))
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
def _value_str(node):
|
|
|
|
# Returns the value part ("[*]", "<M>", "(foo)" etc.) of a menu node
|
|
|
|
|
|
|
|
item = node.item
|
|
|
|
|
|
|
|
if item in (MENU, COMMENT):
|
|
|
|
return ""
|
|
|
|
|
|
|
|
# Wouldn't normally happen, and generates a warning
|
2019-05-06 17:12:27 +02:00
|
|
|
if not item.orig_type:
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
return ""
|
|
|
|
|
2019-05-06 17:12:27 +02:00
|
|
|
if item.orig_type in (STRING, INT, HEX):
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
return "({})".format(item.str_value)
|
|
|
|
|
|
|
|
# BOOL or TRISTATE
|
|
|
|
|
|
|
|
if _is_y_mode_choice_sym(item):
|
|
|
|
return "(X)" if item.choice.selection is item else "( )"
|
|
|
|
|
|
|
|
tri_val_str = (" ", "M", "*")[item.tri_value]
|
|
|
|
|
menuconfig: Fix a case of visible symbols not being shown
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
78682a8e3c4fe to get the following fix in, which could cause certain
visible symbols to not show up in the menuconfig interface:
menuconfig: Always show implicit submenus with visible nodes
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
parent 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.
(Some other tweaks were made later to avoid showing red outside show-all
mode, because it might look confusing/broken.)
A new color scheme for the menuconfig has been added as well,
contributed by Mitja Horvat (pinkfluid). It can be enabled by setting
the environment variable MENUCONFIG_THEME to 'aquatic'.
The default theme has been tweaked to use bold text for the selected
item too.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-29 10:16:51 +02:00
|
|
|
if len(item.assignable) <= 1:
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
# Pinned to a single value
|
|
|
|
return "" if isinstance(item, Choice) else "-{}-".format(tri_val_str)
|
|
|
|
|
|
|
|
if item.type == BOOL:
|
|
|
|
return "[{}]".format(tri_val_str)
|
|
|
|
|
kconfiglib/menuconfig: Add functionality and improve symbol information
Update Kconfiglib and menuconfig to upstream revision 6aea8d06b637e.
Kconfiglib changes:
- Kconfig files are now looked up just relative to $srctree (if set).
Previously, each source'd Kconfig file was also looked up in the
current directory, and Kconfig files there could override Kconfig
files in $srctree. This is what the C tools do.
I'm pretty sure that behavior was a bug in the C tools all along, and
only meant for .config files. It caused problems (and an ugly
workaround) for the undefined Kconfig symbol CI check in an external
project.
The new behavior also saves a bunch of open()'s, though it's probably
not noticeable.
- Setting the KCONFIG_STRICT environment variable to 'y' now makes
Kconfiglib itself warn for references to undefined symbols. This
isn't safe in general, as some projects use multiple Kconfig trees
with shared Kconfig files (e.g. the Linux kernel).
This will be used to simplify the undefined Kconfig symbol CI check.
- It's now possible to customize how symbols and choices are printed
within expressions.
This will be used to make the RST link generation in genrest.py less
hacky.
- Instead of having 'gsource', a plain 'source' is now globbing, and
requires at least one match. There's also 'osource', for when it's
okay for a glob pattern to match no files.
'gsource' had the design flaw that there was no way to require at
least one file to match. I plan on replacing all 'gsource' statements
with plain 'source's later, but 'gsource' is still supported for
backwards compatibility.
- def_int, def_hex, and def_string are now available as a Kconfig
extensions, analogous to def_bool (set type and add default).
- Misc. internal cleanup.
menuconfig changes:
- Boolean value hints are no longer shown to the right of defaults in
the symbol information for int/hex symbols. Stuff like
'- 74 (value: "n")' wasn't helpful, and looked confusing.
- Symbol information has been made more compact in general, e.g. by
skipping value hints where they aren't helpful
('FOO(=y)' instead of 'FOO(=y) (=y)'), and by shortening stuff like
'(value: "y")' to just '(=y)'.
- Misc. internal cleanup.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-10 06:04:23 +02:00
|
|
|
# item.type == TRISTATE
|
|
|
|
if item.assignable == (1, 2):
|
|
|
|
return "{{{}}}".format(tri_val_str) # {M}/{*}
|
|
|
|
return "<{}>".format(tri_val_str)
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
def _is_y_mode_choice_sym(item):
|
|
|
|
# The choice mode is an upper bound on the visibility of choice symbols, so
|
|
|
|
# we can check the choice symbols' own visibility to see if the choice is
|
|
|
|
# in y mode
|
|
|
|
return isinstance(item, Symbol) and item.choice and item.visibility == 2
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
|
|
|
def _check_valid(sym, s):
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
# Returns True if the string 's' is a well-formed value for 'sym'.
|
|
|
|
# Otherwise, displays an error and returns False.
|
|
|
|
|
2019-05-06 17:12:27 +02:00
|
|
|
if sym.orig_type not in (INT, HEX):
|
2020-01-13 10:38:45 +01:00
|
|
|
return True # Anything goes for non-int/hex symbols
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
2019-05-06 17:12:27 +02:00
|
|
|
base = 10 if sym.orig_type == INT else 16
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
try:
|
|
|
|
int(s, base)
|
|
|
|
except ValueError:
|
|
|
|
_error("'{}' is a malformed {} value"
|
2019-05-06 17:12:27 +02:00
|
|
|
.format(s, TYPE_TO_STR[sym.orig_type]))
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
return False
|
|
|
|
|
|
|
|
for low_sym, high_sym, cond in sym.ranges:
|
|
|
|
if expr_value(cond):
|
2019-06-24 08:01:09 +02:00
|
|
|
low_s = low_sym.str_value
|
|
|
|
high_s = high_sym.str_value
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
2019-06-24 08:01:09 +02:00
|
|
|
if not int(low_s, base) <= int(s, base) <= int(high_s, base):
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
_error("{} is outside the range {}-{}"
|
2019-06-24 08:01:09 +02:00
|
|
|
.format(s, low_s, high_s))
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
return False
|
|
|
|
|
|
|
|
break
|
|
|
|
|
|
|
|
return True
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
def _range_info(sym):
|
|
|
|
# Returns a string with information about the valid range for the symbol
|
menuconfig: Add jump-to for choices, menus, and comments
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
bf1701b36634b, to add this commit:
menuconfig: Add jump-to for choices, menus, and comments
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.
Previously, only symbols could be jumped to.
Various other small fixes/improvements are included too:
- The "no range constraints" text was dropped from the input dialog
when settings int/hex symbols without an active 'range'. It might be
more confusing than helpful.
- A crash when pressing Ctrl-F (the view-help shortcut) with no matches
in the jump-to dialog was fixed
- Some gnome-terminal shoddiness was worked around to remove minor
jumpiness when reducing the height of the terminal
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-10-15 02:05:45 +02:00
|
|
|
# 'sym', or None if 'sym' doesn't have a range
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
2019-05-06 17:12:27 +02:00
|
|
|
if sym.orig_type in (INT, HEX):
|
menuconfig: Add jump-to for choices, menus, and comments
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
bf1701b36634b, to add this commit:
menuconfig: Add jump-to for choices, menus, and comments
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.
Previously, only symbols could be jumped to.
Various other small fixes/improvements are included too:
- The "no range constraints" text was dropped from the input dialog
when settings int/hex symbols without an active 'range'. It might be
more confusing than helpful.
- A crash when pressing Ctrl-F (the view-help shortcut) with no matches
in the jump-to dialog was fixed
- Some gnome-terminal shoddiness was worked around to remove minor
jumpiness when reducing the height of the terminal
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-10-15 02:05:45 +02:00
|
|
|
for low, high, cond in sym.ranges:
|
|
|
|
if expr_value(cond):
|
|
|
|
return "Range: {}-{}".format(low.str_value, high.str_value)
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
menuconfig: Add jump-to for choices, menus, and comments
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
bf1701b36634b, to add this commit:
menuconfig: Add jump-to for choices, menus, and comments
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.
Previously, only symbols could be jumped to.
Various other small fixes/improvements are included too:
- The "no range constraints" text was dropped from the input dialog
when settings int/hex symbols without an active 'range'. It might be
more confusing than helpful.
- A crash when pressing Ctrl-F (the view-help shortcut) with no matches
in the jump-to dialog was fixed
- Some gnome-terminal shoddiness was worked around to remove minor
jumpiness when reducing the height of the terminal
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-10-15 02:05:45 +02:00
|
|
|
return None
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
def _is_num(name):
|
|
|
|
# Heuristic to see if a symbol name looks like a number, for nicer output
|
|
|
|
# when printing expressions. Things like 16 are actually symbol names, only
|
|
|
|
# they get their name as their value when the symbol is undefined.
|
|
|
|
|
|
|
|
try:
|
2018-06-15 19:30:34 +02:00
|
|
|
int(name)
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
except ValueError:
|
|
|
|
if not name.startswith(("0x", "0X")):
|
|
|
|
return False
|
|
|
|
|
|
|
|
try:
|
|
|
|
int(name, 16)
|
|
|
|
except ValueError:
|
|
|
|
return False
|
|
|
|
|
kconfiglib/menuconfig: Add functionality and improve symbol information
Update Kconfiglib and menuconfig to upstream revision 6aea8d06b637e.
Kconfiglib changes:
- Kconfig files are now looked up just relative to $srctree (if set).
Previously, each source'd Kconfig file was also looked up in the
current directory, and Kconfig files there could override Kconfig
files in $srctree. This is what the C tools do.
I'm pretty sure that behavior was a bug in the C tools all along, and
only meant for .config files. It caused problems (and an ugly
workaround) for the undefined Kconfig symbol CI check in an external
project.
The new behavior also saves a bunch of open()'s, though it's probably
not noticeable.
- Setting the KCONFIG_STRICT environment variable to 'y' now makes
Kconfiglib itself warn for references to undefined symbols. This
isn't safe in general, as some projects use multiple Kconfig trees
with shared Kconfig files (e.g. the Linux kernel).
This will be used to simplify the undefined Kconfig symbol CI check.
- It's now possible to customize how symbols and choices are printed
within expressions.
This will be used to make the RST link generation in genrest.py less
hacky.
- Instead of having 'gsource', a plain 'source' is now globbing, and
requires at least one match. There's also 'osource', for when it's
okay for a glob pattern to match no files.
'gsource' had the design flaw that there was no way to require at
least one file to match. I plan on replacing all 'gsource' statements
with plain 'source's later, but 'gsource' is still supported for
backwards compatibility.
- def_int, def_hex, and def_string are now available as a Kconfig
extensions, analogous to def_bool (set type and add default).
- Misc. internal cleanup.
menuconfig changes:
- Boolean value hints are no longer shown to the right of defaults in
the symbol information for int/hex symbols. Stuff like
'- 74 (value: "n")' wasn't helpful, and looked confusing.
- Symbol information has been made more compact in general, e.g. by
skipping value hints where they aren't helpful
('FOO(=y)' instead of 'FOO(=y) (=y)'), and by shortening stuff like
'(value: "y")' to just '(=y)'.
- Misc. internal cleanup.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-10 06:04:23 +02:00
|
|
|
return True
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
2019-06-24 08:01:09 +02:00
|
|
|
def _getch_compat(win):
|
2020-01-13 10:38:45 +01:00
|
|
|
# Uses get_wch() if available (Python 3.3+) and getch() otherwise.
|
|
|
|
#
|
|
|
|
# Also falls back on getch() if get_wch() raises curses.error, to work
|
|
|
|
# around an issue when resizing the terminal on at least macOS Catalina.
|
|
|
|
# See https://github.com/ulfalizer/Kconfiglib/issues/84.
|
|
|
|
#
|
|
|
|
# Also handles a PDCurses resizing quirk.
|
2019-06-24 08:01:09 +02:00
|
|
|
|
2020-01-13 10:38:45 +01:00
|
|
|
try:
|
2019-06-24 08:01:09 +02:00
|
|
|
c = win.get_wch()
|
2020-01-13 10:38:45 +01:00
|
|
|
except (AttributeError, curses.error):
|
2019-06-24 08:01:09 +02:00
|
|
|
c = win.getch()
|
|
|
|
if 0 <= c <= 255:
|
|
|
|
c = chr(c)
|
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
# Decent resizing behavior on PDCurses requires calling resize_term(0, 0)
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
# after receiving KEY_RESIZE, while ncurses (usually) handles terminal
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
# resizing automatically in get(_w)ch() (see the end of the
|
|
|
|
# resizeterm(3NCURSES) man page).
|
|
|
|
#
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
# resize_term(0, 0) reliably fails and does nothing on ncurses, so this
|
|
|
|
# hack gives ncurses/PDCurses compatibility for resizing. I don't know
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
# whether it would cause trouble for other implementations.
|
|
|
|
if c == curses.KEY_RESIZE:
|
|
|
|
try:
|
|
|
|
curses.resize_term(0, 0)
|
|
|
|
except curses.error:
|
|
|
|
pass
|
|
|
|
|
|
|
|
return c
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
2018-09-15 08:45:50 +02:00
|
|
|
def _warn(*args):
|
|
|
|
# Temporarily returns from curses to shell mode and prints a warning to
|
|
|
|
# stderr. The warning would get lost in curses mode.
|
|
|
|
curses.endwin()
|
|
|
|
print("menuconfig warning: ", end="", file=sys.stderr)
|
|
|
|
print(*args, file=sys.stderr)
|
|
|
|
curses.doupdate()
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
# Ignore exceptions from some functions that might fail, e.g. for small
|
|
|
|
# windows. They usually do reasonable things anyway.
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
def _safe_curs_set(visibility):
|
|
|
|
try:
|
|
|
|
curses.curs_set(visibility)
|
|
|
|
except curses.error:
|
|
|
|
pass
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
def _safe_addstr(win, *args):
|
2018-09-15 08:45:50 +02:00
|
|
|
# Clip the line to avoid wrapping to the next line, which looks glitchy.
|
|
|
|
# addchstr() would do it for us, but it's not available in the 'curses'
|
|
|
|
# module.
|
|
|
|
|
|
|
|
attr = None
|
|
|
|
if isinstance(args[0], str):
|
|
|
|
y, x = win.getyx()
|
|
|
|
s = args[0]
|
|
|
|
if len(args) == 2:
|
|
|
|
attr = args[1]
|
|
|
|
else:
|
2019-09-04 15:11:57 +02:00
|
|
|
y, x, s = args[:3] # pylint: disable=unbalanced-tuple-unpacking
|
2018-09-15 08:45:50 +02:00
|
|
|
if len(args) == 4:
|
|
|
|
attr = args[3]
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
maxlen = _width(win) - x
|
2018-09-15 08:45:50 +02:00
|
|
|
s = s.expandtabs()
|
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
try:
|
2018-09-15 08:45:50 +02:00
|
|
|
# The 'curses' module uses wattr_set() internally if you pass 'attr',
|
|
|
|
# overwriting the background style, so setting 'attr' to 0 in the first
|
|
|
|
# case won't do the right thing
|
|
|
|
if attr is None:
|
|
|
|
win.addnstr(y, x, s, maxlen)
|
|
|
|
else:
|
|
|
|
win.addnstr(y, x, s, maxlen, attr)
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
except curses.error:
|
|
|
|
pass
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
def _safe_addch(win, *args):
|
|
|
|
try:
|
|
|
|
win.addch(*args)
|
|
|
|
except curses.error:
|
|
|
|
pass
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
def _safe_hline(win, *args):
|
|
|
|
try:
|
|
|
|
win.hline(*args)
|
|
|
|
except curses.error:
|
|
|
|
pass
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
def _safe_vline(win, *args):
|
|
|
|
try:
|
|
|
|
win.vline(*args)
|
|
|
|
except curses.error:
|
|
|
|
pass
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
def _safe_move(win, *args):
|
|
|
|
try:
|
|
|
|
win.move(*args)
|
|
|
|
except curses.error:
|
|
|
|
pass
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
2019-06-24 08:01:09 +02:00
|
|
|
def _change_c_lc_ctype_to_utf8():
|
|
|
|
# See _CHANGE_C_LC_CTYPE_TO_UTF8
|
2018-05-08 17:51:11 +02:00
|
|
|
|
|
|
|
if _IS_WINDOWS:
|
|
|
|
# Windows rarely has issues here, and the PEP 538 implementation avoids
|
|
|
|
# changing the locale on it. None of the UTF-8 locales below were
|
|
|
|
# supported from some quick testing either. Play it safe.
|
|
|
|
return
|
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
def try_set_locale(loc):
|
2018-05-08 17:51:11 +02:00
|
|
|
try:
|
|
|
|
locale.setlocale(locale.LC_CTYPE, loc)
|
|
|
|
return True
|
|
|
|
except locale.Error:
|
|
|
|
return False
|
|
|
|
|
|
|
|
# Is LC_CTYPE set to the C locale?
|
2019-06-24 08:01:09 +02:00
|
|
|
if locale.setlocale(locale.LC_CTYPE) == "C":
|
2018-05-08 17:51:11 +02:00
|
|
|
# This list was taken from the PEP 538 implementation in the CPython
|
|
|
|
# code, in Python/pylifecycle.c
|
|
|
|
for loc in "C.UTF-8", "C.utf8", "UTF-8":
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
if try_set_locale(loc):
|
2019-06-24 08:01:09 +02:00
|
|
|
# LC_CTYPE successfully changed
|
|
|
|
return
|
2018-05-08 17:51:11 +02:00
|
|
|
|
kconfiglib/menuconfig: Various behavior/UI improvements
Update Kconfiglib and menuconfig to upstream revision 90c5573c19, to get
these commits in:
Warn for unquoted argument to 'source', etc.
Print a warning suggesting to add quotes for things like
source foo/bar/Kconfig
menu title
prompt unquoted
Example warning:
Kconfig:32: warning: style: quotes recommended around
'lib/Kconfig.debug' in 'source lib/Kconfig.debug'
That quoteless syntax is supported for compatibility with old
versions of the C tools. It only works for a single word.
==================================================================
menuconfig: Include all parents in menu paths
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.
==================================================================
menuconfig: Fix display issue for optional-prompt menuconfigs
_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.
==================================================================
menuconfig: Remember last saved/loaded path and improve
_conf_changed
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.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-18 15:00:42 +01:00
|
|
|
|
scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.
The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.
A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.
For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.
Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.
The CMake parts are originally by Sebastian Bøe.
Description, taken from the menuconfig.py docstring:
Overview
========
A curses-based menuconfig implementation. The interface should feel
familiar to people used to mconf ('make menuconfig').
Supports the same keys as mconf, and also supports a set of
keybindings inspired by Vi:
J/K : Down/Up
L : Enter menu/Toggle item
H : Leave menu
Ctrl-D/U: Page Down/Page Down
G/End : Jump to end of list
g/Home : Jump to beginning of list
The mconf feature where pressing a key jumps to a menu entry with
that character in it in the current menu isn't supported. A search
feature with a "jump to" function for jumping directly to a
particular symbol regardless of where it is defined will be added
later instead.
Space and Enter are "smart" and try to do what you'd expect for the
given menu entry.
Running
=======
menuconfig.py can be run either as a standalone executable or by
calling the menu.menuconfig() function with an existing Kconfig
instance. The second option is a bit inflexible in that it will
still load and save .config, etc.
When run in standalone mode, the top-level Kconfig file to load can
be passed as a command-line argument. With no argument, it defaults
to "Kconfig".
The KCONFIG_CONFIG environment variable specifies the .config file
to load (if it exists) and save. If KCONFIG_CONFIG is unset,
".config" is used.
$srctree is supported through Kconfiglib.
Other features
==============
- Seamless terminal resizing
- No dependencies on *nix, as the 'curses' module is in the Python
standard library
- Unicode text entry
- Improved information screen compared to mconf:
* Expressions are split up by their top-level &&/|| operands
to improve readability
* Undefined symbols in expressions are pointed out
* Menus and comments have information displays
* Kconfig definitions are printed
Limitations
===========
- Python 3 only
This is mostly due to Python 2 not having curses.get_wch(),
which is needed for Unicode support.
- Doesn't work out of the box on Windows
Has been tested to work with the wheels provided at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-04-24 12:28:48 +02:00
|
|
|
if __name__ == "__main__":
|
2018-06-15 19:30:34 +02:00
|
|
|
_main()
|