Message ID | 20240228060006.13274-1-tfiga@chromium.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [v2] kconfig: menuconfig: Make hidden options show with different color | expand |
On Wed, Feb 28, 2024 at 03:00:05PM +0900, Tomasz Figa wrote: > When hidden options are toggled on (using 'z'), the number of options > on the screen can be overwhelming and may make it hard to distinguish > between available and hidden ones. Make them easier to distinguish by > displaying the hidden one with a different color (COLOR_YELLOW for color > themes and A_DIM for mono). > > Signed-off-by: Tomasz Figa <tfiga@chromium.org> > --- > scripts/kconfig/lxdialog/dialog.h | 5 +++++ > scripts/kconfig/lxdialog/menubox.c | 12 ++++++++---- > scripts/kconfig/lxdialog/util.c | 19 +++++++++++++++++++ > scripts/kconfig/mconf.c | 18 ++++++++++++++++++ > 4 files changed, 50 insertions(+), 4 deletions(-) > > Changes from v1: > (https://patchwork.kernel.org/project/linux-kbuild/patch/20231228054630.3595093-1-tfiga@chromium.org/) > * Replaced A_DIM for color themes with COLOR_YELLOW, because the former > has no effect to black text on some commonly used terminals, e.g. > gnome-terminal, foot. Reported by Masahiro Yamada and Nicolas Schier. > I ended up with COLOR_YELLOW, as it seems to look comparatively dim > with mutliple light and dark color themes in Chromium hterm and > gnome-terminal. Thanks, output looks good to me on my console as well as on all my terminal emulators and in all themes. Tested-by: Nicolas Schier <n.schier@avm.de>
On Wed Feb 28, 2024 at 9:00 AM MSK, Tomasz Figa wrote: > When hidden options are toggled on (using 'z'), the number of options > on the screen can be overwhelming and may make it hard to distinguish > between available and hidden ones. Make them easier to distinguish by > displaying the hidden one with a different color (COLOR_YELLOW for color > themes and A_DIM for mono). > > Signed-off-by: Tomasz Figa <tfiga@chromium.org> > --- > scripts/kconfig/lxdialog/dialog.h | 5 +++++ > scripts/kconfig/lxdialog/menubox.c | 12 ++++++++---- > scripts/kconfig/lxdialog/util.c | 19 +++++++++++++++++++ > scripts/kconfig/mconf.c | 18 ++++++++++++++++++ > 4 files changed, 50 insertions(+), 4 deletions(-) > > Changes from v1: > (https://patchwork.kernel.org/project/linux-kbuild/patch/20231228054630.3595093-1-tfiga@chromium.org/) > * Replaced A_DIM for color themes with COLOR_YELLOW, because the former > has no effect to black text on some commonly used terminals, e.g. > gnome-terminal, foot. Reported by Masahiro Yamada and Nicolas Schier. > I ended up with COLOR_YELLOW, as it seems to look comparatively dim > with mutliple light and dark color themes in Chromium hterm and > gnome-terminal. Thanks! Run a quick tests in xterm. Looks neat! Is there a reason to set hidden flag in all of the _if_ and _switch_ statements in the build_conf() function? Could similar be done in a more generic way? For example: visible = menu_is_visible(menu); if (!visible) item_set_hidden(TRUE); Or this approach will bring some negative side effects ?
On Thu, Feb 29, 2024 at 1:36 AM Matthew Bystrin <dev.mbstr@gmail.com> wrote: > > On Wed Feb 28, 2024 at 9:00 AM MSK, Tomasz Figa wrote: > > When hidden options are toggled on (using 'z'), the number of options > > on the screen can be overwhelming and may make it hard to distinguish > > between available and hidden ones. Make them easier to distinguish by > > displaying the hidden one with a different color (COLOR_YELLOW for color > > themes and A_DIM for mono). > > > > Signed-off-by: Tomasz Figa <tfiga@chromium.org> > > --- > > scripts/kconfig/lxdialog/dialog.h | 5 +++++ > > scripts/kconfig/lxdialog/menubox.c | 12 ++++++++---- > > scripts/kconfig/lxdialog/util.c | 19 +++++++++++++++++++ > > scripts/kconfig/mconf.c | 18 ++++++++++++++++++ > > 4 files changed, 50 insertions(+), 4 deletions(-) > > > > Changes from v1: > > (https://patchwork.kernel.org/project/linux-kbuild/patch/20231228054630.3595093-1-tfiga@chromium.org/) > > * Replaced A_DIM for color themes with COLOR_YELLOW, because the former > > has no effect to black text on some commonly used terminals, e.g. > > gnome-terminal, foot. Reported by Masahiro Yamada and Nicolas Schier. > > I ended up with COLOR_YELLOW, as it seems to look comparatively dim > > with mutliple light and dark color themes in Chromium hterm and > > gnome-terminal. > > Thanks! Run a quick tests in xterm. Looks neat! > > Is there a reason to set hidden flag in all of the _if_ and _switch_ statements > in the build_conf() function? Could similar be done in a more generic way? For > example: > > visible = menu_is_visible(menu); > if (!visible) > item_set_hidden(TRUE); > > Or this approach will bring some negative side effects ? > I guess he just inserted item_set_hidden() where he saw item_make(). Since build_conf() resources to itself, the code flow is difficult to track. You can safely factor it out in some places (for example, just blow), but that does not make a big difference. diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index b7e08ec98717..ba0f177121ed 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c @@ -546,16 +546,15 @@ static void build_conf(struct menu *menu) } item_set_tag('t'); item_set_data(menu); - if (!visible) - item_set_hidden(TRUE); } else { item_make(" "); item_set_tag(def_menu ? 't' : ':'); item_set_data(menu); - if (!visible) - item_set_hidden(TRUE); } + if (!visible) + item_set_hidden(TRUE); + item_add_str("%*c%s", indent + 1, ' ', menu_get_prompt(menu)); if (val == yes) { if (def_menu) {
On Wed, Feb 28, 2024 at 3:00 PM Tomasz Figa <tfiga@chromium.org> wrote: > > When hidden options are toggled on (using 'z'), the number of options > on the screen can be overwhelming and may make it hard to distinguish > between available and hidden ones. Make them easier to distinguish by > displaying the hidden one with a different color (COLOR_YELLOW for color > themes and A_DIM for mono). > > Signed-off-by: Tomasz Figa <tfiga@chromium.org> > --- > diff --git a/scripts/kconfig/lxdialog/util.c b/scripts/kconfig/lxdialog/util.c > index 3f78fb265136..161224dd6fb5 100644 > --- a/scripts/kconfig/lxdialog/util.c > +++ b/scripts/kconfig/lxdialog/util.c > @@ -38,6 +38,8 @@ static void set_mono_theme(void) > dlg.menubox_border.atr = A_NORMAL; > dlg.item.atr = A_NORMAL; > dlg.item_selected.atr = A_REVERSE; > + dlg.item_hidden.atr = A_NORMAL | A_DIM; Nit. (A_NORMAL | A_DIM) should be A_DIM. A_NORMAL is zero. Other A_* attributes are bit flags that can be OR'ed. -- Best Regards Masahiro Yamada
Hi, On 2/27/24 22:00, Tomasz Figa wrote: > When hidden options are toggled on (using 'z'), the number of options > on the screen can be overwhelming and may make it hard to distinguish > between available and hidden ones. Make them easier to distinguish by > displaying the hidden one with a different color (COLOR_YELLOW for color > themes and A_DIM for mono). > Signed-off-by: Tomasz Figa <tfiga@chromium.org> > --- > scripts/kconfig/lxdialog/dialog.h | 5 +++++ > scripts/kconfig/lxdialog/menubox.c | 12 ++++++++---- > scripts/kconfig/lxdialog/util.c | 19 +++++++++++++++++++ > scripts/kconfig/mconf.c | 18 ++++++++++++++++++ > 4 files changed, 50 insertions(+), 4 deletions(-) > Changes from v1: > (https://patchwork.kernel.org/project/linux-kbuild/patch/20231228054630.3595093-1-tfiga@chromium.org/) > * Replaced A_DIM for color themes with COLOR_YELLOW, because the former > has no effect to black text on some commonly used terminals, e.g. > gnome-terminal, foot. Reported by Masahiro Yamada and Nicolas Schier. > I ended up with COLOR_YELLOW, as it seems to look comparatively dim > with mutliple light and dark color themes in Chromium hterm and > gnome-terminal. I guess COLOR_YELLOW is a relative thing, i.e., it depends on the term's current color scheme in my testing. With rxvt (with a beige/khaki background), I do see yellow. With xfce4-terminal (with amber/orange foreground on black background, i.e., my default from days of amber monochrome displays ;), the "yellow" comes out as a faded/washed out/dim orange. But still readable. Anyway, this looks useful to me. Acked-by: Randy Dunlap <rdunlap@infradead.org> Tested-by: Randy Dunlap <rdunlap@infradead.org> thanks.
On Thu, Feb 29, 2024 at 10:57 AM Masahiro Yamada <masahiroy@kernel.org> wrote: > > On Thu, Feb 29, 2024 at 1:36 AM Matthew Bystrin <dev.mbstr@gmail.com> wrote: > > > > On Wed Feb 28, 2024 at 9:00 AM MSK, Tomasz Figa wrote: > > > When hidden options are toggled on (using 'z'), the number of options > > > on the screen can be overwhelming and may make it hard to distinguish > > > between available and hidden ones. Make them easier to distinguish by > > > displaying the hidden one with a different color (COLOR_YELLOW for color > > > themes and A_DIM for mono). > > > > > > Signed-off-by: Tomasz Figa <tfiga@chromium.org> > > > --- > > > scripts/kconfig/lxdialog/dialog.h | 5 +++++ > > > scripts/kconfig/lxdialog/menubox.c | 12 ++++++++---- > > > scripts/kconfig/lxdialog/util.c | 19 +++++++++++++++++++ > > > scripts/kconfig/mconf.c | 18 ++++++++++++++++++ > > > 4 files changed, 50 insertions(+), 4 deletions(-) > > > > > > Changes from v1: > > > (https://patchwork.kernel.org/project/linux-kbuild/patch/20231228054630.3595093-1-tfiga@chromium.org/) > > > * Replaced A_DIM for color themes with COLOR_YELLOW, because the former > > > has no effect to black text on some commonly used terminals, e.g. > > > gnome-terminal, foot. Reported by Masahiro Yamada and Nicolas Schier. > > > I ended up with COLOR_YELLOW, as it seems to look comparatively dim > > > with mutliple light and dark color themes in Chromium hterm and > > > gnome-terminal. > > > > Thanks! Run a quick tests in xterm. Looks neat! > > > > Is there a reason to set hidden flag in all of the _if_ and _switch_ statements > > in the build_conf() function? Could similar be done in a more generic way? For > > example: > > > > visible = menu_is_visible(menu); > > if (!visible) > > item_set_hidden(TRUE); > > > > Or this approach will bring some negative side effects ? > > > > > I guess he just inserted item_set_hidden() where he saw item_make(). > > > Since build_conf() resources to itself, the code flow > is difficult to track. > > > You can safely factor it out in some places (for example, just blow), > but that does not make a big difference. > > > > diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c > index b7e08ec98717..ba0f177121ed 100644 > --- a/scripts/kconfig/mconf.c > +++ b/scripts/kconfig/mconf.c > @@ -546,16 +546,15 @@ static void build_conf(struct menu *menu) > } > item_set_tag('t'); > item_set_data(menu); > - if (!visible) > - item_set_hidden(TRUE); > } else { > item_make(" "); > item_set_tag(def_menu ? 't' : ':'); > item_set_data(menu); > - if (!visible) > - item_set_hidden(TRUE); I wanted to be consistent with the current code, which already has the same item_set_data(menu) in both branches. I'm okay with either. Do you want me to resend with this change? Best regards, Tomasz > } > > + if (!visible) > + item_set_hidden(TRUE); > + > item_add_str("%*c%s", indent + 1, ' ', menu_get_prompt(menu)); > if (val == yes) { > if (def_menu) { > > > > > > > > > -- > Best Regards > Masahiro Yamada
On Thu, Feb 29, 2024 at 2:40 PM Randy Dunlap <rdunlap@infradead.org> wrote: > > Hi, > > On 2/27/24 22:00, Tomasz Figa wrote: > > When hidden options are toggled on (using 'z'), the number of options > > on the screen can be overwhelming and may make it hard to distinguish > > between available and hidden ones. Make them easier to distinguish by > > displaying the hidden one with a different color (COLOR_YELLOW for color > > themes and A_DIM for mono). > > > > Signed-off-by: Tomasz Figa <tfiga@chromium.org> > > --- > > scripts/kconfig/lxdialog/dialog.h | 5 +++++ > > scripts/kconfig/lxdialog/menubox.c | 12 ++++++++---- > > scripts/kconfig/lxdialog/util.c | 19 +++++++++++++++++++ > > scripts/kconfig/mconf.c | 18 ++++++++++++++++++ > > 4 files changed, 50 insertions(+), 4 deletions(-) > > > > Changes from v1: > > (https://patchwork.kernel.org/project/linux-kbuild/patch/20231228054630.3595093-1-tfiga@chromium.org/) > > * Replaced A_DIM for color themes with COLOR_YELLOW, because the former > > has no effect to black text on some commonly used terminals, e.g. > > gnome-terminal, foot. Reported by Masahiro Yamada and Nicolas Schier. > > I ended up with COLOR_YELLOW, as it seems to look comparatively dim > > with mutliple light and dark color themes in Chromium hterm and > > gnome-terminal. > > I guess COLOR_YELLOW is a relative thing, i.e., it depends on the term's > current color scheme in my testing. Yeah, it's kind of on the edge of being relatively neutral, i.e. not standing out much more than the visible options, but I couldn't really find anything that would work better for the standard 16-color mode. An alternative would be to implement support for the 256-color mode, but that would likely require quite a lot of changes in the existing code (and I'm not very familiar with how to do it in ncurses...). > > With rxvt (with a beige/khaki background), I do see yellow. > > With xfce4-terminal (with amber/orange foreground on black background, > i.e., my default from days of amber monochrome displays ;), the "yellow" > comes out as a faded/washed out/dim orange. But still readable. > > Anyway, this looks useful to me. > > Acked-by: Randy Dunlap <rdunlap@infradead.org> > Tested-by: Randy Dunlap <rdunlap@infradead.org> Thanks a lot! Best regards, Tomasz
On Tue, Mar 5, 2024 at 4:47 PM Tomasz Figa <tfiga@chromium.org> wrote: > > On Thu, Feb 29, 2024 at 10:57 AM Masahiro Yamada <masahiroy@kernel.org> wrote: > > > > On Thu, Feb 29, 2024 at 1:36 AM Matthew Bystrin <dev.mbstr@gmail.com> wrote: > > > > > > On Wed Feb 28, 2024 at 9:00 AM MSK, Tomasz Figa wrote: > > > > When hidden options are toggled on (using 'z'), the number of options > > > > on the screen can be overwhelming and may make it hard to distinguish > > > > between available and hidden ones. Make them easier to distinguish by > > > > displaying the hidden one with a different color (COLOR_YELLOW for color > > > > themes and A_DIM for mono). > > > > > > > > Signed-off-by: Tomasz Figa <tfiga@chromium.org> > > > > --- > > > > scripts/kconfig/lxdialog/dialog.h | 5 +++++ > > > > scripts/kconfig/lxdialog/menubox.c | 12 ++++++++---- > > > > scripts/kconfig/lxdialog/util.c | 19 +++++++++++++++++++ > > > > scripts/kconfig/mconf.c | 18 ++++++++++++++++++ > > > > 4 files changed, 50 insertions(+), 4 deletions(-) > > > > > > > > Changes from v1: > > > > (https://patchwork.kernel.org/project/linux-kbuild/patch/20231228054630.3595093-1-tfiga@chromium.org/) > > > > * Replaced A_DIM for color themes with COLOR_YELLOW, because the former > > > > has no effect to black text on some commonly used terminals, e.g. > > > > gnome-terminal, foot. Reported by Masahiro Yamada and Nicolas Schier. > > > > I ended up with COLOR_YELLOW, as it seems to look comparatively dim > > > > with mutliple light and dark color themes in Chromium hterm and > > > > gnome-terminal. > > > > > > Thanks! Run a quick tests in xterm. Looks neat! > > > > > > Is there a reason to set hidden flag in all of the _if_ and _switch_ statements > > > in the build_conf() function? Could similar be done in a more generic way? For > > > example: > > > > > > visible = menu_is_visible(menu); > > > if (!visible) > > > item_set_hidden(TRUE); > > > > > > Or this approach will bring some negative side effects ? > > > > > > > > > I guess he just inserted item_set_hidden() where he saw item_make(). > > > > > > Since build_conf() resources to itself, the code flow > > is difficult to track. > > > > > > You can safely factor it out in some places (for example, just blow), > > but that does not make a big difference. > > > > > > > > diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c > > index b7e08ec98717..ba0f177121ed 100644 > > --- a/scripts/kconfig/mconf.c > > +++ b/scripts/kconfig/mconf.c > > @@ -546,16 +546,15 @@ static void build_conf(struct menu *menu) > > } > > item_set_tag('t'); > > item_set_data(menu); > > - if (!visible) > > - item_set_hidden(TRUE); > > } else { > > item_make(" "); > > item_set_tag(def_menu ? 't' : ':'); > > item_set_data(menu); > > - if (!visible) > > - item_set_hidden(TRUE); > > I wanted to be consistent with the current code, which already has the > same item_set_data(menu) in both branches. I'm okay with either. Do > you want me to resend with this change? I am fine with either way. I thought build_conf() was messy, but it is not a problem with your patch. Talking about the code consistency, what about this suggestion? https://lore.kernel.org/linux-kbuild/CAAFQd5AOvUtHOOU-OKQKJwyJGXSt6EopcMBsHWz83n_0XfnOjA@mail.gmail.com/T/#med19d030bf8167637964b58da0f5b86b18fe3f5e In line 26, A_DIM is directly assigned. dlg.button_inactive.atr = A_DIM; If you verbosely add 'A_NORMAL |', the other line should look like this: dlg.item_hidden_selected.atr = A_NORMAL | A_REVERSE | A_DIM; And, we need to insert 'A_NORMAL |' to every assignment. If you agree with me, you can offer to modify the patch locally.
On Tue, Mar 5, 2024 at 11:15 PM Masahiro Yamada <masahiroy@kernel.org> wrote: > > On Tue, Mar 5, 2024 at 4:47 PM Tomasz Figa <tfiga@chromium.org> wrote: > > > > On Thu, Feb 29, 2024 at 10:57 AM Masahiro Yamada <masahiroy@kernel.org> wrote: > > > > > > On Thu, Feb 29, 2024 at 1:36 AM Matthew Bystrin <dev.mbstr@gmail.com> wrote: > > > > > > > > On Wed Feb 28, 2024 at 9:00 AM MSK, Tomasz Figa wrote: > > > > > When hidden options are toggled on (using 'z'), the number of options > > > > > on the screen can be overwhelming and may make it hard to distinguish > > > > > between available and hidden ones. Make them easier to distinguish by > > > > > displaying the hidden one with a different color (COLOR_YELLOW for color > > > > > themes and A_DIM for mono). > > > > > > > > > > Signed-off-by: Tomasz Figa <tfiga@chromium.org> > > > > > --- > > > > > scripts/kconfig/lxdialog/dialog.h | 5 +++++ > > > > > scripts/kconfig/lxdialog/menubox.c | 12 ++++++++---- > > > > > scripts/kconfig/lxdialog/util.c | 19 +++++++++++++++++++ > > > > > scripts/kconfig/mconf.c | 18 ++++++++++++++++++ > > > > > 4 files changed, 50 insertions(+), 4 deletions(-) > > > > > > > > > > Changes from v1: > > > > > (https://patchwork.kernel.org/project/linux-kbuild/patch/20231228054630.3595093-1-tfiga@chromium.org/) > > > > > * Replaced A_DIM for color themes with COLOR_YELLOW, because the former > > > > > has no effect to black text on some commonly used terminals, e.g. > > > > > gnome-terminal, foot. Reported by Masahiro Yamada and Nicolas Schier. > > > > > I ended up with COLOR_YELLOW, as it seems to look comparatively dim > > > > > with mutliple light and dark color themes in Chromium hterm and > > > > > gnome-terminal. > > > > > > > > Thanks! Run a quick tests in xterm. Looks neat! > > > > > > > > Is there a reason to set hidden flag in all of the _if_ and _switch_ statements > > > > in the build_conf() function? Could similar be done in a more generic way? For > > > > example: > > > > > > > > visible = menu_is_visible(menu); > > > > if (!visible) > > > > item_set_hidden(TRUE); > > > > > > > > Or this approach will bring some negative side effects ? > > > > > > > > > > > > > I guess he just inserted item_set_hidden() where he saw item_make(). > > > > > > > > > Since build_conf() resources to itself, the code flow > > > is difficult to track. > > > > > > > > > You can safely factor it out in some places (for example, just blow), > > > but that does not make a big difference. > > > > > > > > > > > > diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c > > > index b7e08ec98717..ba0f177121ed 100644 > > > --- a/scripts/kconfig/mconf.c > > > +++ b/scripts/kconfig/mconf.c > > > @@ -546,16 +546,15 @@ static void build_conf(struct menu *menu) > > > } > > > item_set_tag('t'); > > > item_set_data(menu); > > > - if (!visible) > > > - item_set_hidden(TRUE); > > > } else { > > > item_make(" "); > > > item_set_tag(def_menu ? 't' : ':'); > > > item_set_data(menu); > > > - if (!visible) > > > - item_set_hidden(TRUE); > > > > I wanted to be consistent with the current code, which already has the > > same item_set_data(menu) in both branches. I'm okay with either. Do > > you want me to resend with this change? > > > > I am fine with either way. > I thought build_conf() was messy, > but it is not a problem with your patch. > > > > Talking about the code consistency, what about this suggestion? > > https://lore.kernel.org/linux-kbuild/CAAFQd5AOvUtHOOU-OKQKJwyJGXSt6EopcMBsHWz83n_0XfnOjA@mail.gmail.com/T/#med19d030bf8167637964b58da0f5b86b18fe3f5e > > > In line 26, A_DIM is directly assigned. > > dlg.button_inactive.atr = A_DIM; > > > > If you verbosely add 'A_NORMAL |', > the other line should look like this: > > > dlg.item_hidden_selected.atr = A_NORMAL | A_REVERSE | A_DIM; > > > And, we need to insert 'A_NORMAL |' > to every assignment. > > > > If you agree with me, you can offer to modify the patch locally. > Ah, sorry, missed that email. I think we can just remove A_NORMAL if we have the other bits, as you suggested in your first reply. Let me fix that. Best regards, Tomasz
diff --git a/scripts/kconfig/lxdialog/dialog.h b/scripts/kconfig/lxdialog/dialog.h index a501abf9fa31..2bba0c406038 100644 --- a/scripts/kconfig/lxdialog/dialog.h +++ b/scripts/kconfig/lxdialog/dialog.h @@ -100,6 +100,8 @@ struct dialog_info { struct dialog_color menubox_border; struct dialog_color item; struct dialog_color item_selected; + struct dialog_color item_hidden; + struct dialog_color item_hidden_selected; struct dialog_color tag; struct dialog_color tag_selected; struct dialog_color tag_key; @@ -128,6 +130,7 @@ void item_add_str(const char *fmt, ...); void item_set_tag(char tag); void item_set_data(void *p); void item_set_selected(int val); +void item_set_hidden(int val); int item_activate_selected(void); void *item_data(void); char item_tag(void); @@ -139,6 +142,7 @@ struct dialog_item { char tag; void *data; /* pointer to menu item - used by menubox+checklist */ int selected; /* Set to 1 by dialog_*() function if selected. */ + int hidden; /* Set to 1 if hidden. */ }; /* list of lialog_items */ @@ -157,6 +161,7 @@ int item_n(void); const char *item_str(void); int item_is_selected(void); int item_is_tag(char tag); +int item_is_hidden(void); #define item_foreach() \ for (item_cur = item_head ? item_head: item_cur; \ item_cur && (item_cur != &item_nil); item_cur = item_cur->next) diff --git a/scripts/kconfig/lxdialog/menubox.c b/scripts/kconfig/lxdialog/menubox.c index 0e333284e947..3bff89eb8cdf 100644 --- a/scripts/kconfig/lxdialog/menubox.c +++ b/scripts/kconfig/lxdialog/menubox.c @@ -51,9 +51,9 @@ static int menu_width, item_x; * Print menu item */ static void do_print_item(WINDOW * win, const char *item, int line_y, - int selected, int hotkey) + int selected, int hotkey, int hidden) { - int j; + int j, attrs; char *menu_item = malloc(menu_width + 1); strncpy(menu_item, item, menu_width - item_x); @@ -64,7 +64,11 @@ static void do_print_item(WINDOW * win, const char *item, int line_y, wattrset(win, dlg.menubox.atr); wmove(win, line_y, 0); wclrtoeol(win); - wattrset(win, selected ? dlg.item_selected.atr : dlg.item.atr); + if (hidden) + attrs = selected ? dlg.item_hidden_selected.atr : dlg.item_hidden.atr; + else + attrs = selected ? dlg.item_selected.atr : dlg.item.atr; + wattrset(win, attrs); mvwaddstr(win, line_y, item_x, menu_item); if (hotkey) { wattrset(win, selected ? dlg.tag_key_selected.atr @@ -81,7 +85,7 @@ static void do_print_item(WINDOW * win, const char *item, int line_y, #define print_item(index, choice, selected) \ do { \ item_set(index); \ - do_print_item(menu, item_str(), choice, selected, !item_is_tag(':')); \ + do_print_item(menu, item_str(), choice, selected, !item_is_tag(':'), item_is_hidden()); \ } while (0) /* diff --git a/scripts/kconfig/lxdialog/util.c b/scripts/kconfig/lxdialog/util.c index 3f78fb265136..161224dd6fb5 100644 --- a/scripts/kconfig/lxdialog/util.c +++ b/scripts/kconfig/lxdialog/util.c @@ -38,6 +38,8 @@ static void set_mono_theme(void) dlg.menubox_border.atr = A_NORMAL; dlg.item.atr = A_NORMAL; dlg.item_selected.atr = A_REVERSE; + dlg.item_hidden.atr = A_NORMAL | A_DIM; + dlg.item_hidden_selected.atr = A_REVERSE | A_DIM; dlg.tag.atr = A_BOLD; dlg.tag_selected.atr = A_REVERSE; dlg.tag_key.atr = A_BOLD; @@ -78,6 +80,8 @@ static void set_classic_theme(void) DLG_COLOR(menubox_border, COLOR_WHITE, COLOR_WHITE, true); DLG_COLOR(item, COLOR_BLACK, COLOR_WHITE, false); DLG_COLOR(item_selected, COLOR_WHITE, COLOR_BLUE, true); + DLG_COLOR(item_hidden, COLOR_YELLOW, COLOR_WHITE, false); + DLG_COLOR(item_hidden_selected, COLOR_WHITE, COLOR_BLUE, true); DLG_COLOR(tag, COLOR_YELLOW, COLOR_WHITE, true); DLG_COLOR(tag_selected, COLOR_YELLOW, COLOR_BLUE, true); DLG_COLOR(tag_key, COLOR_YELLOW, COLOR_WHITE, true); @@ -118,6 +122,9 @@ static void set_blackbg_theme(void) DLG_COLOR(item, COLOR_WHITE, COLOR_BLACK, false); DLG_COLOR(item_selected, COLOR_WHITE, COLOR_RED, false); + DLG_COLOR(item_hidden, COLOR_YELLOW, COLOR_BLACK, false); + DLG_COLOR(item_hidden_selected, COLOR_YELLOW, COLOR_RED, false); + DLG_COLOR(tag, COLOR_RED, COLOR_BLACK, false); DLG_COLOR(tag_selected, COLOR_YELLOW, COLOR_RED, true); DLG_COLOR(tag_key, COLOR_RED, COLOR_BLACK, false); @@ -198,6 +205,8 @@ static void init_dialog_colors(void) init_one_color(&dlg.menubox_border); init_one_color(&dlg.item); init_one_color(&dlg.item_selected); + init_one_color(&dlg.item_hidden); + init_one_color(&dlg.item_hidden_selected); init_one_color(&dlg.tag); init_one_color(&dlg.tag_selected); init_one_color(&dlg.tag_key); @@ -635,6 +644,11 @@ void item_set_selected(int val) item_cur->node.selected = val; } +void item_set_hidden(int val) +{ + item_cur->node.hidden = val; +} + int item_activate_selected(void) { item_foreach() @@ -698,3 +712,8 @@ int item_is_tag(char tag) { return (item_cur->node.tag == tag); } + +int item_is_hidden(void) +{ + return (item_cur->node.hidden != 0); +} diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index f4bb391d50cf..b7e08ec98717 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c @@ -488,6 +488,8 @@ static void build_conf(struct menu *menu) menu_is_empty(menu) ? "----" : "--->"); item_set_tag('m'); item_set_data(menu); + if (!visible) + item_set_hidden(TRUE); if (single_menu_mode && menu->data) goto conf_childs; return; @@ -497,6 +499,8 @@ static void build_conf(struct menu *menu) item_make(" %*c*** %s ***", indent + 1, ' ', prompt); item_set_tag(':'); item_set_data(menu); + if (!visible) + item_set_hidden(TRUE); } break; default: @@ -505,6 +509,8 @@ static void build_conf(struct menu *menu) item_make("---%*c%s", indent + 1, ' ', prompt); item_set_tag(':'); item_set_data(menu); + if (!visible) + item_set_hidden(TRUE); } } } else @@ -540,10 +546,14 @@ static void build_conf(struct menu *menu) } item_set_tag('t'); item_set_data(menu); + if (!visible) + item_set_hidden(TRUE); } else { item_make(" "); item_set_tag(def_menu ? 't' : ':'); item_set_data(menu); + if (!visible) + item_set_hidden(TRUE); } item_add_str("%*c%s", indent + 1, ' ', menu_get_prompt(menu)); @@ -564,6 +574,8 @@ static void build_conf(struct menu *menu) item_make("---%*c%s", indent + 1, ' ', menu_get_prompt(menu)); item_set_tag(':'); item_set_data(menu); + if (!visible) + item_set_hidden(TRUE); goto conf_childs; } child_count++; @@ -581,6 +593,8 @@ static void build_conf(struct menu *menu) item_make("-%c-", val == no ? ' ' : '*'); item_set_tag('t'); item_set_data(menu); + if (!visible) + item_set_hidden(TRUE); break; case S_TRISTATE: switch (val) { @@ -597,6 +611,8 @@ static void build_conf(struct menu *menu) item_make("-%c-", ch); item_set_tag('t'); item_set_data(menu); + if (!visible) + item_set_hidden(TRUE); break; default: tmp = 2 + strlen(sym_get_string_value(sym)); /* () = 2 */ @@ -609,6 +625,8 @@ static void build_conf(struct menu *menu) "" : " (NEW)"); item_set_tag('s'); item_set_data(menu); + if (!visible) + item_set_hidden(TRUE); goto conf_childs; } }
When hidden options are toggled on (using 'z'), the number of options on the screen can be overwhelming and may make it hard to distinguish between available and hidden ones. Make them easier to distinguish by displaying the hidden one with a different color (COLOR_YELLOW for color themes and A_DIM for mono). Signed-off-by: Tomasz Figa <tfiga@chromium.org> --- scripts/kconfig/lxdialog/dialog.h | 5 +++++ scripts/kconfig/lxdialog/menubox.c | 12 ++++++++---- scripts/kconfig/lxdialog/util.c | 19 +++++++++++++++++++ scripts/kconfig/mconf.c | 18 ++++++++++++++++++ 4 files changed, 50 insertions(+), 4 deletions(-) Changes from v1: (https://patchwork.kernel.org/project/linux-kbuild/patch/20231228054630.3595093-1-tfiga@chromium.org/) * Replaced A_DIM for color themes with COLOR_YELLOW, because the former has no effect to black text on some commonly used terminals, e.g. gnome-terminal, foot. Reported by Masahiro Yamada and Nicolas Schier. I ended up with COLOR_YELLOW, as it seems to look comparatively dim with mutliple light and dark color themes in Chromium hterm and gnome-terminal.