diff options
author | Sam Ravnborg <sam@mars.ravnborg.org> | 2006-07-24 15:40:46 -0400 |
---|---|---|
committer | Sam Ravnborg <sam@neptun.ravnborg.org> | 2006-09-30 05:19:19 -0400 |
commit | 98e5a1579e7d34fe3803240750a1c48efcd9cb15 (patch) | |
tree | 433f6b354eb0bb6fa01f325237f9f4651bf5ac9f /scripts/kconfig | |
parent | bf603625660b1742004bf86432ce3c210d14d4fd (diff) |
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 <sam@ravnborg.org>
Diffstat (limited to 'scripts/kconfig')
-rw-r--r-- | scripts/kconfig/lxdialog/checklist.c | 28 | ||||
-rw-r--r-- | scripts/kconfig/lxdialog/colors.h | 154 | ||||
-rw-r--r-- | scripts/kconfig/lxdialog/dialog.h | 82 | ||||
-rw-r--r-- | scripts/kconfig/lxdialog/inputbox.c | 18 | ||||
-rw-r--r-- | scripts/kconfig/lxdialog/lxdialog.c | 6 | ||||
-rw-r--r-- | scripts/kconfig/lxdialog/menubox.c | 28 | ||||
-rw-r--r-- | scripts/kconfig/lxdialog/msgbox.c | 9 | ||||
-rw-r--r-- | scripts/kconfig/lxdialog/textbox.c | 19 | ||||
-rw-r--r-- | scripts/kconfig/lxdialog/util.c | 259 | ||||
-rw-r--r-- | scripts/kconfig/lxdialog/yesno.c | 9 |
10 files changed, 250 insertions, 362 deletions
diff --git a/scripts/kconfig/lxdialog/checklist.c b/scripts/kconfig/lxdialog/checklist.c index 79886413b6d5..b90e888a2bc0 100644 --- a/scripts/kconfig/lxdialog/checklist.c +++ b/scripts/kconfig/lxdialog/checklist.c | |||
@@ -34,18 +34,19 @@ static void print_item(WINDOW * win, const char *item, int status, int choice, | |||
34 | int i; | 34 | int i; |
35 | 35 | ||
36 | /* Clear 'residue' of last item */ | 36 | /* Clear 'residue' of last item */ |
37 | wattrset(win, menubox_attr); | 37 | wattrset(win, dlg.menubox.atr); |
38 | wmove(win, choice, 0); | 38 | wmove(win, choice, 0); |
39 | for (i = 0; i < list_width; i++) | 39 | for (i = 0; i < list_width; i++) |
40 | waddch(win, ' '); | 40 | waddch(win, ' '); |
41 | 41 | ||
42 | wmove(win, choice, check_x); | 42 | wmove(win, choice, check_x); |
43 | wattrset(win, selected ? check_selected_attr : check_attr); | 43 | wattrset(win, selected ? dlg.check_selected.atr |
44 | : dlg.check.atr); | ||
44 | wprintw(win, "(%c)", status ? 'X' : ' '); | 45 | wprintw(win, "(%c)", status ? 'X' : ' '); |
45 | 46 | ||
46 | wattrset(win, selected ? tag_selected_attr : tag_attr); | 47 | wattrset(win, selected ? dlg.tag_selected.atr : dlg.tag.atr); |
47 | mvwaddch(win, choice, item_x, item[0]); | 48 | mvwaddch(win, choice, item_x, item[0]); |
48 | wattrset(win, selected ? item_selected_attr : item_attr); | 49 | wattrset(win, selected ? dlg.item_selected.atr : dlg.item.atr); |
49 | waddstr(win, (char *)item + 1); | 50 | waddstr(win, (char *)item + 1); |
50 | if (selected) { | 51 | if (selected) { |
51 | wmove(win, choice, check_x + 1); | 52 | wmove(win, choice, check_x + 1); |
@@ -62,11 +63,11 @@ static void print_arrows(WINDOW * win, int choice, int item_no, int scroll, | |||
62 | wmove(win, y, x); | 63 | wmove(win, y, x); |
63 | 64 | ||
64 | if (scroll > 0) { | 65 | if (scroll > 0) { |
65 | wattrset(win, uarrow_attr); | 66 | wattrset(win, dlg.uarrow.atr); |
66 | waddch(win, ACS_UARROW); | 67 | waddch(win, ACS_UARROW); |
67 | waddstr(win, "(-)"); | 68 | waddstr(win, "(-)"); |
68 | } else { | 69 | } else { |
69 | wattrset(win, menubox_attr); | 70 | wattrset(win, dlg.menubox.atr); |
70 | waddch(win, ACS_HLINE); | 71 | waddch(win, ACS_HLINE); |
71 | waddch(win, ACS_HLINE); | 72 | waddch(win, ACS_HLINE); |
72 | waddch(win, ACS_HLINE); | 73 | waddch(win, ACS_HLINE); |
@@ -77,11 +78,11 @@ static void print_arrows(WINDOW * win, int choice, int item_no, int scroll, | |||
77 | wmove(win, y, x); | 78 | wmove(win, y, x); |
78 | 79 | ||
79 | if ((height < item_no) && (scroll + choice < item_no - 1)) { | 80 | if ((height < item_no) && (scroll + choice < item_no - 1)) { |
80 | wattrset(win, darrow_attr); | 81 | wattrset(win, dlg.darrow.atr); |
81 | waddch(win, ACS_DARROW); | 82 | waddch(win, ACS_DARROW); |
82 | waddstr(win, "(+)"); | 83 | waddstr(win, "(+)"); |
83 | } else { | 84 | } else { |
84 | wattrset(win, menubox_border_attr); | 85 | wattrset(win, dlg.menubox_border.atr); |
85 | waddch(win, ACS_HLINE); | 86 | waddch(win, ACS_HLINE); |
86 | waddch(win, ACS_HLINE); | 87 | waddch(win, ACS_HLINE); |
87 | waddch(win, ACS_HLINE); | 88 | waddch(win, ACS_HLINE); |
@@ -145,17 +146,18 @@ int dialog_checklist(const char *title, const char *prompt, int height, | |||
145 | dialog = newwin(height, width, y, x); | 146 | dialog = newwin(height, width, y, x); |
146 | keypad(dialog, TRUE); | 147 | keypad(dialog, TRUE); |
147 | 148 | ||
148 | draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr); | 149 | draw_box(dialog, 0, 0, height, width, |
149 | wattrset(dialog, border_attr); | 150 | dlg.dialog.atr, dlg.border.atr); |
151 | wattrset(dialog, dlg.border.atr); | ||
150 | mvwaddch(dialog, height - 3, 0, ACS_LTEE); | 152 | mvwaddch(dialog, height - 3, 0, ACS_LTEE); |
151 | for (i = 0; i < width - 2; i++) | 153 | for (i = 0; i < width - 2; i++) |
152 | waddch(dialog, ACS_HLINE); | 154 | waddch(dialog, ACS_HLINE); |
153 | wattrset(dialog, dialog_attr); | 155 | wattrset(dialog, dlg.dialog.atr); |
154 | waddch(dialog, ACS_RTEE); | 156 | waddch(dialog, ACS_RTEE); |
155 | 157 | ||
156 | print_title(dialog, title, width); | 158 | print_title(dialog, title, width); |
157 | 159 | ||
158 | wattrset(dialog, dialog_attr); | 160 | wattrset(dialog, dlg.dialog.atr); |
159 | print_autowrap(dialog, prompt, width - 2, 1, 3); | 161 | print_autowrap(dialog, prompt, width - 2, 1, 3); |
160 | 162 | ||
161 | list_width = width - 6; | 163 | list_width = width - 6; |
@@ -170,7 +172,7 @@ int dialog_checklist(const char *title, const char *prompt, int height, | |||
170 | 172 | ||
171 | /* draw a box around the list items */ | 173 | /* draw a box around the list items */ |
172 | draw_box(dialog, box_y, box_x, list_height + 2, list_width + 2, | 174 | draw_box(dialog, box_y, box_x, list_height + 2, list_width + 2, |
173 | menubox_border_attr, menubox_attr); | 175 | dlg.menubox_border.atr, dlg.menubox.atr); |
174 | 176 | ||
175 | /* Find length of longest item in order to center checklist */ | 177 | /* Find length of longest item in order to center checklist */ |
176 | check_x = 0; | 178 | check_x = 0; |
diff --git a/scripts/kconfig/lxdialog/colors.h b/scripts/kconfig/lxdialog/colors.h deleted file mode 100644 index db071df12bbb..000000000000 --- a/scripts/kconfig/lxdialog/colors.h +++ /dev/null | |||
@@ -1,154 +0,0 @@ | |||
1 | /* | ||
2 | * colors.h -- color attribute definitions | ||
3 | * | ||
4 | * AUTHOR: Savio Lam (lam836@cs.cuhk.hk) | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License | ||
8 | * as published by the Free Software Foundation; either version 2 | ||
9 | * of the License, or (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
19 | */ | ||
20 | |||
21 | /* | ||
22 | * Default color definitions | ||
23 | * | ||
24 | * *_FG = foreground | ||
25 | * *_BG = background | ||
26 | * *_HL = highlight? | ||
27 | */ | ||
28 | #define SCREEN_FG COLOR_CYAN | ||
29 | #define SCREEN_BG COLOR_BLUE | ||
30 | #define SCREEN_HL TRUE | ||
31 | |||
32 | #define SHADOW_FG COLOR_BLACK | ||
33 | #define SHADOW_BG COLOR_BLACK | ||
34 | #define SHADOW_HL TRUE | ||
35 | |||
36 | #define DIALOG_FG COLOR_BLACK | ||
37 | #define DIALOG_BG COLOR_WHITE | ||
38 | #define DIALOG_HL FALSE | ||
39 | |||
40 | #define TITLE_FG COLOR_YELLOW | ||
41 | #define TITLE_BG COLOR_WHITE | ||
42 | #define TITLE_HL TRUE | ||
43 | |||
44 | #define BORDER_FG COLOR_WHITE | ||
45 | #define BORDER_BG COLOR_WHITE | ||
46 | #define BORDER_HL TRUE | ||
47 | |||
48 | #define BUTTON_ACTIVE_FG COLOR_WHITE | ||
49 | #define BUTTON_ACTIVE_BG COLOR_BLUE | ||
50 | #define BUTTON_ACTIVE_HL TRUE | ||
51 | |||
52 | #define BUTTON_INACTIVE_FG COLOR_BLACK | ||
53 | #define BUTTON_INACTIVE_BG COLOR_WHITE | ||
54 | #define BUTTON_INACTIVE_HL FALSE | ||
55 | |||
56 | #define BUTTON_KEY_ACTIVE_FG COLOR_WHITE | ||
57 | #define BUTTON_KEY_ACTIVE_BG COLOR_BLUE | ||
58 | #define BUTTON_KEY_ACTIVE_HL TRUE | ||
59 | |||
60 | #define BUTTON_KEY_INACTIVE_FG COLOR_RED | ||
61 | #define BUTTON_KEY_INACTIVE_BG COLOR_WHITE | ||
62 | #define BUTTON_KEY_INACTIVE_HL FALSE | ||
63 | |||
64 | #define BUTTON_LABEL_ACTIVE_FG COLOR_YELLOW | ||
65 | #define BUTTON_LABEL_ACTIVE_BG COLOR_BLUE | ||
66 | #define BUTTON_LABEL_ACTIVE_HL TRUE | ||
67 | |||
68 | #define BUTTON_LABEL_INACTIVE_FG COLOR_BLACK | ||
69 | #define BUTTON_LABEL_INACTIVE_BG COLOR_WHITE | ||
70 | #define BUTTON_LABEL_INACTIVE_HL TRUE | ||
71 | |||
72 | #define INPUTBOX_FG COLOR_BLACK | ||
73 | #define INPUTBOX_BG COLOR_WHITE | ||
74 | #define INPUTBOX_HL FALSE | ||
75 | |||
76 | #define INPUTBOX_BORDER_FG COLOR_BLACK | ||
77 | #define INPUTBOX_BORDER_BG COLOR_WHITE | ||
78 | #define INPUTBOX_BORDER_HL FALSE | ||
79 | |||
80 | #define SEARCHBOX_FG COLOR_BLACK | ||
81 | #define SEARCHBOX_BG COLOR_WHITE | ||
82 | #define SEARCHBOX_HL FALSE | ||
83 | |||
84 | #define SEARCHBOX_TITLE_FG COLOR_YELLOW | ||
85 | #define SEARCHBOX_TITLE_BG COLOR_WHITE | ||
86 | #define SEARCHBOX_TITLE_HL TRUE | ||
87 | |||
88 | #define SEARCHBOX_BORDER_FG COLOR_WHITE | ||
89 | #define SEARCHBOX_BORDER_BG COLOR_WHITE | ||
90 | #define SEARCHBOX_BORDER_HL TRUE | ||
91 | |||
92 | #define POSITION_INDICATOR_FG COLOR_YELLOW | ||
93 | #define POSITION_INDICATOR_BG COLOR_WHITE | ||
94 | #define POSITION_INDICATOR_HL TRUE | ||
95 | |||
96 | #define MENUBOX_FG COLOR_BLACK | ||
97 | #define MENUBOX_BG COLOR_WHITE | ||
98 | #define MENUBOX_HL FALSE | ||
99 | |||
100 | #define MENUBOX_BORDER_FG COLOR_WHITE | ||
101 | #define MENUBOX_BORDER_BG COLOR_WHITE | ||
102 | #define MENUBOX_BORDER_HL TRUE | ||
103 | |||
104 | #define ITEM_FG COLOR_BLACK | ||
105 | #define ITEM_BG COLOR_WHITE | ||
106 | #define ITEM_HL FALSE | ||
107 | |||
108 | #define ITEM_SELECTED_FG COLOR_WHITE | ||
109 | #define ITEM_SELECTED_BG COLOR_BLUE | ||
110 | #define ITEM_SELECTED_HL TRUE | ||
111 | |||
112 | #define TAG_FG COLOR_YELLOW | ||
113 | #define TAG_BG COLOR_WHITE | ||
114 | #define TAG_HL TRUE | ||
115 | |||
116 | #define TAG_SELECTED_FG COLOR_YELLOW | ||
117 | #define TAG_SELECTED_BG COLOR_BLUE | ||
118 | #define TAG_SELECTED_HL TRUE | ||
119 | |||
120 | #define TAG_KEY_FG COLOR_YELLOW | ||
121 | #define TAG_KEY_BG COLOR_WHITE | ||
122 | #define TAG_KEY_HL TRUE | ||
123 | |||
124 | #define TAG_KEY_SELECTED_FG COLOR_YELLOW | ||
125 | #define TAG_KEY_SELECTED_BG COLOR_BLUE | ||
126 | #define TAG_KEY_SELECTED_HL TRUE | ||
127 | |||
128 | #define CHECK_FG COLOR_BLACK | ||
129 | #define CHECK_BG COLOR_WHITE | ||
130 | #define CHECK_HL FALSE | ||
131 | |||
132 | #define CHECK_SELECTED_FG COLOR_WHITE | ||
133 | #define CHECK_SELECTED_BG COLOR_BLUE | ||
134 | #define CHECK_SELECTED_HL TRUE | ||
135 | |||
136 | #define UARROW_FG COLOR_GREEN | ||
137 | #define UARROW_BG COLOR_WHITE | ||
138 | #define UARROW_HL TRUE | ||
139 | |||
140 | #define DARROW_FG COLOR_GREEN | ||
141 | #define DARROW_BG COLOR_WHITE | ||
142 | #define DARROW_HL TRUE | ||
143 | |||
144 | /* End of default color definitions */ | ||
145 | |||
146 | #define C_ATTR(x,y) ((x ? A_BOLD : 0) | COLOR_PAIR((y))) | ||
147 | #define COLOR_NAME_LEN 10 | ||
148 | #define COLOR_COUNT 8 | ||
149 | |||
150 | /* | ||
151 | * Global variables | ||
152 | */ | ||
153 | |||
154 | extern int color_table[][3]; | ||
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 @@ | |||
87 | #endif | 87 | #endif |
88 | 88 | ||
89 | /* | 89 | /* |
90 | * Attribute names | 90 | * Color definitions |
91 | */ | 91 | */ |
92 | #define screen_attr attributes[0] | 92 | struct dialog_color { |
93 | #define shadow_attr attributes[1] | 93 | chtype atr; /* Color attribute */ |
94 | #define dialog_attr attributes[2] | 94 | int fg; /* foreground */ |
95 | #define title_attr attributes[3] | 95 | int bg; /* background */ |
96 | #define border_attr attributes[4] | 96 | int hl; /* highlight this item */ |
97 | #define button_active_attr attributes[5] | 97 | }; |
98 | #define button_inactive_attr attributes[6] | ||
99 | #define button_key_active_attr attributes[7] | ||
100 | #define button_key_inactive_attr attributes[8] | ||
101 | #define button_label_active_attr attributes[9] | ||
102 | #define button_label_inactive_attr attributes[10] | ||
103 | #define inputbox_attr attributes[11] | ||
104 | #define inputbox_border_attr attributes[12] | ||
105 | #define searchbox_attr attributes[13] | ||
106 | #define searchbox_title_attr attributes[14] | ||
107 | #define searchbox_border_attr attributes[15] | ||
108 | #define position_indicator_attr attributes[16] | ||
109 | #define menubox_attr attributes[17] | ||
110 | #define menubox_border_attr attributes[18] | ||
111 | #define item_attr attributes[19] | ||
112 | #define item_selected_attr attributes[20] | ||
113 | #define tag_attr attributes[21] | ||
114 | #define tag_selected_attr attributes[22] | ||
115 | #define tag_key_attr attributes[23] | ||
116 | #define tag_key_selected_attr attributes[24] | ||
117 | #define check_attr attributes[25] | ||
118 | #define check_selected_attr attributes[26] | ||
119 | #define uarrow_attr attributes[27] | ||
120 | #define darrow_attr attributes[28] | ||
121 | 98 | ||
122 | /* number of attributes */ | 99 | struct dialog_info { |
123 | #define ATTRIBUTE_COUNT 29 | 100 | const char *backtitle; |
101 | struct dialog_color screen; | ||
102 | struct dialog_color shadow; | ||
103 | struct dialog_color dialog; | ||
104 | struct dialog_color title; | ||
105 | struct dialog_color border; | ||
106 | struct dialog_color button_active; | ||
107 | struct dialog_color button_inactive; | ||
108 | struct dialog_color button_key_active; | ||
109 | struct dialog_color button_key_inactive; | ||
110 | struct dialog_color button_label_active; | ||
111 | struct dialog_color button_label_inactive; | ||
112 | struct dialog_color inputbox; | ||
113 | struct dialog_color inputbox_border; | ||
114 | struct dialog_color searchbox; | ||
115 | struct dialog_color searchbox_title; | ||
116 | struct dialog_color searchbox_border; | ||
117 | struct dialog_color position_indicator; | ||
118 | struct dialog_color menubox; | ||
119 | struct dialog_color menubox_border; | ||
120 | struct dialog_color item; | ||
121 | struct dialog_color item_selected; | ||
122 | struct dialog_color tag; | ||
123 | struct dialog_color tag_selected; | ||
124 | struct dialog_color tag_key; | ||
125 | struct dialog_color tag_key_selected; | ||
126 | struct dialog_color check; | ||
127 | struct dialog_color check_selected; | ||
128 | struct dialog_color uarrow; | ||
129 | struct dialog_color darrow; | ||
130 | }; | ||
124 | 131 | ||
125 | /* | 132 | /* |
126 | * Global variables | 133 | * Global variables |
127 | */ | 134 | */ |
128 | extern bool use_colors; | 135 | extern struct dialog_info dlg; |
129 | extern bool use_shadow; | ||
130 | |||
131 | extern chtype attributes[]; | ||
132 | |||
133 | extern const char *backtitle; | ||
134 | 136 | ||
135 | /* | 137 | /* |
136 | * Function prototypes | 138 | * Function prototypes |
137 | */ | 139 | */ |
138 | extern void create_rc(const char *filename); | ||
139 | extern int parse_rc(void); | ||
140 | |||
141 | void init_dialog(void); | 140 | void init_dialog(void); |
142 | void end_dialog(void); | 141 | void end_dialog(void); |
143 | void attr_clear(WINDOW * win, int height, int width, chtype attr); | 142 | void attr_clear(WINDOW * win, int height, int width, chtype attr); |
144 | void dialog_clear(void); | 143 | void dialog_clear(void); |
145 | void color_setup(void); | ||
146 | void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x); | 144 | void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x); |
147 | void print_button(WINDOW * win, const char *label, int y, int x, int selected); | 145 | void print_button(WINDOW * win, const char *label, int y, int x, int selected); |
148 | void print_title(WINDOW *dialog, const char *title, int width); | 146 | void print_title(WINDOW *dialog, const char *title, int width); |
diff --git a/scripts/kconfig/lxdialog/inputbox.c b/scripts/kconfig/lxdialog/inputbox.c index 779503726b0a..f75b51f8e636 100644 --- a/scripts/kconfig/lxdialog/inputbox.c +++ b/scripts/kconfig/lxdialog/inputbox.c | |||
@@ -58,17 +58,18 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width | |||
58 | dialog = newwin(height, width, y, x); | 58 | dialog = newwin(height, width, y, x); |
59 | keypad(dialog, TRUE); | 59 | keypad(dialog, TRUE); |
60 | 60 | ||
61 | draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr); | 61 | draw_box(dialog, 0, 0, height, width, |
62 | wattrset(dialog, border_attr); | 62 | dlg.dialog.atr, dlg.border.atr); |
63 | wattrset(dialog, dlg.border.atr); | ||
63 | mvwaddch(dialog, height - 3, 0, ACS_LTEE); | 64 | mvwaddch(dialog, height - 3, 0, ACS_LTEE); |
64 | for (i = 0; i < width - 2; i++) | 65 | for (i = 0; i < width - 2; i++) |
65 | waddch(dialog, ACS_HLINE); | 66 | waddch(dialog, ACS_HLINE); |
66 | wattrset(dialog, dialog_attr); | 67 | wattrset(dialog, dlg.dialog.atr); |
67 | waddch(dialog, ACS_RTEE); | 68 | waddch(dialog, ACS_RTEE); |
68 | 69 | ||
69 | print_title(dialog, title, width); | 70 | print_title(dialog, title, width); |
70 | 71 | ||
71 | wattrset(dialog, dialog_attr); | 72 | wattrset(dialog, dlg.dialog.atr); |
72 | print_autowrap(dialog, prompt, width - 2, 1, 3); | 73 | print_autowrap(dialog, prompt, width - 2, 1, 3); |
73 | 74 | ||
74 | /* Draw the input field box */ | 75 | /* Draw the input field box */ |
@@ -76,13 +77,14 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width | |||
76 | getyx(dialog, y, x); | 77 | getyx(dialog, y, x); |
77 | box_y = y + 2; | 78 | box_y = y + 2; |
78 | box_x = (width - box_width) / 2; | 79 | box_x = (width - box_width) / 2; |
79 | draw_box(dialog, y + 1, box_x - 1, 3, box_width + 2, border_attr, dialog_attr); | 80 | draw_box(dialog, y + 1, box_x - 1, 3, box_width + 2, |
81 | dlg.border.atr, dlg.dialog.atr); | ||
80 | 82 | ||
81 | print_buttons(dialog, height, width, 0); | 83 | print_buttons(dialog, height, width, 0); |
82 | 84 | ||
83 | /* Set up the initial value */ | 85 | /* Set up the initial value */ |
84 | wmove(dialog, box_y, box_x); | 86 | wmove(dialog, box_y, box_x); |
85 | wattrset(dialog, inputbox_attr); | 87 | wattrset(dialog, dlg.inputbox.atr); |
86 | 88 | ||
87 | if (!init) | 89 | if (!init) |
88 | instr[0] = '\0'; | 90 | instr[0] = '\0'; |
@@ -120,7 +122,7 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width | |||
120 | case KEY_BACKSPACE: | 122 | case KEY_BACKSPACE: |
121 | case 127: | 123 | case 127: |
122 | if (input_x || scroll) { | 124 | if (input_x || scroll) { |
123 | wattrset(dialog, inputbox_attr); | 125 | wattrset(dialog, dlg.inputbox.atr); |
124 | if (!input_x) { | 126 | if (!input_x) { |
125 | scroll = scroll < box_width - 1 ? 0 : scroll - (box_width - 1); | 127 | scroll = scroll < box_width - 1 ? 0 : scroll - (box_width - 1); |
126 | wmove(dialog, box_y, box_x); | 128 | wmove(dialog, box_y, box_x); |
@@ -140,7 +142,7 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width | |||
140 | default: | 142 | default: |
141 | if (key < 0x100 && isprint(key)) { | 143 | if (key < 0x100 && isprint(key)) { |
142 | if (scroll + input_x < MAX_LEN) { | 144 | if (scroll + input_x < MAX_LEN) { |
143 | wattrset(dialog, inputbox_attr); | 145 | wattrset(dialog, dlg.inputbox.atr); |
144 | instr[scroll + input_x] = key; | 146 | instr[scroll + input_x] = key; |
145 | instr[scroll + input_x + 1] = '\0'; | 147 | instr[scroll + input_x + 1] = '\0'; |
146 | if (input_x == box_width - 1) { | 148 | if (input_x == box_width - 1) { |
diff --git a/scripts/kconfig/lxdialog/lxdialog.c b/scripts/kconfig/lxdialog/lxdialog.c index 79f6c5fb5cef..c264e024309e 100644 --- a/scripts/kconfig/lxdialog/lxdialog.c +++ b/scripts/kconfig/lxdialog/lxdialog.c | |||
@@ -78,11 +78,11 @@ int main(int argc, const char *const *argv) | |||
78 | offset += 2; | 78 | offset += 2; |
79 | } | 79 | } |
80 | } else if (!strcmp(argv[offset + 1], "--backtitle")) { | 80 | } else if (!strcmp(argv[offset + 1], "--backtitle")) { |
81 | if (backtitle != NULL) { | 81 | if (dlg.backtitle != NULL) { |
82 | Usage(argv[0]); | 82 | Usage(argv[0]); |
83 | exit(-1); | 83 | exit(-1); |
84 | } else { | 84 | } else { |
85 | backtitle = argv[offset + 2]; | 85 | dlg.backtitle = argv[offset + 2]; |
86 | offset += 2; | 86 | offset += 2; |
87 | } | 87 | } |
88 | } else if (!strcmp(argv[offset + 1], "--clear")) { | 88 | } else if (!strcmp(argv[offset + 1], "--clear")) { |
@@ -123,7 +123,7 @@ int main(int argc, const char *const *argv) | |||
123 | retval = (*(modePtr->jumper)) (title, argc - offset, argv + offset); | 123 | retval = (*(modePtr->jumper)) (title, argc - offset, argv + offset); |
124 | 124 | ||
125 | if (opt_clear) { /* clear screen before exit */ | 125 | if (opt_clear) { /* clear screen before exit */ |
126 | attr_clear(stdscr, LINES, COLS, screen_attr); | 126 | attr_clear(stdscr, LINES, COLS, dlg.screen.atr); |
127 | refresh(); | 127 | refresh(); |
128 | } | 128 | } |
129 | end_dialog(); | 129 | end_dialog(); |
diff --git a/scripts/kconfig/lxdialog/menubox.c b/scripts/kconfig/lxdialog/menubox.c index bf8052f4fd4a..ff991db827bd 100644 --- a/scripts/kconfig/lxdialog/menubox.c +++ b/scripts/kconfig/lxdialog/menubox.c | |||
@@ -74,7 +74,7 @@ static void do_print_item(WINDOW * win, const char *item, int choice, | |||
74 | j = first_alpha(menu_item, "YyNnMmHh"); | 74 | j = first_alpha(menu_item, "YyNnMmHh"); |
75 | 75 | ||
76 | /* Clear 'residue' of last item */ | 76 | /* Clear 'residue' of last item */ |
77 | wattrset(win, menubox_attr); | 77 | wattrset(win, dlg.menubox.atr); |
78 | wmove(win, choice, 0); | 78 | wmove(win, choice, 0); |
79 | #if OLD_NCURSES | 79 | #if OLD_NCURSES |
80 | { | 80 | { |
@@ -85,10 +85,11 @@ static void do_print_item(WINDOW * win, const char *item, int choice, | |||
85 | #else | 85 | #else |
86 | wclrtoeol(win); | 86 | wclrtoeol(win); |
87 | #endif | 87 | #endif |
88 | wattrset(win, selected ? item_selected_attr : item_attr); | 88 | wattrset(win, selected ? dlg.item_selected.atr : dlg.item.atr); |
89 | mvwaddstr(win, choice, item_x, menu_item); | 89 | mvwaddstr(win, choice, item_x, menu_item); |
90 | if (hotkey) { | 90 | if (hotkey) { |
91 | wattrset(win, selected ? tag_key_selected_attr : tag_key_attr); | 91 | wattrset(win, selected ? dlg.tag_key_selected.atr |
92 | : dlg.tag_key.atr); | ||
92 | mvwaddch(win, choice, item_x + j, menu_item[j]); | 93 | mvwaddch(win, choice, item_x + j, menu_item[j]); |
93 | } | 94 | } |
94 | if (selected) { | 95 | if (selected) { |
@@ -117,11 +118,11 @@ static void print_arrows(WINDOW * win, int item_no, int scroll, int y, int x, | |||
117 | wmove(win, y, x); | 118 | wmove(win, y, x); |
118 | 119 | ||
119 | if (scroll > 0) { | 120 | if (scroll > 0) { |
120 | wattrset(win, uarrow_attr); | 121 | wattrset(win, dlg.uarrow.atr); |
121 | waddch(win, ACS_UARROW); | 122 | waddch(win, ACS_UARROW); |
122 | waddstr(win, "(-)"); | 123 | waddstr(win, "(-)"); |
123 | } else { | 124 | } else { |
124 | wattrset(win, menubox_attr); | 125 | wattrset(win, dlg.menubox.atr); |
125 | waddch(win, ACS_HLINE); | 126 | waddch(win, ACS_HLINE); |
126 | waddch(win, ACS_HLINE); | 127 | waddch(win, ACS_HLINE); |
127 | waddch(win, ACS_HLINE); | 128 | waddch(win, ACS_HLINE); |
@@ -133,11 +134,11 @@ static void print_arrows(WINDOW * win, int item_no, int scroll, int y, int x, | |||
133 | wrefresh(win); | 134 | wrefresh(win); |
134 | 135 | ||
135 | if ((height < item_no) && (scroll + height < item_no)) { | 136 | if ((height < item_no) && (scroll + height < item_no)) { |
136 | wattrset(win, darrow_attr); | 137 | wattrset(win, dlg.darrow.atr); |
137 | waddch(win, ACS_DARROW); | 138 | waddch(win, ACS_DARROW); |
138 | waddstr(win, "(+)"); | 139 | waddstr(win, "(+)"); |
139 | } else { | 140 | } else { |
140 | wattrset(win, menubox_border_attr); | 141 | wattrset(win, dlg.menubox_border.atr); |
141 | waddch(win, ACS_HLINE); | 142 | waddch(win, ACS_HLINE); |
142 | waddch(win, ACS_HLINE); | 143 | waddch(win, ACS_HLINE); |
143 | waddch(win, ACS_HLINE); | 144 | waddch(win, ACS_HLINE); |
@@ -199,18 +200,19 @@ int dialog_menu(const char *title, const char *prompt, int height, int width, | |||
199 | dialog = newwin(height, width, y, x); | 200 | dialog = newwin(height, width, y, x); |
200 | keypad(dialog, TRUE); | 201 | keypad(dialog, TRUE); |
201 | 202 | ||
202 | draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr); | 203 | draw_box(dialog, 0, 0, height, width, |
203 | wattrset(dialog, border_attr); | 204 | dlg.dialog.atr, dlg.border.atr); |
205 | wattrset(dialog, dlg.border.atr); | ||
204 | mvwaddch(dialog, height - 3, 0, ACS_LTEE); | 206 | mvwaddch(dialog, height - 3, 0, ACS_LTEE); |
205 | for (i = 0; i < width - 2; i++) | 207 | for (i = 0; i < width - 2; i++) |
206 | waddch(dialog, ACS_HLINE); | 208 | waddch(dialog, ACS_HLINE); |
207 | wattrset(dialog, dialog_attr); | 209 | wattrset(dialog, dlg.dialog.atr); |
208 | wbkgdset(dialog, dialog_attr & A_COLOR); | 210 | wbkgdset(dialog, dlg.dialog.atr & A_COLOR); |
209 | waddch(dialog, ACS_RTEE); | 211 | waddch(dialog, ACS_RTEE); |
210 | 212 | ||
211 | print_title(dialog, title, width); | 213 | print_title(dialog, title, width); |
212 | 214 | ||
213 | wattrset(dialog, dialog_attr); | 215 | wattrset(dialog, dlg.dialog.atr); |
214 | print_autowrap(dialog, prompt, width - 2, 1, 3); | 216 | print_autowrap(dialog, prompt, width - 2, 1, 3); |
215 | 217 | ||
216 | menu_width = width - 6; | 218 | menu_width = width - 6; |
@@ -224,7 +226,7 @@ int dialog_menu(const char *title, const char *prompt, int height, int width, | |||
224 | 226 | ||
225 | /* draw a box around the menu items */ | 227 | /* draw a box around the menu items */ |
226 | draw_box(dialog, box_y, box_x, menu_height + 2, menu_width + 2, | 228 | draw_box(dialog, box_y, box_x, menu_height + 2, menu_width + 2, |
227 | menubox_border_attr, menubox_attr); | 229 | dlg.menubox_border.atr, dlg.menubox.atr); |
228 | 230 | ||
229 | item_x = (menu_width - 70) / 2; | 231 | item_x = (menu_width - 70) / 2; |
230 | 232 | ||
diff --git a/scripts/kconfig/lxdialog/msgbox.c b/scripts/kconfig/lxdialog/msgbox.c index 7323f5471f69..236759ff3f4e 100644 --- a/scripts/kconfig/lxdialog/msgbox.c +++ b/scripts/kconfig/lxdialog/msgbox.c | |||
@@ -40,19 +40,20 @@ int dialog_msgbox(const char *title, const char *prompt, int height, int width, | |||
40 | dialog = newwin(height, width, y, x); | 40 | dialog = newwin(height, width, y, x); |
41 | keypad(dialog, TRUE); | 41 | keypad(dialog, TRUE); |
42 | 42 | ||
43 | draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr); | 43 | draw_box(dialog, 0, 0, height, width, |
44 | dlg.dialog.atr, dlg.border.atr); | ||
44 | 45 | ||
45 | print_title(dialog, title, width); | 46 | print_title(dialog, title, width); |
46 | 47 | ||
47 | wattrset(dialog, dialog_attr); | 48 | wattrset(dialog, dlg.dialog.atr); |
48 | print_autowrap(dialog, prompt, width - 2, 1, 2); | 49 | print_autowrap(dialog, prompt, width - 2, 1, 2); |
49 | 50 | ||
50 | if (pause) { | 51 | if (pause) { |
51 | wattrset(dialog, border_attr); | 52 | wattrset(dialog, dlg.border.atr); |
52 | mvwaddch(dialog, height - 3, 0, ACS_LTEE); | 53 | mvwaddch(dialog, height - 3, 0, ACS_LTEE); |
53 | for (i = 0; i < width - 2; i++) | 54 | for (i = 0; i < width - 2; i++) |
54 | waddch(dialog, ACS_HLINE); | 55 | waddch(dialog, ACS_HLINE); |
55 | wattrset(dialog, dialog_attr); | 56 | wattrset(dialog, dlg.dialog.atr); |
56 | waddch(dialog, ACS_RTEE); | 57 | waddch(dialog, ACS_RTEE); |
57 | 58 | ||
58 | print_button(dialog, " Ok ", height - 2, width / 2 - 4, TRUE); | 59 | print_button(dialog, " Ok ", height - 2, width / 2 - 4, TRUE); |
diff --git a/scripts/kconfig/lxdialog/textbox.c b/scripts/kconfig/lxdialog/textbox.c index 77848bb8e07f..336793b03954 100644 --- a/scripts/kconfig/lxdialog/textbox.c +++ b/scripts/kconfig/lxdialog/textbox.c | |||
@@ -87,20 +87,21 @@ int dialog_textbox(const char *title, const char *file, int height, int width) | |||
87 | 87 | ||
88 | /* Create window for text region, used for scrolling text */ | 88 | /* Create window for text region, used for scrolling text */ |
89 | text = subwin(dialog, height - 4, width - 2, y + 1, x + 1); | 89 | text = subwin(dialog, height - 4, width - 2, y + 1, x + 1); |
90 | wattrset(text, dialog_attr); | 90 | wattrset(text, dlg.dialog.atr); |
91 | wbkgdset(text, dialog_attr & A_COLOR); | 91 | wbkgdset(text, dlg.dialog.atr & A_COLOR); |
92 | 92 | ||
93 | keypad(text, TRUE); | 93 | keypad(text, TRUE); |
94 | 94 | ||
95 | /* register the new window, along with its borders */ | 95 | /* register the new window, along with its borders */ |
96 | draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr); | 96 | draw_box(dialog, 0, 0, height, width, |
97 | dlg.dialog.atr, dlg.border.atr); | ||
97 | 98 | ||
98 | wattrset(dialog, border_attr); | 99 | wattrset(dialog, dlg.border.atr); |
99 | mvwaddch(dialog, height - 3, 0, ACS_LTEE); | 100 | mvwaddch(dialog, height - 3, 0, ACS_LTEE); |
100 | for (i = 0; i < width - 2; i++) | 101 | for (i = 0; i < width - 2; i++) |
101 | waddch(dialog, ACS_HLINE); | 102 | waddch(dialog, ACS_HLINE); |
102 | wattrset(dialog, dialog_attr); | 103 | wattrset(dialog, dlg.dialog.atr); |
103 | wbkgdset(dialog, dialog_attr & A_COLOR); | 104 | wbkgdset(dialog, dlg.dialog.atr & A_COLOR); |
104 | waddch(dialog, ACS_RTEE); | 105 | waddch(dialog, ACS_RTEE); |
105 | 106 | ||
106 | print_title(dialog, title, width); | 107 | print_title(dialog, title, width); |
@@ -110,7 +111,7 @@ int dialog_textbox(const char *title, const char *file, int height, int width) | |||
110 | getyx(dialog, cur_y, cur_x); /* Save cursor position */ | 111 | getyx(dialog, cur_y, cur_x); /* Save cursor position */ |
111 | 112 | ||
112 | /* Print first page of text */ | 113 | /* Print first page of text */ |
113 | attr_clear(text, height - 4, width - 2, dialog_attr); | 114 | attr_clear(text, height - 4, width - 2, dlg.dialog.atr); |
114 | print_page(text, height - 4, width - 2); | 115 | print_page(text, height - 4, width - 2); |
115 | print_position(dialog, height, width); | 116 | print_position(dialog, height, width); |
116 | wmove(dialog, cur_y, cur_x); /* Restore cursor position */ | 117 | wmove(dialog, cur_y, cur_x); /* Restore cursor position */ |
@@ -524,8 +525,8 @@ static void print_position(WINDOW * win, int height, int width) | |||
524 | fprintf(stderr, "\nError moving file pointer in print_position().\n"); | 525 | fprintf(stderr, "\nError moving file pointer in print_position().\n"); |
525 | exit(-1); | 526 | exit(-1); |
526 | } | 527 | } |
527 | wattrset(win, position_indicator_attr); | 528 | wattrset(win, dlg.position_indicator.atr); |
528 | wbkgdset(win, position_indicator_attr & A_COLOR); | 529 | wbkgdset(win, dlg.position_indicator.atr & A_COLOR); |
529 | percent = !file_size ? | 530 | percent = !file_size ? |
530 | 100 : ((fpos - bytes_read + page - buf) * 100) / file_size; | 531 | 100 : ((fpos - bytes_read + page - buf) * 100) / file_size; |
531 | wmove(win, height - 3, width - 9); | 532 | wmove(win, height - 3, width - 9); |
diff --git a/scripts/kconfig/lxdialog/util.c b/scripts/kconfig/lxdialog/util.c index f82cebb9ff06..08f98b1c4bb3 100644 --- a/scripts/kconfig/lxdialog/util.c +++ b/scripts/kconfig/lxdialog/util.c | |||
@@ -21,85 +21,141 @@ | |||
21 | 21 | ||
22 | #include "dialog.h" | 22 | #include "dialog.h" |
23 | 23 | ||
24 | /* use colors by default? */ | 24 | struct dialog_info dlg; |
25 | bool use_colors = 1; | ||
26 | 25 | ||
27 | const char *backtitle = NULL; | 26 | static void set_mono_theme(void) |
27 | { | ||
28 | dlg.screen.atr = A_NORMAL; | ||
29 | dlg.shadow.atr = A_NORMAL; | ||
30 | dlg.dialog.atr = A_NORMAL; | ||
31 | dlg.title.atr = A_BOLD; | ||
32 | dlg.border.atr = A_NORMAL; | ||
33 | dlg.button_active.atr = A_REVERSE; | ||
34 | dlg.button_inactive.atr = A_DIM; | ||
35 | dlg.button_key_active.atr = A_REVERSE; | ||
36 | dlg.button_key_inactive.atr = A_BOLD; | ||
37 | dlg.button_label_active.atr = A_REVERSE; | ||
38 | dlg.button_label_inactive.atr = A_NORMAL; | ||
39 | dlg.inputbox.atr = A_NORMAL; | ||
40 | dlg.inputbox_border.atr = A_NORMAL; | ||
41 | dlg.searchbox.atr = A_NORMAL; | ||
42 | dlg.searchbox_title.atr = A_BOLD; | ||
43 | dlg.searchbox_border.atr = A_NORMAL; | ||
44 | dlg.position_indicator.atr = A_BOLD; | ||
45 | dlg.menubox.atr = A_NORMAL; | ||
46 | dlg.menubox_border.atr = A_NORMAL; | ||
47 | dlg.item.atr = A_NORMAL; | ||
48 | dlg.item_selected.atr = A_REVERSE; | ||
49 | dlg.tag.atr = A_BOLD; | ||
50 | dlg.tag_selected.atr = A_REVERSE; | ||
51 | dlg.tag_key.atr = A_BOLD; | ||
52 | dlg.tag_key_selected.atr = A_REVERSE; | ||
53 | dlg.check.atr = A_BOLD; | ||
54 | dlg.check_selected.atr = A_REVERSE; | ||
55 | dlg.uarrow.atr = A_BOLD; | ||
56 | dlg.darrow.atr = A_BOLD; | ||
57 | } | ||
28 | 58 | ||
29 | /* | 59 | #define DLG_COLOR(dialog, f, b, h) \ |
30 | * Attribute values, default is for mono display | 60 | do { \ |
31 | */ | 61 | dlg.dialog.fg = (f); \ |
32 | chtype attributes[] = { | 62 | dlg.dialog.bg = (b); \ |
33 | A_NORMAL, /* screen_attr */ | 63 | dlg.dialog.hl = (h); \ |
34 | A_NORMAL, /* shadow_attr */ | 64 | } while (0) |
35 | A_NORMAL, /* dialog_attr */ | 65 | |
36 | A_BOLD, /* title_attr */ | 66 | static void set_classic_theme(void) |
37 | A_NORMAL, /* border_attr */ | 67 | { |
38 | A_REVERSE, /* button_active_attr */ | 68 | DLG_COLOR(screen, COLOR_CYAN, COLOR_BLUE, true); |
39 | A_DIM, /* button_inactive_attr */ | 69 | DLG_COLOR(shadow, COLOR_BLACK, COLOR_BLACK, true); |
40 | A_REVERSE, /* button_key_active_attr */ | 70 | DLG_COLOR(dialog, COLOR_BLACK, COLOR_WHITE, false); |
41 | A_BOLD, /* button_key_inactive_attr */ | 71 | DLG_COLOR(title, COLOR_YELLOW, COLOR_WHITE, true); |
42 | A_REVERSE, /* button_label_active_attr */ | 72 | DLG_COLOR(border, COLOR_WHITE, COLOR_WHITE, true); |
43 | A_NORMAL, /* button_label_inactive_attr */ | 73 | DLG_COLOR(button_active, COLOR_WHITE, COLOR_BLUE, true); |
44 | A_NORMAL, /* inputbox_attr */ | 74 | DLG_COLOR(button_inactive, COLOR_BLACK, COLOR_WHITE, false); |
45 | A_NORMAL, /* inputbox_border_attr */ | 75 | DLG_COLOR(button_key_active, COLOR_WHITE, COLOR_BLUE, true); |
46 | A_NORMAL, /* searchbox_attr */ | 76 | DLG_COLOR(button_key_inactive, COLOR_RED, COLOR_WHITE, false); |
47 | A_BOLD, /* searchbox_title_attr */ | 77 | DLG_COLOR(button_label_active, COLOR_YELLOW, COLOR_BLUE, true); |
48 | A_NORMAL, /* searchbox_border_attr */ | 78 | DLG_COLOR(button_label_inactive, COLOR_BLACK, COLOR_WHITE, true); |
49 | A_BOLD, /* position_indicator_attr */ | 79 | DLG_COLOR(inputbox, COLOR_BLACK, COLOR_WHITE, false); |
50 | A_NORMAL, /* menubox_attr */ | 80 | DLG_COLOR(inputbox_border, COLOR_BLACK, COLOR_WHITE, false); |
51 | A_NORMAL, /* menubox_border_attr */ | 81 | DLG_COLOR(searchbox, COLOR_BLACK, COLOR_WHITE, false); |
52 | A_NORMAL, /* item_attr */ | 82 | DLG_COLOR(searchbox_title, COLOR_YELLOW, COLOR_WHITE, true); |
53 | A_REVERSE, /* item_selected_attr */ | 83 | DLG_COLOR(searchbox_border, COLOR_WHITE, COLOR_WHITE, true); |
54 | A_BOLD, /* tag_attr */ | 84 | DLG_COLOR(position_indicator, COLOR_YELLOW, COLOR_WHITE, true); |
55 | A_REVERSE, /* tag_selected_attr */ | 85 | DLG_COLOR(menubox, COLOR_BLACK, COLOR_WHITE, false); |
56 | A_BOLD, /* tag_key_attr */ | 86 | DLG_COLOR(menubox_border, COLOR_WHITE, COLOR_WHITE, true); |
57 | A_REVERSE, /* tag_key_selected_attr */ | 87 | DLG_COLOR(item, COLOR_BLACK, COLOR_WHITE, false); |
58 | A_BOLD, /* check_attr */ | 88 | DLG_COLOR(item_selected, COLOR_WHITE, COLOR_BLUE, true); |
59 | A_REVERSE, /* check_selected_attr */ | 89 | DLG_COLOR(tag, COLOR_YELLOW, COLOR_WHITE, true); |
60 | A_BOLD, /* uarrow_attr */ | 90 | DLG_COLOR(tag_selected, COLOR_YELLOW, COLOR_BLUE, true); |
61 | A_BOLD /* darrow_attr */ | 91 | DLG_COLOR(tag_key, COLOR_YELLOW, COLOR_WHITE, true); |
62 | }; | 92 | DLG_COLOR(tag_key_selected, COLOR_YELLOW, COLOR_BLUE, true); |
63 | 93 | DLG_COLOR(check, COLOR_BLACK, COLOR_WHITE, false); | |
64 | #include "colors.h" | 94 | DLG_COLOR(check_selected, COLOR_WHITE, COLOR_BLUE, true); |
95 | DLG_COLOR(uarrow, COLOR_GREEN, COLOR_WHITE, true); | ||
96 | DLG_COLOR(darrow, COLOR_GREEN, COLOR_WHITE, true); | ||
97 | } | ||
98 | |||
99 | static void init_one_color(struct dialog_color *color) | ||
100 | { | ||
101 | static int pair = 0; | ||
102 | |||
103 | pair++; | ||
104 | init_pair(pair, color->fg, color->bg); | ||
105 | if (color->hl) | ||
106 | color->atr = A_BOLD | COLOR_PAIR(pair); | ||
107 | else | ||
108 | color->atr = COLOR_PAIR(pair); | ||
109 | } | ||
110 | |||
111 | static void init_dialog_colors(void) | ||
112 | { | ||
113 | init_one_color(&dlg.screen); | ||
114 | init_one_color(&dlg.shadow); | ||
115 | init_one_color(&dlg.dialog); | ||
116 | init_one_color(&dlg.title); | ||
117 | init_one_color(&dlg.border); | ||
118 | init_one_color(&dlg.button_active); | ||
119 | init_one_color(&dlg.button_inactive); | ||
120 | init_one_color(&dlg.button_key_active); | ||
121 | init_one_color(&dlg.button_key_inactive); | ||
122 | init_one_color(&dlg.button_label_active); | ||
123 | init_one_color(&dlg.button_label_inactive); | ||
124 | init_one_color(&dlg.inputbox); | ||
125 | init_one_color(&dlg.inputbox_border); | ||
126 | init_one_color(&dlg.searchbox); | ||
127 | init_one_color(&dlg.searchbox_title); | ||
128 | init_one_color(&dlg.searchbox_border); | ||
129 | init_one_color(&dlg.position_indicator); | ||
130 | init_one_color(&dlg.menubox); | ||
131 | init_one_color(&dlg.menubox_border); | ||
132 | init_one_color(&dlg.item); | ||
133 | init_one_color(&dlg.item_selected); | ||
134 | init_one_color(&dlg.tag); | ||
135 | init_one_color(&dlg.tag_selected); | ||
136 | init_one_color(&dlg.tag_key); | ||
137 | init_one_color(&dlg.tag_key_selected); | ||
138 | init_one_color(&dlg.check); | ||
139 | init_one_color(&dlg.check_selected); | ||
140 | init_one_color(&dlg.uarrow); | ||
141 | init_one_color(&dlg.darrow); | ||
142 | } | ||
65 | 143 | ||
66 | /* | 144 | /* |
67 | * Table of color values | 145 | * Setup for color display |
68 | */ | 146 | */ |
69 | int color_table[][3] = { | 147 | static void color_setup(void) |
70 | {SCREEN_FG, SCREEN_BG, SCREEN_HL}, | 148 | { |
71 | {SHADOW_FG, SHADOW_BG, SHADOW_HL}, | 149 | if (has_colors()) { /* Terminal supports color? */ |
72 | {DIALOG_FG, DIALOG_BG, DIALOG_HL}, | 150 | start_color(); |
73 | {TITLE_FG, TITLE_BG, TITLE_HL}, | 151 | set_classic_theme(); |
74 | {BORDER_FG, BORDER_BG, BORDER_HL}, | 152 | init_dialog_colors(); |
75 | {BUTTON_ACTIVE_FG, BUTTON_ACTIVE_BG, BUTTON_ACTIVE_HL}, | 153 | } |
76 | {BUTTON_INACTIVE_FG, BUTTON_INACTIVE_BG, BUTTON_INACTIVE_HL}, | 154 | else |
77 | {BUTTON_KEY_ACTIVE_FG, BUTTON_KEY_ACTIVE_BG, BUTTON_KEY_ACTIVE_HL}, | 155 | { |
78 | {BUTTON_KEY_INACTIVE_FG, BUTTON_KEY_INACTIVE_BG, | 156 | set_mono_theme(); |
79 | BUTTON_KEY_INACTIVE_HL}, | 157 | } |
80 | {BUTTON_LABEL_ACTIVE_FG, BUTTON_LABEL_ACTIVE_BG, | 158 | } |
81 | BUTTON_LABEL_ACTIVE_HL}, | ||
82 | {BUTTON_LABEL_INACTIVE_FG, BUTTON_LABEL_INACTIVE_BG, | ||
83 | BUTTON_LABEL_INACTIVE_HL}, | ||
84 | {INPUTBOX_FG, INPUTBOX_BG, INPUTBOX_HL}, | ||
85 | {INPUTBOX_BORDER_FG, INPUTBOX_BORDER_BG, INPUTBOX_BORDER_HL}, | ||
86 | {SEARCHBOX_FG, SEARCHBOX_BG, SEARCHBOX_HL}, | ||
87 | {SEARCHBOX_TITLE_FG, SEARCHBOX_TITLE_BG, SEARCHBOX_TITLE_HL}, | ||
88 | {SEARCHBOX_BORDER_FG, SEARCHBOX_BORDER_BG, SEARCHBOX_BORDER_HL}, | ||
89 | {POSITION_INDICATOR_FG, POSITION_INDICATOR_BG, POSITION_INDICATOR_HL}, | ||
90 | {MENUBOX_FG, MENUBOX_BG, MENUBOX_HL}, | ||
91 | {MENUBOX_BORDER_FG, MENUBOX_BORDER_BG, MENUBOX_BORDER_HL}, | ||
92 | {ITEM_FG, ITEM_BG, ITEM_HL}, | ||
93 | {ITEM_SELECTED_FG, ITEM_SELECTED_BG, ITEM_SELECTED_HL}, | ||
94 | {TAG_FG, TAG_BG, TAG_HL}, | ||
95 | {TAG_SELECTED_FG, TAG_SELECTED_BG, TAG_SELECTED_HL}, | ||
96 | {TAG_KEY_FG, TAG_KEY_BG, TAG_KEY_HL}, | ||
97 | {TAG_KEY_SELECTED_FG, TAG_KEY_SELECTED_BG, TAG_KEY_SELECTED_HL}, | ||
98 | {CHECK_FG, CHECK_BG, CHECK_HL}, | ||
99 | {CHECK_SELECTED_FG, CHECK_SELECTED_BG, CHECK_SELECTED_HL}, | ||
100 | {UARROW_FG, UARROW_BG, UARROW_HL}, | ||
101 | {DARROW_FG, DARROW_BG, DARROW_HL}, | ||
102 | }; /* color_table */ | ||
103 | 159 | ||
104 | /* | 160 | /* |
105 | * Set window to attribute 'attr' | 161 | * Set window to attribute 'attr' |
@@ -119,13 +175,13 @@ void attr_clear(WINDOW * win, int height, int width, chtype attr) | |||
119 | 175 | ||
120 | void dialog_clear(void) | 176 | void dialog_clear(void) |
121 | { | 177 | { |
122 | attr_clear(stdscr, LINES, COLS, screen_attr); | 178 | attr_clear(stdscr, LINES, COLS, dlg.screen.atr); |
123 | /* Display background title if it exists ... - SLH */ | 179 | /* Display background title if it exists ... - SLH */ |
124 | if (backtitle != NULL) { | 180 | if (dlg.backtitle != NULL) { |
125 | int i; | 181 | int i; |
126 | 182 | ||
127 | wattrset(stdscr, screen_attr); | 183 | wattrset(stdscr, dlg.screen.atr); |
128 | mvwaddstr(stdscr, 0, 1, (char *)backtitle); | 184 | mvwaddstr(stdscr, 0, 1, (char *)dlg.backtitle); |
129 | wmove(stdscr, 1, 1); | 185 | wmove(stdscr, 1, 1); |
130 | for (i = 1; i < COLS - 1; i++) | 186 | for (i = 1; i < COLS - 1; i++) |
131 | waddch(stdscr, ACS_HLINE); | 187 | waddch(stdscr, ACS_HLINE); |
@@ -142,34 +198,11 @@ void init_dialog(void) | |||
142 | keypad(stdscr, TRUE); | 198 | keypad(stdscr, TRUE); |
143 | cbreak(); | 199 | cbreak(); |
144 | noecho(); | 200 | noecho(); |
145 | 201 | color_setup(); | |
146 | if (use_colors) /* Set up colors */ | ||
147 | color_setup(); | ||
148 | |||
149 | dialog_clear(); | 202 | dialog_clear(); |
150 | } | 203 | } |
151 | 204 | ||
152 | /* | 205 | /* |
153 | * Setup for color display | ||
154 | */ | ||
155 | void color_setup(void) | ||
156 | { | ||
157 | int i; | ||
158 | |||
159 | if (has_colors()) { /* Terminal supports color? */ | ||
160 | start_color(); | ||
161 | |||
162 | /* Initialize color pairs */ | ||
163 | for (i = 0; i < ATTRIBUTE_COUNT; i++) | ||
164 | init_pair(i + 1, color_table[i][0], color_table[i][1]); | ||
165 | |||
166 | /* Setup color attributes */ | ||
167 | for (i = 0; i < ATTRIBUTE_COUNT; i++) | ||
168 | attributes[i] = C_ATTR(color_table[i][2], i + 1); | ||
169 | } | ||
170 | } | ||
171 | |||
172 | /* | ||
173 | * End using dialog functions. | 206 | * End using dialog functions. |
174 | */ | 207 | */ |
175 | void end_dialog(void) | 208 | void end_dialog(void) |
@@ -184,7 +217,7 @@ void print_title(WINDOW *dialog, const char *title, int width) | |||
184 | { | 217 | { |
185 | if (title) { | 218 | if (title) { |
186 | int tlen = MIN(width - 2, strlen(title)); | 219 | int tlen = MIN(width - 2, strlen(title)); |
187 | wattrset(dialog, title_attr); | 220 | wattrset(dialog, dlg.title.atr); |
188 | mvwaddch(dialog, 0, (width - tlen) / 2 - 1, ' '); | 221 | mvwaddch(dialog, 0, (width - tlen) / 2 - 1, ' '); |
189 | mvwaddnstr(dialog, 0, (width - tlen)/2, title, tlen); | 222 | mvwaddnstr(dialog, 0, (width - tlen)/2, title, tlen); |
190 | waddch(dialog, ' '); | 223 | waddch(dialog, ' '); |
@@ -264,21 +297,23 @@ void print_button(WINDOW * win, const char *label, int y, int x, int selected) | |||
264 | int i, temp; | 297 | int i, temp; |
265 | 298 | ||
266 | wmove(win, y, x); | 299 | wmove(win, y, x); |
267 | wattrset(win, selected ? button_active_attr : button_inactive_attr); | 300 | wattrset(win, selected ? dlg.button_active.atr |
301 | : dlg.button_inactive.atr); | ||
268 | waddstr(win, "<"); | 302 | waddstr(win, "<"); |
269 | temp = strspn(label, " "); | 303 | temp = strspn(label, " "); |
270 | label += temp; | 304 | label += temp; |
271 | wattrset(win, selected ? button_label_active_attr | 305 | wattrset(win, selected ? dlg.button_label_active.atr |
272 | : button_label_inactive_attr); | 306 | : dlg.button_label_inactive.atr); |
273 | for (i = 0; i < temp; i++) | 307 | for (i = 0; i < temp; i++) |
274 | waddch(win, ' '); | 308 | waddch(win, ' '); |
275 | wattrset(win, selected ? button_key_active_attr | 309 | wattrset(win, selected ? dlg.button_key_active.atr |
276 | : button_key_inactive_attr); | 310 | : dlg.button_key_inactive.atr); |
277 | waddch(win, label[0]); | 311 | waddch(win, label[0]); |
278 | wattrset(win, selected ? button_label_active_attr | 312 | wattrset(win, selected ? dlg.button_label_active.atr |
279 | : button_label_inactive_attr); | 313 | : dlg.button_label_inactive.atr); |
280 | waddstr(win, (char *)label + 1); | 314 | waddstr(win, (char *)label + 1); |
281 | wattrset(win, selected ? button_active_attr : button_inactive_attr); | 315 | wattrset(win, selected ? dlg.button_active.atr |
316 | : dlg.button_inactive.atr); | ||
282 | waddstr(win, ">"); | 317 | waddstr(win, ">"); |
283 | wmove(win, y, x + temp + 1); | 318 | wmove(win, y, x + temp + 1); |
284 | } | 319 | } |
@@ -326,7 +361,7 @@ void draw_shadow(WINDOW * win, int y, int x, int height, int width) | |||
326 | int i; | 361 | int i; |
327 | 362 | ||
328 | if (has_colors()) { /* Whether terminal supports color? */ | 363 | if (has_colors()) { /* Whether terminal supports color? */ |
329 | wattrset(win, shadow_attr); | 364 | wattrset(win, dlg.shadow.atr); |
330 | wmove(win, y + height, x + 2); | 365 | wmove(win, y + height, x + 2); |
331 | for (i = 0; i < width; i++) | 366 | for (i = 0; i < width; i++) |
332 | waddch(win, winch(win) & A_CHARTEXT); | 367 | waddch(win, winch(win) & A_CHARTEXT); |
diff --git a/scripts/kconfig/lxdialog/yesno.c b/scripts/kconfig/lxdialog/yesno.c index cb2568aae3ed..e938037c8020 100644 --- a/scripts/kconfig/lxdialog/yesno.c +++ b/scripts/kconfig/lxdialog/yesno.c | |||
@@ -53,17 +53,18 @@ int dialog_yesno(const char *title, const char *prompt, int height, int width) | |||
53 | dialog = newwin(height, width, y, x); | 53 | dialog = newwin(height, width, y, x); |
54 | keypad(dialog, TRUE); | 54 | keypad(dialog, TRUE); |
55 | 55 | ||
56 | draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr); | 56 | draw_box(dialog, 0, 0, height, width, |
57 | wattrset(dialog, border_attr); | 57 | dlg.dialog.atr, dlg.border.atr); |
58 | wattrset(dialog, dlg.border.atr); | ||
58 | mvwaddch(dialog, height - 3, 0, ACS_LTEE); | 59 | mvwaddch(dialog, height - 3, 0, ACS_LTEE); |
59 | for (i = 0; i < width - 2; i++) | 60 | for (i = 0; i < width - 2; i++) |
60 | waddch(dialog, ACS_HLINE); | 61 | waddch(dialog, ACS_HLINE); |
61 | wattrset(dialog, dialog_attr); | 62 | wattrset(dialog, dlg.dialog.atr); |
62 | waddch(dialog, ACS_RTEE); | 63 | waddch(dialog, ACS_RTEE); |
63 | 64 | ||
64 | print_title(dialog, title, width); | 65 | print_title(dialog, title, width); |
65 | 66 | ||
66 | wattrset(dialog, dialog_attr); | 67 | wattrset(dialog, dlg.dialog.atr); |
67 | print_autowrap(dialog, prompt, width - 2, 1, 3); | 68 | print_autowrap(dialog, prompt, width - 2, 1, 3); |
68 | 69 | ||
69 | print_buttons(dialog, height, width, 0); | 70 | print_buttons(dialog, height, width, 0); |