From 98e5a1579e7d34fe3803240750a1c48efcd9cb15 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Mon, 24 Jul 2006 21:40:46 +0200 Subject: kconfig/lxdialog: refactor color support Clean up and refactor color support. All color support are now in util.c including color definitions. In the process introduced a global variable named 'dlg' which is used all over to set color - thats the reason why all files are changed. Signed-off-by: Sam Ravnborg --- scripts/kconfig/lxdialog/dialog.h | 82 +++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 42 deletions(-) (limited to 'scripts/kconfig/lxdialog/dialog.h') diff --git a/scripts/kconfig/lxdialog/dialog.h b/scripts/kconfig/lxdialog/dialog.h index af3cf716e215..2f4c19d710b2 100644 --- a/scripts/kconfig/lxdialog/dialog.h +++ b/scripts/kconfig/lxdialog/dialog.h @@ -87,62 +87,60 @@ #endif /* - * Attribute names + * Color definitions */ -#define screen_attr attributes[0] -#define shadow_attr attributes[1] -#define dialog_attr attributes[2] -#define title_attr attributes[3] -#define border_attr attributes[4] -#define button_active_attr attributes[5] -#define button_inactive_attr attributes[6] -#define button_key_active_attr attributes[7] -#define button_key_inactive_attr attributes[8] -#define button_label_active_attr attributes[9] -#define button_label_inactive_attr attributes[10] -#define inputbox_attr attributes[11] -#define inputbox_border_attr attributes[12] -#define searchbox_attr attributes[13] -#define searchbox_title_attr attributes[14] -#define searchbox_border_attr attributes[15] -#define position_indicator_attr attributes[16] -#define menubox_attr attributes[17] -#define menubox_border_attr attributes[18] -#define item_attr attributes[19] -#define item_selected_attr attributes[20] -#define tag_attr attributes[21] -#define tag_selected_attr attributes[22] -#define tag_key_attr attributes[23] -#define tag_key_selected_attr attributes[24] -#define check_attr attributes[25] -#define check_selected_attr attributes[26] -#define uarrow_attr attributes[27] -#define darrow_attr attributes[28] +struct dialog_color { + chtype atr; /* Color attribute */ + int fg; /* foreground */ + int bg; /* background */ + int hl; /* highlight this item */ +}; -/* number of attributes */ -#define ATTRIBUTE_COUNT 29 +struct dialog_info { + const char *backtitle; + struct dialog_color screen; + struct dialog_color shadow; + struct dialog_color dialog; + struct dialog_color title; + struct dialog_color border; + struct dialog_color button_active; + struct dialog_color button_inactive; + struct dialog_color button_key_active; + struct dialog_color button_key_inactive; + struct dialog_color button_label_active; + struct dialog_color button_label_inactive; + struct dialog_color inputbox; + struct dialog_color inputbox_border; + struct dialog_color searchbox; + struct dialog_color searchbox_title; + struct dialog_color searchbox_border; + struct dialog_color position_indicator; + struct dialog_color menubox; + struct dialog_color menubox_border; + struct dialog_color item; + struct dialog_color item_selected; + struct dialog_color tag; + struct dialog_color tag_selected; + struct dialog_color tag_key; + struct dialog_color tag_key_selected; + struct dialog_color check; + struct dialog_color check_selected; + struct dialog_color uarrow; + struct dialog_color darrow; +}; /* * Global variables */ -extern bool use_colors; -extern bool use_shadow; - -extern chtype attributes[]; - -extern const char *backtitle; +extern struct dialog_info dlg; /* * Function prototypes */ -extern void create_rc(const char *filename); -extern int parse_rc(void); - void init_dialog(void); void end_dialog(void); void attr_clear(WINDOW * win, int height, int width, chtype attr); void dialog_clear(void); -void color_setup(void); void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x); void print_button(WINDOW * win, const char *label, int y, int x, int selected); void print_title(WINDOW *dialog, const char *title, int width); -- cgit v1.2.2 From 2982de6993e6d9944f2215d7cb9b558b465a0c99 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Thu, 27 Jul 2006 22:10:27 +0200 Subject: kconfig/menuconfig: lxdialog is now built-in lxdialog was previously called as an external program causing screen to flicker when used. With this patch lxdialog is now built-in. It is loosly based om previous work by: Petr Baudis Following is a list of changes: o Moved build of dialog routings to kconfig Makefile o menubox + checklist uses a new item list to hold all menu items o in util.c implmented helper function to deal with item list o menubox now uses parameters to save scroll state (avoids temp file) o textbox now get text to be displayed as parameter and not a file o make sure to properly delete subwin's before main windows o killed unused files: lxdialog.c msgbox.c o modified return value for ESC to match direct calling o in a few places the code has been adjusted to 80 char wide o in textbox a small refactoring was made to make code remotely readable o in mconf removed all unused stuff (functions/variables) Following is a list of know short comings: a) pressing ESC twice will be interpreted as two ESC presses b) resize does not work. menuconfig needs to be restarted to be adjusted Signed-off-by: Sam Ravnborg --- scripts/kconfig/lxdialog/dialog.h | 52 +++++++++++++++++++++++++++++++++++---- 1 file changed, 47 insertions(+), 5 deletions(-) (limited to 'scripts/kconfig/lxdialog/dialog.h') diff --git a/scripts/kconfig/lxdialog/dialog.h b/scripts/kconfig/lxdialog/dialog.h index 2f4c19d710b2..065ded0a449f 100644 --- a/scripts/kconfig/lxdialog/dialog.h +++ b/scripts/kconfig/lxdialog/dialog.h @@ -133,11 +133,55 @@ struct dialog_info { * Global variables */ extern struct dialog_info dlg; +extern char dialog_input_result[]; /* * Function prototypes */ -void init_dialog(void); + +/* item list as used by checklist and menubox */ +void item_reset(void); +void item_make(const char *fmt, ...); +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); +int item_activate_selected(void); +void *item_data(void); +char item_tag(void); + +/* item list manipulation for lxdialog use */ +#define MAXITEMSTR 200 +struct dialog_item { + char str[MAXITEMSTR]; /* promtp displayed */ + char tag; + void *data; /* pointer to menu item - used by menubox+checklist */ + int selected; /* Set to 1 by dialog_*() function if selected. */ +}; + +/* list of lialog_items */ +struct dialog_list { + struct dialog_item node; + struct dialog_list *next; +}; + +extern struct dialog_list *item_cur; +extern struct dialog_list item_nil; +extern struct dialog_list *item_head; + +int item_count(void); +void item_set(int n); +int item_n(void); +const char *item_str(void); +int item_is_selected(void); +int item_is_tag(char tag); +#define item_foreach() \ + for (item_cur = item_head ? item_head: item_cur; \ + item_cur && (item_cur != &item_nil); item_cur = item_cur->next) + + +void init_dialog(const char *backtitle); +void reset_dialog(void); void end_dialog(void); void attr_clear(WINDOW * win, int height, int width, chtype attr); void dialog_clear(void); @@ -154,11 +198,9 @@ int dialog_msgbox(const char *title, const char *prompt, int height, int width, int pause); int dialog_textbox(const char *title, const char *file, int height, int width); int dialog_menu(const char *title, const char *prompt, int height, int width, - int menu_height, const char *choice, int item_no, - const char *const *items); + int menu_height, const void *selected, int *s_scroll); int dialog_checklist(const char *title, const char *prompt, int height, - int width, int list_height, int item_no, - const char *const *items); + int width, int list_height); extern char dialog_input_result[]; int dialog_inputbox(const char *title, const char *prompt, int height, int width, const char *init); -- cgit v1.2.2 From f3cbcdc955d0d2c8b4c52d6b73fc536b01b68c64 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Fri, 28 Jul 2006 23:57:48 +0200 Subject: kconfig/lxdialog: let behave as expected is used to step one back in the dialogs. When lxdialog became built-in pressing once would cause one step back and pressing would cause two steps back. This patch - based on concept from Roman Zippel - makes one a noop and pressing will cause one step backward. In addition the final yes/no dialog now has the option to go back to the the kernel configuration. So if you get too far out you can now go back to configuring the kernel without saving and starting all over again. Signed-off-by: Sam Ravnborg --- scripts/kconfig/lxdialog/dialog.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'scripts/kconfig/lxdialog/dialog.h') diff --git a/scripts/kconfig/lxdialog/dialog.h b/scripts/kconfig/lxdialog/dialog.h index 065ded0a449f..a7cfdecc2409 100644 --- a/scripts/kconfig/lxdialog/dialog.h +++ b/scripts/kconfig/lxdialog/dialog.h @@ -48,7 +48,7 @@ #define TR(params) _tracef params -#define ESC 27 +#define KEY_ESC 27 #define TAB 9 #define MAX_LEN 2048 #define BUF_SIZE (10*1024) @@ -179,6 +179,8 @@ int item_is_tag(char tag); for (item_cur = item_head ? item_head: item_cur; \ item_cur && (item_cur != &item_nil); item_cur = item_cur->next) +/* generic key handlers */ +int on_key_esc(WINDOW *win); void init_dialog(const char *backtitle); void reset_dialog(void); -- cgit v1.2.2 From c8dc68ad0fbd934e78e913b8a8d7b45945db4930 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sat, 29 Jul 2006 22:48:57 +0200 Subject: kconfig/lxdialog: support resize In all dialogs now properly catch KEY_RESIZE and take proper action. In mconf try to behave sensibly when a dialog routine returns -ERRDISPLAYTOOSMALL. The original check for a screnn size of 80x19 is kept for now. It may make sense to remove it later, but thats anyway what much text is adjusted for. Signed-off-by: Sam Ravnborg --- scripts/kconfig/lxdialog/dialog.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'scripts/kconfig/lxdialog/dialog.h') diff --git a/scripts/kconfig/lxdialog/dialog.h b/scripts/kconfig/lxdialog/dialog.h index a7cfdecc2409..8dea47f9d3e4 100644 --- a/scripts/kconfig/lxdialog/dialog.h +++ b/scripts/kconfig/lxdialog/dialog.h @@ -86,6 +86,9 @@ #define ACS_DARROW 'v' #endif +/* error return codes */ +#define ERRDISPLAYTOOSMALL (KEY_MAX + 1) + /* * Color definitions */ @@ -181,6 +184,7 @@ int item_is_tag(char tag); /* generic key handlers */ int on_key_esc(WINDOW *win); +int on_key_resize(void); void init_dialog(const char *backtitle); void reset_dialog(void); @@ -199,8 +203,8 @@ int dialog_yesno(const char *title, const char *prompt, int height, int width); int dialog_msgbox(const char *title, const char *prompt, int height, int width, int pause); int dialog_textbox(const char *title, const char *file, int height, int width); -int dialog_menu(const char *title, const char *prompt, int height, int width, - int menu_height, const void *selected, int *s_scroll); +int dialog_menu(const char *title, const char *prompt, + const void *selected, int *s_scroll); int dialog_checklist(const char *title, const char *prompt, int height, int width, int list_height); extern char dialog_input_result[]; -- cgit v1.2.2