From ff7b0c2c2430b5b116108441cbd0680efbef68d1 Mon Sep 17 00:00:00 2001 From: Sedat Dilek Date: Sun, 16 Jun 2013 18:43:04 +0200 Subject: kconfig/lxdialog: Use new mininimum resize definitions in conf_choice() This is a cleanup which uses the proper (new) definitions and does not change current behaviour. Signed-off-by: Sedat Dilek Reviewed-by: "Yann E. MORIN" Tested-by: "Yann E. MORIN" Signed-off-by: "Yann E. MORIN" --- Yann had some more ideas on improvements: "What would be nice is an improvement that scales the choice window to the number of entries in the choice. If there are a lot of choice entries, then the choice popup grows in height (but does not overflow the screen of course). So, instead of seeing only 6 entries, we'd see as much as possible in the current screen. Ditto for the width: the popup adapts to the longest prompt (but does not overflow the screen either, of course), so prompts are not truncated." NOTE: This patch requires [1]. [1] http://marc.info/?l=linux-kbuild&m=137128726917166&w=2 --- scripts/kconfig/mconf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'scripts/kconfig/mconf.c') diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index 387dc8daf7b2..2396c5be31ad 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c @@ -825,7 +825,9 @@ static void conf_choice(struct menu *menu) dialog_clear(); res = dialog_checklist(prompt ? _(prompt) : _("Main Menu"), _(radiolist_instructions), - 15, 70, 6); + MENUBOX_HEIGTH_MIN, + MENUBOX_WIDTH_MIN, + CHECKLIST_HEIGTH_MIN); selected = item_activate_selected(); switch (res) { case 0: -- cgit v1.2.3-59-g8ed1b From 1376391621654cc369c5e8b60497f7c184f0ed47 Mon Sep 17 00:00:00 2001 From: Dirk Gouders Date: Wed, 8 May 2013 17:29:42 +0200 Subject: kconfig/lxdialog: handle newline characters in print_autowrap() When exiting menuconfig with unsaved changes, a dialog like the following is shown: Do you wish to save your new configuration ? to continue. The author of the dialog text specified a newline after the '?', and probably expected it to be processed, so let print_autowrap() handle newlines propperly. Also, reword that dialog's second phrase with a real sentence. Signed-off-by: Dirk Gouders Tested-by: "Yann E. MORIN" Reviewed-by: "Yann E. MORIN" [yann.morin.1998@free.fr: very slightly tweak the commit message] Signed-off-by: Yann E. MORIN --- scripts/kconfig/lxdialog/util.c | 31 +++++++++++++++++-------------- scripts/kconfig/mconf.c | 4 ++-- 2 files changed, 19 insertions(+), 16 deletions(-) (limited to 'scripts/kconfig/mconf.c') diff --git a/scripts/kconfig/lxdialog/util.c b/scripts/kconfig/lxdialog/util.c index 78fe4e9d8778..0fa567eb68c6 100644 --- a/scripts/kconfig/lxdialog/util.c +++ b/scripts/kconfig/lxdialog/util.c @@ -371,27 +371,19 @@ void print_title(WINDOW *dialog, const char *title, int width) /* * Print a string of text in a window, automatically wrap around to the * next line if the string is too long to fit on one line. Newline - * characters '\n' are replaced by spaces. We start on a new line + * characters '\n' are propperly processed. We start on a new line * if there is no room for at least 4 nonblanks following a double-space. */ void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x) { int newl, cur_x, cur_y; - int i, prompt_len, room, wlen; - char tempstr[MAX_LEN + 1], *word, *sp, *sp2; + int prompt_len, room, wlen; + char tempstr[MAX_LEN + 1], *word, *sp, *sp2, *newline_separator = 0; strcpy(tempstr, prompt); prompt_len = strlen(tempstr); - /* - * Remove newlines - */ - for (i = 0; i < prompt_len; i++) { - if (tempstr[i] == '\n') - tempstr[i] = ' '; - } - if (prompt_len <= width - x * 2) { /* If prompt is short */ wmove(win, y, (width - prompt_len) / 2); waddstr(win, tempstr); @@ -401,7 +393,10 @@ void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x) newl = 1; word = tempstr; while (word && *word) { - sp = strchr(word, ' '); + sp = strpbrk(word, "\n "); + if (sp && *sp == '\n') + newline_separator = sp; + if (sp) *sp++ = 0; @@ -413,7 +408,7 @@ void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x) if (wlen > room || (newl && wlen < 4 && sp && wlen + 1 + strlen(sp) > room - && (!(sp2 = strchr(sp, ' ')) + && (!(sp2 = strpbrk(sp, "\n ")) || wlen + 1 + (sp2 - sp) > room))) { cur_y++; cur_x = x; @@ -421,7 +416,15 @@ void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x) wmove(win, cur_y, cur_x); waddstr(win, word); getyx(win, cur_y, cur_x); - cur_x++; + + /* Move to the next line if the word separator was a newline */ + if (newline_separator) { + cur_y++; + cur_x = x; + newline_separator = 0; + } else + cur_x++; + if (sp && *sp == ' ') { cur_x++; /* double space */ while (*++sp == ' ') ; diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index 2396c5be31ad..cb8cf4ae0ef3 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c @@ -958,8 +958,8 @@ static int handle_exit(void) dialog_clear(); if (conf_get_changed()) res = dialog_yesno(NULL, - _("Do you wish to save your new configuration ?\n" - " to continue."), + _("Do you wish to save your new configuration?\n" + "(Press to continue kernel configuration.)"), 6, 60); else res = -1; -- cgit v1.2.3-59-g8ed1b From 1278ebdbc3167883f32095491990fbdc7cdf8b5e Mon Sep 17 00:00:00 2001 From: Dirk Gouders Date: Sun, 19 May 2013 21:49:34 +0200 Subject: mconf/nconf: mark empty menus/menuconfigs different from non-empty ones Submenus are sometimes empty and it would be nice if there is something that notifies us that we should not expect any content _before_ we enter a submenu. A new function menu_is_empty() was introduced and empty menus and menuconfigs are now marked by "----" as opposed to non-empty ones that are marked by "--->". This scheme was suggested by "Yann E. MORIN" . Signed-off-by: Dirk Gouders Tested-by: "Yann E. MORIN" Reviewed-by: "Yann E. MORIN" Signed-off-by: "Yann E. MORIN" --- scripts/kconfig/lkc_proto.h | 1 + scripts/kconfig/mconf.c | 11 ++++++----- scripts/kconfig/menu.c | 16 ++++++++++++++++ scripts/kconfig/nconf.c | 16 ++++++++-------- 4 files changed, 31 insertions(+), 13 deletions(-) (limited to 'scripts/kconfig/mconf.c') diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h index ef1a7381f956..ecdb9659b67d 100644 --- a/scripts/kconfig/lkc_proto.h +++ b/scripts/kconfig/lkc_proto.h @@ -14,6 +14,7 @@ P(conf_set_message_callback, void,(void (*fn)(const char *fmt, va_list ap))); /* menu.c */ P(rootmenu,struct menu,); +P(menu_is_empty, bool, (struct menu *menu)); P(menu_is_visible, bool, (struct menu *menu)); P(menu_has_prompt, bool, (struct menu *menu)); P(menu_get_prompt,const char *,(struct menu *menu)); diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index cb8cf4ae0ef3..6ee4aaea9d87 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c @@ -48,7 +48,7 @@ static const char mconf_readme[] = N_( "----------\n" "o Use the Up/Down arrow keys (cursor keys) to highlight the item\n" " you wish to change or submenu wish to select and press .\n" -" Submenus are designated by \"--->\".\n" +" Submenus are designated by \"--->\", empty ones by \"----\".\n" "\n" " Shortcut: Press the option's highlighted letter (hotkey).\n" " Pressing a hotkey more than once will sequence\n" @@ -176,7 +176,7 @@ static const char mconf_readme[] = N_( "\n"), menu_instructions[] = N_( "Arrow keys navigate the menu. " - " selects submenus --->. " + " selects submenus ---> (or empty submenus ----). " "Highlighted letters are hotkeys. " "Pressing includes, excludes, modularizes features. " "Press to exit, for Help, for Search. " @@ -498,8 +498,9 @@ static void build_conf(struct menu *menu) menu->data ? "-->" : "++>", indent + 1, ' ', prompt); } else - item_make(" %*c%s --->", indent + 1, ' ', prompt); - + item_make(" %*c%s %s", + indent + 1, ' ', prompt, + menu_is_empty(menu) ? "----" : "--->"); item_set_tag('m'); item_set_data(menu); if (single_menu_mode && menu->data) @@ -630,7 +631,7 @@ static void build_conf(struct menu *menu) (sym_has_value(sym) || !sym_is_changable(sym)) ? "" : _(" (NEW)")); if (menu->prompt->type == P_MENU) { - item_add_str(" --->"); + item_add_str(" %s", menu_is_empty(menu) ? "----" : "--->"); return; } } diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index b5c7d90df9df..6d11c8f63eb0 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -430,6 +430,22 @@ bool menu_has_prompt(struct menu *menu) return true; } +/* + * Determine if a menu is empty. + * A menu is considered empty if it contains no or only + * invisible entries. + */ +bool menu_is_empty(struct menu *menu) +{ + struct menu *child; + + for (child = menu->list; child; child = child->next) { + if (menu_is_visible(child)) + return(false); + } + return(true); +} + bool menu_is_visible(struct menu *menu) { struct menu *child; diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c index aac85d37b69b..0183153c2095 100644 --- a/scripts/kconfig/nconf.c +++ b/scripts/kconfig/nconf.c @@ -45,8 +45,8 @@ static const char nconf_global_help[] = N_( " to remove it. You may press the key to cycle through the\n" "available options.\n" "\n" -"A trailing \"--->\" designates a submenu.\n" -"\n" +"A trailing \"--->\" designates a submenu, a trailing \"----\" an\n" +"empty submenu.\n" "\n" "Menu navigation keys\n" "----------------------------------------------------------------------\n" @@ -131,7 +131,7 @@ static const char nconf_global_help[] = N_( "\n"), menu_no_f_instructions[] = N_( "Legend: [*] built-in [ ] excluded module < > module capable.\n" -"Submenus are designated by a trailing \"--->\".\n" +"Submenus are designated by a trailing \"--->\", empty ones by \"----\".\n" "\n" "Use the following keys to navigate the menus:\n" "Move up or down with and .\n" @@ -148,7 +148,7 @@ menu_no_f_instructions[] = N_( "For help related to the current menu entry press or .\n"), menu_instructions[] = N_( "Legend: [*] built-in [ ] excluded module < > module capable.\n" -"Submenus are designated by a trailing \"--->\".\n" +"Submenus are designated by a trailing \"--->\", empty ones by \"----\".\n" "\n" "Use the following keys to navigate the menus:\n" "Move up or down with or .\n" @@ -760,9 +760,9 @@ static void build_conf(struct menu *menu) indent + 1, ' ', prompt); } else item_make(menu, 'm', - " %*c%s --->", - indent + 1, - ' ', prompt); + " %*c%s %s", + indent + 1, ' ', prompt, + menu_is_empty(menu) ? "----" : "--->"); if (single_menu_mode && menu->data) goto conf_childs; @@ -904,7 +904,7 @@ static void build_conf(struct menu *menu) (sym_has_value(sym) || !sym_is_changable(sym)) ? "" : _(" (NEW)")); if (menu->prompt && menu->prompt->type == P_MENU) { - item_add_str(" --->"); + item_add_str(" %s", menu_is_empty(menu) ? "----" : "--->"); return; } } -- cgit v1.2.3-59-g8ed1b From a1ce636f560336ba007bfabb15b167ff31b592cf Mon Sep 17 00:00:00 2001 From: "Yann E. MORIN" Date: Mon, 24 Jun 2013 20:01:37 +0200 Subject: kconfig/[mn]conf: make it explicit in the search box that a regexp is possible Reported-by: Jean Delvare Signed-off-by: "Yann E. MORIN" Cc: Jean Delvare Cc: Michal Marek --- scripts/kconfig/mconf.c | 2 +- scripts/kconfig/nconf.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'scripts/kconfig/mconf.c') diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index 6ee4aaea9d87..18d3dc93d718 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c @@ -401,7 +401,7 @@ static void search_conf(void) struct subtitle_part stpart; title = str_new(); - str_printf( &title, _("Enter %s (sub)string to search for " + str_printf( &title, _("Enter %s (sub)string or regexp to search for " "(with or without \"%s\")"), CONFIG_, CONFIG_); again: diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c index 0183153c2095..7975d8d258c3 100644 --- a/scripts/kconfig/nconf.c +++ b/scripts/kconfig/nconf.c @@ -695,7 +695,7 @@ static void search_conf(void) int dres; title = str_new(); - str_printf( &title, _("Enter %s (sub)string to search for " + str_printf( &title, _("Enter %s (sub)string or regexp to search for " "(with or without \"%s\")"), CONFIG_, CONFIG_); again: -- cgit v1.2.3-59-g8ed1b