diff options
author | Masahiro Yamada <masahiroy@kernel.org> | 2023-07-16 07:55:07 +0300 |
---|---|---|
committer | Masahiro Yamada <masahiroy@kernel.org> | 2023-07-24 18:59:32 +0300 |
commit | e14f1242a8be413846360b295102abd4c62848ad (patch) | |
tree | 65973a8357a893e797eb94d70e302988a6bcd7a4 /scripts/kconfig/menu.c | |
parent | 481461f5109919babbb393d6f68002936b8e2493 (diff) | |
download | linux-e14f1242a8be413846360b295102abd4c62848ad.tar.xz |
kconfig: menuconfig: simplify global jump key assignment
Commit 95ac9b3b585d ("menuconfig: Assign jump keys per-page instead
of globally") injected a lot of hacks to the bottom of the textbox
infrastructure.
I reverted many of them without changing the behavior. (almost)
Now, the key markers are inserted when constructing the search result
instead of updating the text buffer on-the-fly.
The buffer passed to the textbox got back to a constant string.
The ugly casts from (const char *) to (char *) went away.
A disadvantage is that the same key numbers might be displayed multiple
times in the dialog if you use a huge window (but I believe it is
unlikely to happen).
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Jesse Taube <Mr.Bossman075@gmail.com>
Diffstat (limited to 'scripts/kconfig/menu.c')
-rw-r--r-- | scripts/kconfig/menu.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index b90fff833588..d2f0a8efabb5 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -701,6 +701,11 @@ static void get_dep_str(struct gstr *r, struct expr *expr, const char *prefix) } } +int __attribute__((weak)) get_jump_key_char(void) +{ + return -1; +} + static void get_prompt_str(struct gstr *r, struct property *prop, struct list_head *head) { @@ -743,11 +748,22 @@ static void get_prompt_str(struct gstr *r, struct property *prop, } str_printf(r, " Location:\n"); - for (j = 4; --i >= 0; j += 2) { + for (j = 0; --i >= 0; j++) { + int jk = -1; + int indent = 2 * j + 4; + menu = submenu[i]; - if (jump && menu == location) + if (jump && menu == location) { jump->offset = strlen(r->s); - str_printf(r, "%*c-> %s", j, ' ', menu_get_prompt(menu)); + jk = get_jump_key_char(); + } + + if (jk >= 0) { + str_printf(r, "(%c)", jk); + indent -= 3; + } + + str_printf(r, "%*c-> %s", indent, ' ', menu_get_prompt(menu)); if (menu->sym) { str_printf(r, " (%s [=%s])", menu->sym->name ? menu->sym->name : "<choice>", |