Linux-KBuild Archive mirror
 help / color / mirror / Atom feed
From: Tomasz Figa <tfiga@chromium.org>
To: linux-kbuild@vger.kernel.org
Cc: Nicolas Schier <n.schier@avm.de>,
	Masahiro Yamada <masahiroy@kernel.org>,
	linux-kernel@vger.kernel.org,
	Jesse Taube <Mr.Bossman075@gmail.com>,
	Tomasz Figa <tfiga@chromium.org>
Subject: [PATCH v2] kconfig: menuconfig: Make hidden options show with different color
Date: Wed, 28 Feb 2024 15:00:05 +0900	[thread overview]
Message-ID: <20240228060006.13274-1-tfiga@chromium.org> (raw)

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.

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;
 			}
 		}
-- 
2.39.2


             reply	other threads:[~2024-02-28  6:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-28  6:00 Tomasz Figa [this message]
2024-02-28  7:36 ` [PATCH v2] kconfig: menuconfig: Make hidden options show with different color Nicolas Schier
2024-02-28 16:36 ` Matthew Bystrin
2024-02-29  1:57   ` Masahiro Yamada
2024-03-05  7:47     ` Tomasz Figa
2024-03-05 14:15       ` Masahiro Yamada
2024-03-06  7:35         ` Tomasz Figa
2024-02-29  1:58 ` Masahiro Yamada
2024-02-29  5:40 ` Randy Dunlap
2024-03-05  7:49   ` Tomasz Figa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240228060006.13274-1-tfiga@chromium.org \
    --to=tfiga@chromium.org \
    --cc=Mr.Bossman075@gmail.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masahiroy@kernel.org \
    --cc=n.schier@avm.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).