Menuconfig has a feature where you can "press the key in the (#) prefix
to jump directly to that location. You will be returned to the current
search results after exiting this new menu."
This commit adds this feature to nconfig, with almost identical code.
Signed-off-by: Jesse Taube <Mr.Bossman075@gmail.com>
Acked-by: Randy Dunlap <rdunlap@infradead.org>
Tested-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
This helper is the same as the sample code in the NCURSES HOWTO [1],
but it is over-engineering to be used for nconf.
I do not see any good reason to use the 'float' type just for the
division by 2.
All the call-sites pass a non-NULL pointer to the first argument,
so 'if (win == NULL) win = stdscr;' is dead code.
'if (startx != 0) x = startx;' is dead code because 'x' will be
overridden some lines below, by 'x = startx + (int)temp;'.
All the call-sites pass a non-zero value to the second argument,
so 'if (starty != 0)' is always true.
getyx(win, y, x) is also dead-code because both 'y' and 'x' are
overridden.
All the call-sites pass 0 to the third parameter, so 'startx' can
be removed.
All the call-sites pass a non-zero value to the fourth parameter,
so 'if (width == 0) width = 80;' is dead code.
The window will be refreshed later, so there is no need to call
refresh() in this function.
Change the type of the last parameter from 'chtype' to 'int' to be
aligned with the prototype, 'int wattrset(WINDOW *win, int attrs);'
I also slightly cleaned up the indentation style.
[1]: https://tldp.org/HOWTO/NCURSES-Programming-HOWTO/color.html
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
The current attributes setup code is strange; the array attribute[]
is set to values outside the range of the attribute_t enum.
At least,
attributes_t attributes[ATTR_MAX+1] = {0};
... should be
int attribute[ATTR_MAX+1] = {0};
Also, there is no need to hard-code the color-pair numbers in
attributes_t.
The current code is messy. Rewrite it.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
This reverts commit 10175ba65f ("nconfig: Silence unused return values
from wattrset").
With this patch applied, recent GCC versions can cleanly build nconf
without "value computed is not used" warnings.
The wattrset() used to be implemented as a macro, like this:
#define wattrset(win,at) \
(NCURSES_OK_ADDR(win) \
? ((win)->_attrs = NCURSES_CAST(attr_t, at), \
OK) \
: ERR)
The GCC bugzilla [1] reported a false-positive -Wunused-value warning
in a similar test case. It was fixed by GCC 4.4.1.
Let's revert that commit, and see if somebody will claim the issue.
[1]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=39889
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
The lower 8-bit of attributes should be 0, but this code wrongly
sets it to NORMAL (=1). The correct one is A_NORMAL.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Backspace is not working on some terminal emulators which do not send the
key code defined by terminfo. Terminals either send '^H' (8) or '^?' (127).
But currently only '^?' is handled. Let's also handle '^H' for those
terminals.
Signed-off-by: Changbin Du <changbin.du@gmail.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
All files in lxdialog/ are licensed under GPL-2.0+, and the rest are
under GPL-2.0. I added GPL-2.0 tags to test scripts in tests/.
Documentation/process/license-rules.rst does not suggest anything
about the flex/bison files. Because flex does not accept the C++
comment style at the very top of a file, I used the C style for
zconf.l, and so for zconf.y for consistency.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
We already have xmalloc(), xcalloc(). Add xrealloc() as well
to save tedious error handling.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Fix sparse warnings in scripts/kconfig/nconf* ('make nconfig'):
../scripts/kconfig/nconf.c:1071:32: warning: Using plain integer as NULL pointer
../scripts/kconfig/nconf.c:1238:30: warning: Using plain integer as NULL pointer
../scripts/kconfig/nconf.c:511:51: warning: Using plain integer as NULL pointer
../scripts/kconfig/nconf.c:1460:6: warning: symbol 'setup_windows' was not declared. Should it be static?
../scripts/kconfig/nconf.c:274:12: warning: symbol 'current_instructions' was not declared. Should it be static?
../scripts/kconfig/nconf.c:308:22: warning: symbol 'function_keys' was not declared. Should it be static?
../scripts/kconfig/nconf.gui.c:132:17: warning: non-ANSI function declaration of function 'set_colors'
../scripts/kconfig/nconf.gui.c:195:24: warning: Using plain integer as NULL pointer
nconf.gui.o before/after files are the same.
nconf.o before/after files are the same until the 'static' function
declarations are added.
Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Currently it is impossible to edit the value of a config symbol with a
prompt longer than (terminal width - 2) characters. dialog_inputbox()
calculates a negative x-offset for the input window and newwin() fails
as this is invalid. It also doesn't check for this failure, so it
busy-loops calling wgetch(NULL) which immediately returns -1.
The additions in the offset calculations also don't match the intended
size of the window.
Limit the window size and calculate the offset similarly to
show_scroll_win().
Cc: stable <stable@vger.kernel.org>
Fixes: 692d97c380 ("kconfig: new configuration interface (nconfig)")
Signed-off-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
According to the documentation [1], LINES and COLS are initialized by
initscr(); it does not say anything about the behavior when windows are
resized.
Do not rely on the current implementation of ncurses that updates
these variables on resize, but use the propper function calls or macros
to get window dimensions.
The use of the variables in main() was OK, but for the sake of
consistency it was modified to use the macro getmaxyx().
[1] ncurses(3X)
Signed-off-by: Dirk Gouders <dirk@gouders.net>
Reviewed-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
[yann.morin.1998@free.fr: declare 'lines' and 'columns' on a single line]
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
• In function keys line descriptions black on darkblue are almost
impossible to read. Change colors to black on brown.
Signed-off-by: Roland Eggner <edvx1@systemanalysen.net>
Tested-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
They function just like they do in less(1).
Also correct some discrepancy between the help text and the code wrt
function keys.
Signed-off-by: Benjamin Poirier <bpoirier@suse.de>
Signed-off-by: Michal Marek <mmarek@suse.cz>
to make it easier to locate begin/end when editing long strings;
Signed-off-by: Cheng Renquan <crquan@gmail.com>
Acked By: Nir Tzachar <nir.tzachar@gmail.com>
The original dialog_inputbox doesn't work with longer than prompt_width
strings, here fixed it in this way:
1) add variable cursor_form_win to record cursor of form_win,
keep its value always between [0, prompt_width-1];
reuse the original cursor_position as cursor of the string result,
use (cursor_position-cursor_form_win) as begin offset to show part of
the string in form_win;
Signed-off-by: Cheng Renquan <crquan@gmail.com>
Cc: Arnaud Lacombe <lacombar@gmail.com>
Cc: Nir Tzachar <nir.tzachar@gmail.com>
To support unlimited length string config items;
No check for realloc return value keeps code simple, and to be
consistent with other existing unchecked malloc in kconfig.
Signed-off-by: Cheng Renquan <crquan@gmail.com>
Signed-off-by: Arnaud Lacombe <lacombar@gmail.com>
In case KEY_BACKSPACE / KEY_DC to delete a char, it memmove only
(len-cursor_position+1) bytes;
the default case is to insert a char, it should also memmove exactly
(len-cursor_position+1) bytes;
the original use of (len+1) is wrong and may access following memory
that doesn't belong to result, may cause SegFault in theory;
case KEY_BACKSPACE:
if (cursor_position > 0) {
memmove(&result[cursor_position-1],
&result[cursor_position],
len-cursor_position+1);
cursor_position--;
}
break;
case KEY_DC:
if (cursor_position >= 0 && cursor_position < len) {
memmove(&result[cursor_position],
&result[cursor_position+1],
len-cursor_position+1);
}
break;
default:
if ((isgraph(res) || isspace(res)) &&
len-2 < result_len) {
/* insert the char at the proper position */
memmove(&result[cursor_position+1],
&result[cursor_position],
len-cursor_position+1);
result[cursor_position] = res;
cursor_position++;
}
Signed-off-by: Cheng Renquan <crquan@gmail.com>
Acked-by: Nir Tzachar <nir.tzachar@gmail.com>
Remove the old hotkeys feature, and replace it by an interactive string
search.
From nconfig help:
Searching: pressing '/' triggers interactive search mode.
nconfig performs a case insensitive search for the string
in the menu prompts (no regex support).
Pressing the up/down keys highlights the previous/next
matching item. Backspace removes one character from the
match string. Pressing either '/' again or ESC exits
search mode. All other keys behave normally.
Miscellaneous other changes (including Rundy's and Justin's input).
Signed-off-by: Nir Tzachar <nir.tzachar@gmail.com>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Michal Marek <mmarek@suse.cz>
nconfig segfaults when help text contains the character '%'. For a quick
example, navigate to the kernel compression options and get the help for
bzip2. Doing so triggers a call to mvwprintw() with a string containing
'%' and no extra arguments to fill in the specifier's value. Fix this
case by printing the literal string retrieved from the kconfig.
#0 0x00002b52b6b11d83 in vfprintf () from /lib/libc.so.6
#1 0x00002b52b6bad010 in __vsnprintf_chk () from /lib/libc.so.6
#2 0x00002b52b623991b in _nc_printf_string () from
/lib/libncursesw.so.5
#3 0x00002b52b6234cff in vwprintw () from /lib/libncursesw.so.5
#4 0x00002b52b6234db9 in mvwprintw () from /lib/libncursesw.so.5
#5 0x00000000004151d8 in fill_window (win=0x21b64c0,
text=0x21b62b0 "CONFIG_KERNEL_BZIP2:\n\nIts compression ratio and
speed is intermediate.\nDecompression speed is slowest among the
three. The kernel\nsize is about 10% smaller with bzip2, in
comparison to gzip.\nBzip2 us"...)
at scripts/kconfig/nconf.gui.c:229
#6 0x0000000000416335 in show_scroll_win (main_window=0x21a5630,
title=0x157fa30 "Bzip2",
text=0x21b62b0 "CONFIG_KERNEL_BZIP2:\n\nIts compression
ratio and speed is intermediate.\nDecompression speed is
slowest among the three. The kernel\nsize is about 10%
smaller with bzip2, in comparison to gzip.\nBzip2 us"...)
at scripts/kconfig/nconf.gui.c:535
#7 0x00000000004055b2 in show_help (menu=0x157f9d0)
at scripts/kconfig/nconf.c:1257
#8 0x0000000000405897 in conf_choice (menu=0x157f130)
at scripts/kconfig/nconf.c:1321
#9 0x0000000000405326 in conf (menu=0x157d130) at
scripts/kconfig/nconf.c:1208
#10 0x00000000004052e8 in conf (menu=0xb434a0) at
scripts/kconfig/nconf.c:1203
#11 0x0000000000406092 in main (ac=2, av=0x7fff96a93c38)
Cc: Michal Marek <mmarek@suse.cz>
Cc: Nir Tzachar <nir.tzachar@gmail.com>
Signed-off-by: Stephen Boyd <bebarino@gmail.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>
scripts/kconfig/nconf.gui.c:23: warning: no previous prototype for 'set_normal_colors'
scripts/kconfig/nconf.gui.c:68: warning: no previous prototype for 'normal_color_theme'
scripts/kconfig/nconf.gui.c💯 warning: no previous prototype for 'no_colors_theme'
scripts/kconfig/nconf.c:455: warning: no previous prototype for 'process_special_keys'
scripts/kconfig/nconf.c:487: warning: no previous prototype for 'get_next_hot'
scripts/kconfig/nconf.c:506: warning: no previous prototype for 'canbhot'
scripts/kconfig/nconf.c:514: warning: no previous prototype for 'is_hot'
scripts/kconfig/nconf.c:522: warning: no previous prototype for 'make_hot'
scripts/kconfig/nconf.c:582: warning: no previous prototype for 'item_make'
scripts/kconfig/nconf.c:626: warning: no previous prototype for 'item_add_str'
scripts/kconfig/nconf.c:656: warning: no previous prototype for 'item_tag'
scripts/kconfig/nconf.c:668: warning: no previous prototype for 'curses_item_index'
scripts/kconfig/nconf.c:673: warning: no previous prototype for 'item_data'
scripts/kconfig/nconf.c:684: warning: no previous prototype for 'item_is_tag'
scripts/kconfig/nconf.c:691: warning: no previous prototype for 'set_config_filename'
Signed-off-by: Michal Marek <mmarek@suse.cz>
This patch was inspired by the kernel projects page, where an ncurses
replacement for menuconfig was mentioned (by Sam Ravnborg).
Building on menuconfig, this patch implements a more modern look
interface using ncurses and ncurses' satellite libraries (menu, panel,
form). The implementation does not depend on lxdialog, which is
currently distributed with the kernel.
Signed-off-by: Nir Tzachar <nir.tzachar@gmail.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>