kconfig: menuconfig: remove OLD_NCURSES macro
PATCH 1/3 kconfig: menuconfig: remove OLD_NCURSES macro
This code has been here for more than 20 years. The bug in the old days no longer matters.
Signed-off-by Masahiro Yamada <[email protected]>
---
scripts/kconfig/lxdialog/dialog.h | 16 ---------------- scripts/kconfig/lxdialog/menubox.c | 8 -------- scripts/kconfig/lxdialog/textbox.c | 9 --------- 3 files changed, 33 deletions(-)
scripts/kconfig/lxdialog/dialog.h +0 -16
@@ -18,22 +18,6 @@#endif #include <ncurses.h> -/* -* Colors in ncurses 1.9.9e do not work properly since foreground and -* background colors are OR'd rather than separately masked. This version -* of dialog was hacked to work with ncurses 1.9.9e, making it incompatible -* with standard curses. The simplest fix (to make this work with standard -* curses) uses the wbkgdset() function, not used in the original hack. -* Turn it off if we're building with 1.9.9e, since it just confuses things. -*/ -#if defined(NCURSES_VERSION ) && defined(_NEED_WRAP) && !defined(GCC_PRINTFLIKE ) -#define OLD_NCURSES 1 -#undef wbkgdset -#define wbkgdset (w,p)/*nothing */ -#else -#define OLD_NCURSES 0 -#endif -#define TR (params) _tracef params#define KEY_ESC 27
scripts/kconfig/lxdialog/menubox.c +0 -8
@@ -63,15 +63,7 @@ static void do_print_item(WINDOW * win, const char *item, int line_y,/* Clear 'residue' of last item */ wattrset (win, dlg.menubox.atr);wmove (win, line_y,0 ); -#if OLD_NCURSES - { -int i; -for (i =0 ; i < menu_width; i++) -waddch (win,' ' ); - } -#else wclrtoeol (win); -#endif wattrset (win, selected ? dlg.item_selected.atr : dlg.item.atr);mvwaddstr (win, line_y, item_x, menu_item);if (hotkey) {
scripts/kconfig/lxdialog/textbox.c +0 -9
@@ -336,16 +336,7 @@ static void print_line(WINDOW * win, int row, int width)waddnstr (win, line,MIN (strlen (line), width -2 ));/* Clear 'residue' of previous line */ -#if OLD_NCURSES - { -int x =getcurx (win); -int i; -for (i =0 ; i < width - x; i++) -waddch (win,' ' ); - } -#else wclrtoeol (win); -#endif }/*
Signature · 1 line
2.34.1
PATCH 2/3 kconfig: menuconfig: remove unused M_EVENT macro
This is not used anywhere.
Signed-off-by Masahiro Yamada <[email protected]>
---
scripts/kconfig/lxdialog/dialog.h | 11 ----------- 1 file changed, 11 deletions(-)
scripts/kconfig/lxdialog/dialog.h +0 -11
@@ -209,14 +209,3 @@ int dialog_checklist(const char *title, const char *prompt, int height, int width, int list_height);int dialog_inputbox (const char *title,const char *prompt,int height,int width,const char *init); - -/* -* This is the base for fictitious keys, which activate -* the buttons. -* -* Mouse-generated keys are the following: -* -- the first 32 are used as numbers, in addition to '0'-'9' -* -- the lowercase are used to signal mouse-enter events (M_EVENT + 'o') -* -- uppercase chars are used to invoke the button (M_EVENT + 'O') -*/ -#define M_EVENT (KEY_MAX+1)
Signature · 1 line
2.34.1
PATCH 3/3 kconfig: menuconfig: reorder functions to remove forward declarations
In reply to Masahiro YamadaDefine helper functions before the callers so that forward declarations can go away.
Signed-off-by Masahiro Yamada <[email protected]>
---
scripts/kconfig/lxdialog/textbox.c | 258 ++++++++++++------------ scripts/kconfig/mconf.c | 314 ++++++++++++++--------------- 2 files changed, 277 insertions(+), 295 deletions(-)
scripts/kconfig/lxdialog/textbox.c +125 -133
@@ -8,18 +8,136 @@#include "dialog.h" -static void back_lines (int n); -static void print_page (WINDOW *win,int height,int width,update_text_fn - update_text,void *data); -static void print_line (WINDOW *win,int row,int width); -static char *get_line (void ); -static void print_position (WINDOW * win); -static int hscroll;static int begin_reached, end_reached, page_length;static char *buf;static char *page; +/* +* Go back 'n' lines in text. Called by dialog_textbox(). +* 'page' will be updated to point to the desired line in 'buf'. +*/ +static void back_lines (int n) +{ +int i; + + begin_reached =0 ; +/* Go back 'n' lines */ +for (i =0 ; i < n; i++) { +if (*page =='\0' ) { +if (end_reached) { + end_reached =0 ; +continue ; + } + } +if (page == buf) { + begin_reached =1 ; +return ; + } + page--; +do { +if (page == buf) { + begin_reached =1 ; +return ; + } + page--; + }while (*page !='\n' ); + page++; + } +} + +/* +* Return current line of text. Called by dialog_textbox() and print_line(). +* 'page' should point to start of current line before calling, and will be +* updated to point to start of next line. +*/ +static char *get_line (void ) +{ +int i =0 ; +static char line[MAX_LEN +1 ]; + + end_reached =0 ; +while (*page !='\n' ) { +if (*page =='\0' ) { + end_reached =1 ; +break ; + }else if (i <MAX_LEN ) + line[i++] = *(page++); +else { +/* Truncate lines longer than MAX_LEN characters */ +if (i ==MAX_LEN ) + line[i++] ='\0' ; + page++; + } + } +if (i <=MAX_LEN ) + line[i] ='\0' ; +if (!end_reached) + page++;/* move past '\n' */ + +return line; +} + +/* +* Print a new line of text. +*/ +static void print_line (WINDOW *win,int row,int width) +{ +char *line; + + line =get_line (); + line +=MIN (strlen (line), hscroll);/* Scroll horizontally */ +wmove (win, row,0 );/* move cursor to correct line */ +waddch (win,' ' ); +waddnstr (win, line,MIN (strlen (line), width -2 )); + +/* Clear 'residue' of previous line */ +wclrtoeol (win); +} + +/* +* Print a new page of text. +*/ +static void print_page (WINDOW *win,int height,int width,update_text_fn + update_text,void *data) +{ +int i, passed_end =0 ; + +if (update_text) { +char *end; + +for (i =0 ; i < height; i++) +get_line (); + end = page; +back_lines (height); +update_text (buf, page - buf, end - buf, data); + } + + page_length =0 ; +for (i =0 ; i < height; i++) { +print_line (win, i, width); +if (!passed_end) + page_length++; +if (end_reached && !passed_end) + passed_end =1 ; + } +wnoutrefresh (win); +} + +/* +* Print current position +*/ +static void print_position (WINDOW *win) +{ +int percent; + +wattrset (win, dlg.position_indicator.atr); +wbkgdset (win, dlg.position_indicator.atr &A_COLOR ); + percent = (page - buf) *100 /strlen (buf); +wmove (win,getmaxy (win) -3 ,getmaxx (win) -9 ); +wprintw (win,"(%3d%%)" , percent); +} +/* * refresh window content */
@@ -33,7 +151,6 @@ static void refresh_text_box(WINDOW *dialog, WINDOW *box, int boxh, int boxw,wrefresh (dialog); } -/* * Display text from a file in a dialog box. *
@@ -259,128 +376,3 @@ int dialog_textbox(const char *title, char *tbuf, int initial_height, *_hscroll = hscroll;return key; } - -/* -* Go back 'n' lines in text. Called by dialog_textbox(). -* 'page' will be updated to point to the desired line in 'buf'. -*/ -static void back_lines (int n) -{ -int i; - - begin_reached =0 ; -/* Go back 'n' lines */ -for (i =0 ; i < n; i++) { -if (*page =='\0' ) { -if (end_reached) { - end_reached =0 ; -continue ; - } - } -if (page == buf) { - begin_reached =1 ; -return ; - } - page--; -do { -if (page == buf) { - begin_reached =1 ; -return ; - } - page--; - }while (*page !='\n' ); - page++; - } -} - -/* -* Print a new page of text. -*/ -static void print_page (WINDOW *win,int height,int width,update_text_fn - update_text,void *data) -{ -int i, passed_end =0 ; - -if (update_text) { -char *end; - -for (i =0 ; i < height; i++) -get_line (); - end = page; -back_lines (height); -update_text (buf, page - buf, end - buf, data); - } - - page_length =0 ; -for (i =0 ; i < height; i++) { -print_line (win, i, width); -if (!passed_end) - page_length++; -if (end_reached && !passed_end) - passed_end =1 ; - } -wnoutrefresh (win); -} - -/* -* Print a new line of text. -*/ -static void print_line (WINDOW * win,int row,int width) -{ -char *line; - - line =get_line (); - line +=MIN (strlen (line), hscroll);/* Scroll horizontally */ -wmove (win, row,0 );/* move cursor to correct line */ -waddch (win,' ' ); -waddnstr (win, line,MIN (strlen (line), width -2 )); - -/* Clear 'residue' of previous line */ -wclrtoeol (win); -} - -/* -* Return current line of text. Called by dialog_textbox() and print_line(). -* 'page' should point to start of current line before calling, and will be -* updated to point to start of next line. -*/ -static char *get_line (void ) -{ -int i =0 ; -static char line[MAX_LEN +1 ]; - - end_reached =0 ; -while (*page !='\n' ) { -if (*page =='\0' ) { - end_reached =1 ; -break ; - }else if (i <MAX_LEN ) - line[i++] = *(page++); -else { -/* Truncate lines longer than MAX_LEN characters */ -if (i ==MAX_LEN ) - line[i++] ='\0' ; - page++; - } - } -if (i <=MAX_LEN ) - line[i] ='\0' ; -if (!end_reached) - page++;/* move past '\n' */ - -return line; -} - -/* -* Print current position -*/ -static void print_position (WINDOW * win) -{ -int percent; - -wattrset (win, dlg.position_indicator.atr); -wbkgdset (win, dlg.position_indicator.atr &A_COLOR ); - percent = (page - buf) *100 /strlen (buf); -wmove (win,getmaxy (win) -3 ,getmaxx (win) -9 ); -wprintw (win,"(%3d%%)" , percent); -}
scripts/kconfig/mconf.c +152 -162
338 lines not on this page · raw message
Signature · 1 line
2.34.1