Mercurial > hg > toybox
annotate kconfig/lxdialog/util.c @ 484:4099d3026e56
Set HOSTCC only if it isn't already set as an environment variable.
author | Rob Landley <rob@landley.net> |
---|---|
date | Sun, 19 Feb 2012 22:21:45 -0600 |
parents | 4d21d59f3206 |
children |
rev | line source |
---|---|
10
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
1 /* |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
2 * util.c |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
3 * |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
4 * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
5 * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
6 * |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
7 * This program is free software; you can redistribute it and/or |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
8 * modify it under the terms of the GNU General Public License |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
9 * as published by the Free Software Foundation; either version 2 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
10 * of the License, or (at your option) any later version. |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
11 * |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
15 * GNU General Public License for more details. |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
16 * |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
17 * You should have received a copy of the GNU General Public License |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
18 * along with this program; if not, write to the Free Software |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
20 */ |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
21 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
22 #include "dialog.h" |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
23 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
24 struct dialog_info dlg; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
25 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
26 static void set_mono_theme(void) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
27 { |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
28 dlg.screen.atr = A_NORMAL; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
29 dlg.shadow.atr = A_NORMAL; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
30 dlg.dialog.atr = A_NORMAL; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
31 dlg.title.atr = A_BOLD; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
32 dlg.border.atr = A_NORMAL; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
33 dlg.button_active.atr = A_REVERSE; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
34 dlg.button_inactive.atr = A_DIM; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
35 dlg.button_key_active.atr = A_REVERSE; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
36 dlg.button_key_inactive.atr = A_BOLD; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
37 dlg.button_label_active.atr = A_REVERSE; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
38 dlg.button_label_inactive.atr = A_NORMAL; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
39 dlg.inputbox.atr = A_NORMAL; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
40 dlg.inputbox_border.atr = A_NORMAL; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
41 dlg.searchbox.atr = A_NORMAL; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
42 dlg.searchbox_title.atr = A_BOLD; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
43 dlg.searchbox_border.atr = A_NORMAL; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
44 dlg.position_indicator.atr = A_BOLD; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
45 dlg.menubox.atr = A_NORMAL; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
46 dlg.menubox_border.atr = A_NORMAL; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
47 dlg.item.atr = A_NORMAL; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
48 dlg.item_selected.atr = A_REVERSE; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
49 dlg.tag.atr = A_BOLD; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
50 dlg.tag_selected.atr = A_REVERSE; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
51 dlg.tag_key.atr = A_BOLD; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
52 dlg.tag_key_selected.atr = A_REVERSE; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
53 dlg.check.atr = A_BOLD; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
54 dlg.check_selected.atr = A_REVERSE; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
55 dlg.uarrow.atr = A_BOLD; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
56 dlg.darrow.atr = A_BOLD; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
57 } |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
58 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
59 #define DLG_COLOR(dialog, f, b, h) \ |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
60 do { \ |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
61 dlg.dialog.fg = (f); \ |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
62 dlg.dialog.bg = (b); \ |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
63 dlg.dialog.hl = (h); \ |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
64 } while (0) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
65 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
66 static void set_classic_theme(void) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
67 { |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
68 DLG_COLOR(screen, COLOR_CYAN, COLOR_BLUE, true); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
69 DLG_COLOR(shadow, COLOR_BLACK, COLOR_BLACK, true); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
70 DLG_COLOR(dialog, COLOR_BLACK, COLOR_WHITE, false); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
71 DLG_COLOR(title, COLOR_YELLOW, COLOR_WHITE, true); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
72 DLG_COLOR(border, COLOR_WHITE, COLOR_WHITE, true); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
73 DLG_COLOR(button_active, COLOR_WHITE, COLOR_BLUE, true); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
74 DLG_COLOR(button_inactive, COLOR_BLACK, COLOR_WHITE, false); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
75 DLG_COLOR(button_key_active, COLOR_WHITE, COLOR_BLUE, true); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
76 DLG_COLOR(button_key_inactive, COLOR_RED, COLOR_WHITE, false); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
77 DLG_COLOR(button_label_active, COLOR_YELLOW, COLOR_BLUE, true); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
78 DLG_COLOR(button_label_inactive, COLOR_BLACK, COLOR_WHITE, true); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
79 DLG_COLOR(inputbox, COLOR_BLACK, COLOR_WHITE, false); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
80 DLG_COLOR(inputbox_border, COLOR_BLACK, COLOR_WHITE, false); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
81 DLG_COLOR(searchbox, COLOR_BLACK, COLOR_WHITE, false); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
82 DLG_COLOR(searchbox_title, COLOR_YELLOW, COLOR_WHITE, true); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
83 DLG_COLOR(searchbox_border, COLOR_WHITE, COLOR_WHITE, true); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
84 DLG_COLOR(position_indicator, COLOR_YELLOW, COLOR_WHITE, true); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
85 DLG_COLOR(menubox, COLOR_BLACK, COLOR_WHITE, false); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
86 DLG_COLOR(menubox_border, COLOR_WHITE, COLOR_WHITE, true); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
87 DLG_COLOR(item, COLOR_BLACK, COLOR_WHITE, false); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
88 DLG_COLOR(item_selected, COLOR_WHITE, COLOR_BLUE, true); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
89 DLG_COLOR(tag, COLOR_YELLOW, COLOR_WHITE, true); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
90 DLG_COLOR(tag_selected, COLOR_YELLOW, COLOR_BLUE, true); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
91 DLG_COLOR(tag_key, COLOR_YELLOW, COLOR_WHITE, true); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
92 DLG_COLOR(tag_key_selected, COLOR_YELLOW, COLOR_BLUE, true); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
93 DLG_COLOR(check, COLOR_BLACK, COLOR_WHITE, false); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
94 DLG_COLOR(check_selected, COLOR_WHITE, COLOR_BLUE, true); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
95 DLG_COLOR(uarrow, COLOR_GREEN, COLOR_WHITE, true); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
96 DLG_COLOR(darrow, COLOR_GREEN, COLOR_WHITE, true); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
97 } |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
98 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
99 static void set_blackbg_theme(void) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
100 { |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
101 DLG_COLOR(screen, COLOR_RED, COLOR_BLACK, true); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
102 DLG_COLOR(shadow, COLOR_BLACK, COLOR_BLACK, false); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
103 DLG_COLOR(dialog, COLOR_WHITE, COLOR_BLACK, false); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
104 DLG_COLOR(title, COLOR_RED, COLOR_BLACK, false); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
105 DLG_COLOR(border, COLOR_BLACK, COLOR_BLACK, true); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
106 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
107 DLG_COLOR(button_active, COLOR_YELLOW, COLOR_RED, false); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
108 DLG_COLOR(button_inactive, COLOR_YELLOW, COLOR_BLACK, false); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
109 DLG_COLOR(button_key_active, COLOR_YELLOW, COLOR_RED, true); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
110 DLG_COLOR(button_key_inactive, COLOR_RED, COLOR_BLACK, false); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
111 DLG_COLOR(button_label_active, COLOR_WHITE, COLOR_RED, false); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
112 DLG_COLOR(button_label_inactive, COLOR_BLACK, COLOR_BLACK, true); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
113 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
114 DLG_COLOR(inputbox, COLOR_YELLOW, COLOR_BLACK, false); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
115 DLG_COLOR(inputbox_border, COLOR_YELLOW, COLOR_BLACK, false); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
116 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
117 DLG_COLOR(searchbox, COLOR_YELLOW, COLOR_BLACK, false); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
118 DLG_COLOR(searchbox_title, COLOR_YELLOW, COLOR_BLACK, true); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
119 DLG_COLOR(searchbox_border, COLOR_BLACK, COLOR_BLACK, true); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
120 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
121 DLG_COLOR(position_indicator, COLOR_RED, COLOR_BLACK, false); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
122 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
123 DLG_COLOR(menubox, COLOR_YELLOW, COLOR_BLACK, false); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
124 DLG_COLOR(menubox_border, COLOR_BLACK, COLOR_BLACK, true); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
125 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
126 DLG_COLOR(item, COLOR_WHITE, COLOR_BLACK, false); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
127 DLG_COLOR(item_selected, COLOR_WHITE, COLOR_RED, false); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
128 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
129 DLG_COLOR(tag, COLOR_RED, COLOR_BLACK, false); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
130 DLG_COLOR(tag_selected, COLOR_YELLOW, COLOR_RED, true); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
131 DLG_COLOR(tag_key, COLOR_RED, COLOR_BLACK, false); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
132 DLG_COLOR(tag_key_selected, COLOR_YELLOW, COLOR_RED, true); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
133 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
134 DLG_COLOR(check, COLOR_YELLOW, COLOR_BLACK, false); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
135 DLG_COLOR(check_selected, COLOR_YELLOW, COLOR_RED, true); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
136 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
137 DLG_COLOR(uarrow, COLOR_RED, COLOR_BLACK, false); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
138 DLG_COLOR(darrow, COLOR_RED, COLOR_BLACK, false); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
139 } |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
140 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
141 static void set_bluetitle_theme(void) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
142 { |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
143 set_classic_theme(); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
144 DLG_COLOR(title, COLOR_BLUE, COLOR_WHITE, true); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
145 DLG_COLOR(button_key_active, COLOR_YELLOW, COLOR_BLUE, true); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
146 DLG_COLOR(button_label_active, COLOR_WHITE, COLOR_BLUE, true); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
147 DLG_COLOR(searchbox_title, COLOR_BLUE, COLOR_WHITE, true); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
148 DLG_COLOR(position_indicator, COLOR_BLUE, COLOR_WHITE, true); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
149 DLG_COLOR(tag, COLOR_BLUE, COLOR_WHITE, true); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
150 DLG_COLOR(tag_key, COLOR_BLUE, COLOR_WHITE, true); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
151 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
152 } |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
153 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
154 /* |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
155 * Select color theme |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
156 */ |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
157 static int set_theme(const char *theme) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
158 { |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
159 int use_color = 1; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
160 if (!theme) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
161 set_bluetitle_theme(); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
162 else if (strcmp(theme, "classic") == 0) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
163 set_classic_theme(); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
164 else if (strcmp(theme, "bluetitle") == 0) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
165 set_bluetitle_theme(); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
166 else if (strcmp(theme, "blackbg") == 0) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
167 set_blackbg_theme(); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
168 else if (strcmp(theme, "mono") == 0) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
169 use_color = 0; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
170 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
171 return use_color; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
172 } |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
173 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
174 static void init_one_color(struct dialog_color *color) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
175 { |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
176 static int pair = 0; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
177 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
178 pair++; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
179 init_pair(pair, color->fg, color->bg); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
180 if (color->hl) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
181 color->atr = A_BOLD | COLOR_PAIR(pair); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
182 else |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
183 color->atr = COLOR_PAIR(pair); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
184 } |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
185 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
186 static void init_dialog_colors(void) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
187 { |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
188 init_one_color(&dlg.screen); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
189 init_one_color(&dlg.shadow); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
190 init_one_color(&dlg.dialog); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
191 init_one_color(&dlg.title); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
192 init_one_color(&dlg.border); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
193 init_one_color(&dlg.button_active); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
194 init_one_color(&dlg.button_inactive); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
195 init_one_color(&dlg.button_key_active); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
196 init_one_color(&dlg.button_key_inactive); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
197 init_one_color(&dlg.button_label_active); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
198 init_one_color(&dlg.button_label_inactive); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
199 init_one_color(&dlg.inputbox); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
200 init_one_color(&dlg.inputbox_border); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
201 init_one_color(&dlg.searchbox); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
202 init_one_color(&dlg.searchbox_title); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
203 init_one_color(&dlg.searchbox_border); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
204 init_one_color(&dlg.position_indicator); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
205 init_one_color(&dlg.menubox); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
206 init_one_color(&dlg.menubox_border); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
207 init_one_color(&dlg.item); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
208 init_one_color(&dlg.item_selected); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
209 init_one_color(&dlg.tag); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
210 init_one_color(&dlg.tag_selected); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
211 init_one_color(&dlg.tag_key); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
212 init_one_color(&dlg.tag_key_selected); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
213 init_one_color(&dlg.check); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
214 init_one_color(&dlg.check_selected); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
215 init_one_color(&dlg.uarrow); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
216 init_one_color(&dlg.darrow); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
217 } |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
218 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
219 /* |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
220 * Setup for color display |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
221 */ |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
222 static void color_setup(const char *theme) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
223 { |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
224 if (set_theme(theme)) { |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
225 if (has_colors()) { /* Terminal supports color? */ |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
226 start_color(); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
227 init_dialog_colors(); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
228 } |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
229 } |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
230 else |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
231 { |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
232 set_mono_theme(); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
233 } |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
234 } |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
235 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
236 /* |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
237 * Set window to attribute 'attr' |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
238 */ |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
239 void attr_clear(WINDOW * win, int height, int width, chtype attr) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
240 { |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
241 int i, j; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
242 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
243 wattrset(win, attr); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
244 for (i = 0; i < height; i++) { |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
245 wmove(win, i, 0); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
246 for (j = 0; j < width; j++) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
247 waddch(win, ' '); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
248 } |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
249 touchwin(win); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
250 } |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
251 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
252 void dialog_clear(void) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
253 { |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
254 attr_clear(stdscr, LINES, COLS, dlg.screen.atr); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
255 /* Display background title if it exists ... - SLH */ |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
256 if (dlg.backtitle != NULL) { |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
257 int i; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
258 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
259 wattrset(stdscr, dlg.screen.atr); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
260 mvwaddstr(stdscr, 0, 1, (char *)dlg.backtitle); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
261 wmove(stdscr, 1, 1); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
262 for (i = 1; i < COLS - 1; i++) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
263 waddch(stdscr, ACS_HLINE); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
264 } |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
265 wnoutrefresh(stdscr); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
266 } |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
267 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
268 /* |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
269 * Do some initialization for dialog |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
270 */ |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
271 void init_dialog(const char *backtitle) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
272 { |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
273 dlg.backtitle = backtitle; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
274 color_setup(getenv("MENUCONFIG_COLOR")); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
275 } |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
276 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
277 void reset_dialog(void) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
278 { |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
279 initscr(); /* Init curses */ |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
280 keypad(stdscr, TRUE); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
281 cbreak(); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
282 noecho(); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
283 dialog_clear(); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
284 } |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
285 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
286 /* |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
287 * End using dialog functions. |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
288 */ |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
289 void end_dialog(void) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
290 { |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
291 endwin(); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
292 } |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
293 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
294 /* Print the title of the dialog. Center the title and truncate |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
295 * tile if wider than dialog (- 2 chars). |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
296 **/ |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
297 void print_title(WINDOW *dialog, const char *title, int width) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
298 { |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
299 if (title) { |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
300 int tlen = MIN(width - 2, strlen(title)); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
301 wattrset(dialog, dlg.title.atr); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
302 mvwaddch(dialog, 0, (width - tlen) / 2 - 1, ' '); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
303 mvwaddnstr(dialog, 0, (width - tlen)/2, title, tlen); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
304 waddch(dialog, ' '); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
305 } |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
306 } |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
307 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
308 /* |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
309 * Print a string of text in a window, automatically wrap around to the |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
310 * next line if the string is too long to fit on one line. Newline |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
311 * characters '\n' are replaced by spaces. We start on a new line |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
312 * if there is no room for at least 4 nonblanks following a double-space. |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
313 */ |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
314 void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
315 { |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
316 int newl, cur_x, cur_y; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
317 int i, prompt_len, room, wlen; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
318 char tempstr[MAX_LEN + 1], *word, *sp, *sp2; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
319 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
320 strcpy(tempstr, prompt); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
321 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
322 prompt_len = strlen(tempstr); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
323 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
324 /* |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
325 * Remove newlines |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
326 */ |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
327 for (i = 0; i < prompt_len; i++) { |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
328 if (tempstr[i] == '\n') |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
329 tempstr[i] = ' '; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
330 } |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
331 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
332 if (prompt_len <= width - x * 2) { /* If prompt is short */ |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
333 wmove(win, y, (width - prompt_len) / 2); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
334 waddstr(win, tempstr); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
335 } else { |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
336 cur_x = x; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
337 cur_y = y; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
338 newl = 1; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
339 word = tempstr; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
340 while (word && *word) { |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
341 sp = index(word, ' '); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
342 if (sp) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
343 *sp++ = 0; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
344 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
345 /* Wrap to next line if either the word does not fit, |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
346 or it is the first word of a new sentence, and it is |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
347 short, and the next word does not fit. */ |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
348 room = width - cur_x; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
349 wlen = strlen(word); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
350 if (wlen > room || |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
351 (newl && wlen < 4 && sp |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
352 && wlen + 1 + strlen(sp) > room |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
353 && (!(sp2 = index(sp, ' ')) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
354 || wlen + 1 + (sp2 - sp) > room))) { |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
355 cur_y++; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
356 cur_x = x; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
357 } |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
358 wmove(win, cur_y, cur_x); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
359 waddstr(win, word); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
360 getyx(win, cur_y, cur_x); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
361 cur_x++; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
362 if (sp && *sp == ' ') { |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
363 cur_x++; /* double space */ |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
364 while (*++sp == ' ') ; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
365 newl = 1; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
366 } else |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
367 newl = 0; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
368 word = sp; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
369 } |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
370 } |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
371 } |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
372 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
373 /* |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
374 * Print a button |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
375 */ |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
376 void print_button(WINDOW * win, const char *label, int y, int x, int selected) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
377 { |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
378 int i, temp; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
379 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
380 wmove(win, y, x); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
381 wattrset(win, selected ? dlg.button_active.atr |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
382 : dlg.button_inactive.atr); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
383 waddstr(win, "<"); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
384 temp = strspn(label, " "); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
385 label += temp; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
386 wattrset(win, selected ? dlg.button_label_active.atr |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
387 : dlg.button_label_inactive.atr); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
388 for (i = 0; i < temp; i++) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
389 waddch(win, ' '); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
390 wattrset(win, selected ? dlg.button_key_active.atr |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
391 : dlg.button_key_inactive.atr); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
392 waddch(win, label[0]); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
393 wattrset(win, selected ? dlg.button_label_active.atr |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
394 : dlg.button_label_inactive.atr); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
395 waddstr(win, (char *)label + 1); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
396 wattrset(win, selected ? dlg.button_active.atr |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
397 : dlg.button_inactive.atr); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
398 waddstr(win, ">"); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
399 wmove(win, y, x + temp + 1); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
400 } |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
401 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
402 /* |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
403 * Draw a rectangular box with line drawing characters |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
404 */ |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
405 void |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
406 draw_box(WINDOW * win, int y, int x, int height, int width, |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
407 chtype box, chtype border) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
408 { |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
409 int i, j; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
410 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
411 wattrset(win, 0); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
412 for (i = 0; i < height; i++) { |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
413 wmove(win, y + i, x); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
414 for (j = 0; j < width; j++) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
415 if (!i && !j) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
416 waddch(win, border | ACS_ULCORNER); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
417 else if (i == height - 1 && !j) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
418 waddch(win, border | ACS_LLCORNER); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
419 else if (!i && j == width - 1) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
420 waddch(win, box | ACS_URCORNER); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
421 else if (i == height - 1 && j == width - 1) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
422 waddch(win, box | ACS_LRCORNER); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
423 else if (!i) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
424 waddch(win, border | ACS_HLINE); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
425 else if (i == height - 1) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
426 waddch(win, box | ACS_HLINE); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
427 else if (!j) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
428 waddch(win, border | ACS_VLINE); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
429 else if (j == width - 1) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
430 waddch(win, box | ACS_VLINE); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
431 else |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
432 waddch(win, box | ' '); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
433 } |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
434 } |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
435 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
436 /* |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
437 * Draw shadows along the right and bottom edge to give a more 3D look |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
438 * to the boxes |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
439 */ |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
440 void draw_shadow(WINDOW * win, int y, int x, int height, int width) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
441 { |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
442 int i; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
443 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
444 if (has_colors()) { /* Whether terminal supports color? */ |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
445 wattrset(win, dlg.shadow.atr); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
446 wmove(win, y + height, x + 2); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
447 for (i = 0; i < width; i++) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
448 waddch(win, winch(win) & A_CHARTEXT); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
449 for (i = y + 1; i < y + height + 1; i++) { |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
450 wmove(win, i, x + width); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
451 waddch(win, winch(win) & A_CHARTEXT); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
452 waddch(win, winch(win) & A_CHARTEXT); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
453 } |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
454 wnoutrefresh(win); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
455 } |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
456 } |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
457 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
458 /* |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
459 * Return the position of the first alphabetic character in a string. |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
460 */ |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
461 int first_alpha(const char *string, const char *exempt) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
462 { |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
463 int i, in_paren = 0, c; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
464 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
465 for (i = 0; i < strlen(string); i++) { |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
466 c = tolower(string[i]); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
467 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
468 if (strchr("<[(", c)) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
469 ++in_paren; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
470 if (strchr(">])", c) && in_paren > 0) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
471 --in_paren; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
472 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
473 if ((!in_paren) && isalpha(c) && strchr(exempt, c) == 0) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
474 return i; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
475 } |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
476 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
477 return 0; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
478 } |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
479 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
480 /* |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
481 * ncurses uses ESC to detect escaped char sequences. This resutl in |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
482 * a small timeout before ESC is actually delivered to the application. |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
483 * lxdialog suggest <ESC> <ESC> which is correctly translated to two |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
484 * times esc. But then we need to ignore the second esc to avoid stepping |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
485 * out one menu too much. Filter away all escaped key sequences since |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
486 * keypad(FALSE) turn off ncurses support for escape sequences - and thats |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
487 * needed to make notimeout() do as expected. |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
488 */ |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
489 int on_key_esc(WINDOW *win) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
490 { |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
491 int key; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
492 int key2; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
493 int key3; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
494 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
495 nodelay(win, TRUE); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
496 keypad(win, FALSE); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
497 key = wgetch(win); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
498 key2 = wgetch(win); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
499 do { |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
500 key3 = wgetch(win); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
501 } while (key3 != ERR); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
502 nodelay(win, FALSE); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
503 keypad(win, TRUE); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
504 if (key == KEY_ESC && key2 == ERR) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
505 return KEY_ESC; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
506 else if (key != ERR && key != KEY_ESC && key2 == ERR) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
507 ungetch(key); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
508 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
509 return -1; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
510 } |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
511 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
512 /* redraw screen in new size */ |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
513 int on_key_resize(void) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
514 { |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
515 dialog_clear(); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
516 return KEY_RESIZE; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
517 } |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
518 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
519 struct dialog_list *item_cur; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
520 struct dialog_list item_nil; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
521 struct dialog_list *item_head; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
522 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
523 void item_reset(void) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
524 { |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
525 struct dialog_list *p, *next; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
526 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
527 for (p = item_head; p; p = next) { |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
528 next = p->next; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
529 free(p); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
530 } |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
531 item_head = NULL; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
532 item_cur = &item_nil; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
533 } |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
534 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
535 void item_make(const char *fmt, ...) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
536 { |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
537 va_list ap; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
538 struct dialog_list *p = malloc(sizeof(*p)); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
539 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
540 if (item_head) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
541 item_cur->next = p; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
542 else |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
543 item_head = p; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
544 item_cur = p; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
545 memset(p, 0, sizeof(*p)); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
546 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
547 va_start(ap, fmt); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
548 vsnprintf(item_cur->node.str, sizeof(item_cur->node.str), fmt, ap); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
549 va_end(ap); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
550 } |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
551 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
552 void item_add_str(const char *fmt, ...) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
553 { |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
554 va_list ap; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
555 size_t avail; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
556 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
557 avail = sizeof(item_cur->node.str) - strlen(item_cur->node.str); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
558 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
559 va_start(ap, fmt); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
560 vsnprintf(item_cur->node.str + strlen(item_cur->node.str), |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
561 avail, fmt, ap); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
562 item_cur->node.str[sizeof(item_cur->node.str) - 1] = '\0'; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
563 va_end(ap); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
564 } |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
565 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
566 void item_set_tag(char tag) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
567 { |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
568 item_cur->node.tag = tag; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
569 } |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
570 void item_set_data(void *ptr) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
571 { |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
572 item_cur->node.data = ptr; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
573 } |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
574 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
575 void item_set_selected(int val) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
576 { |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
577 item_cur->node.selected = val; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
578 } |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
579 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
580 int item_activate_selected(void) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
581 { |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
582 item_foreach() |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
583 if (item_is_selected()) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
584 return 1; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
585 return 0; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
586 } |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
587 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
588 void *item_data(void) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
589 { |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
590 return item_cur->node.data; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
591 } |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
592 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
593 char item_tag(void) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
594 { |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
595 return item_cur->node.tag; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
596 } |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
597 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
598 int item_count(void) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
599 { |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
600 int n = 0; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
601 struct dialog_list *p; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
602 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
603 for (p = item_head; p; p = p->next) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
604 n++; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
605 return n; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
606 } |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
607 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
608 void item_set(int n) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
609 { |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
610 int i = 0; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
611 item_foreach() |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
612 if (i++ == n) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
613 return; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
614 } |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
615 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
616 int item_n(void) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
617 { |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
618 int n = 0; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
619 struct dialog_list *p; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
620 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
621 for (p = item_head; p; p = p->next) { |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
622 if (p == item_cur) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
623 return n; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
624 n++; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
625 } |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
626 return 0; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
627 } |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
628 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
629 const char *item_str(void) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
630 { |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
631 return item_cur->node.str; |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
632 } |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
633 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
634 int item_is_selected(void) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
635 { |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
636 return (item_cur->node.selected != 0); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
637 } |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
638 |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
639 int item_is_tag(char tag) |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
640 { |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
641 return (item_cur->node.tag == tag); |
4d21d59f3206
Add menuconfig, plus some basic Config info, lots of which is just future
landley@driftwood
parents:
diff
changeset
|
642 } |