aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/lxdialog/inputbox.c
diff options
context:
space:
mode:
authorSam Ravnborg <sam@mars.ravnborg.org>2005-11-19 15:56:20 -0500
committerSam Ravnborg <sam@mars.ravnborg.org>2005-11-19 15:56:20 -0500
commitdec69da856653772d7ee7b2f98dc69da27274a22 (patch)
tree020cf19de028a402a6bfc792caaffeddaf5a3e9b /scripts/lxdialog/inputbox.c
parentb1c5f1c635f4a821f834ed51ccd8a2a1515fffd2 (diff)
kconfig: fixup after Lindent
Readability are more important then the 80 coloumn limit, so fold several lines to greatly improve readability. Also keep return type on same line as function definition. Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Diffstat (limited to 'scripts/lxdialog/inputbox.c')
-rw-r--r--scripts/lxdialog/inputbox.c49
1 files changed, 15 insertions, 34 deletions
diff --git a/scripts/lxdialog/inputbox.c b/scripts/lxdialog/inputbox.c
index 9e9691567269..bc135c7093d9 100644
--- a/scripts/lxdialog/inputbox.c
+++ b/scripts/lxdialog/inputbox.c
@@ -41,9 +41,8 @@ static void print_buttons(WINDOW * dialog, int height, int width, int selected)
41/* 41/*
42 * Display a dialog box for inputing a string 42 * Display a dialog box for inputing a string
43 */ 43 */
44int 44int dialog_inputbox(const char *title, const char *prompt, int height, int width,
45dialog_inputbox(const char *title, const char *prompt, int height, int width, 45 const char *init)
46 const char *init)
47{ 46{
48 int i, x, y, box_y, box_x, box_width; 47 int i, x, y, box_y, box_x, box_width;
49 int input_x = 0, scroll = 0, key = 0, button = -1; 48 int input_x = 0, scroll = 0, key = 0, button = -1;
@@ -90,8 +89,7 @@ dialog_inputbox(const char *title, const char *prompt, int height, int width,
90 getyx(dialog, y, x); 89 getyx(dialog, y, x);
91 box_y = y + 2; 90 box_y = y + 2;
92 box_x = (width - box_width) / 2; 91 box_x = (width - box_width) / 2;
93 draw_box(dialog, y + 1, box_x - 1, 3, box_width + 2, 92 draw_box(dialog, y + 1, box_x - 1, 3, box_width + 2, border_attr, dialog_attr);
94 border_attr, dialog_attr);
95 93
96 print_buttons(dialog, height, width, 0); 94 print_buttons(dialog, height, width, 0);
97 95
@@ -111,8 +109,9 @@ dialog_inputbox(const char *title, const char *prompt, int height, int width,
111 input_x = box_width - 1; 109 input_x = box_width - 1;
112 for (i = 0; i < box_width - 1; i++) 110 for (i = 0; i < box_width - 1; i++)
113 waddch(dialog, instr[scroll + i]); 111 waddch(dialog, instr[scroll + i]);
114 } else 112 } else {
115 waddstr(dialog, instr); 113 waddstr(dialog, instr);
114 }
116 115
117 wmove(dialog, box_y, box_x + input_x); 116 wmove(dialog, box_y, box_x + input_x);
118 117
@@ -136,26 +135,17 @@ dialog_inputbox(const char *title, const char *prompt, int height, int width,
136 if (input_x || scroll) { 135 if (input_x || scroll) {
137 wattrset(dialog, inputbox_attr); 136 wattrset(dialog, inputbox_attr);
138 if (!input_x) { 137 if (!input_x) {
139 scroll = 138 scroll = scroll < box_width - 1 ? 0 : scroll - (box_width - 1);
140 scroll <
141 box_width - 1 ? 0 : scroll -
142 (box_width - 1);
143 wmove(dialog, box_y, box_x); 139 wmove(dialog, box_y, box_x);
144 for (i = 0; i < box_width; i++) 140 for (i = 0; i < box_width; i++)
145 waddch(dialog, 141 waddch(dialog,
146 instr[scroll + 142 instr[scroll + input_x + i] ?
147 input_x + 143 instr[scroll + input_x + i] : ' ');
148 i] ? 144 input_x = strlen(instr) - scroll;
149 instr[scroll +
150 input_x +
151 i] : ' ');
152 input_x =
153 strlen(instr) - scroll;
154 } else 145 } else
155 input_x--; 146 input_x--;
156 instr[scroll + input_x] = '\0'; 147 instr[scroll + input_x] = '\0';
157 mvwaddch(dialog, box_y, input_x + box_x, 148 mvwaddch(dialog, box_y, input_x + box_x, ' ');
158 ' ');
159 wmove(dialog, box_y, input_x + box_x); 149 wmove(dialog, box_y, input_x + box_x);
160 wrefresh(dialog); 150 wrefresh(dialog);
161 } 151 }
@@ -165,23 +155,14 @@ dialog_inputbox(const char *title, const char *prompt, int height, int width,
165 if (scroll + input_x < MAX_LEN) { 155 if (scroll + input_x < MAX_LEN) {
166 wattrset(dialog, inputbox_attr); 156 wattrset(dialog, inputbox_attr);
167 instr[scroll + input_x] = key; 157 instr[scroll + input_x] = key;
168 instr[scroll + input_x + 1] = 158 instr[scroll + input_x + 1] = '\0';
169 '\0';
170 if (input_x == box_width - 1) { 159 if (input_x == box_width - 1) {
171 scroll++; 160 scroll++;
172 wmove(dialog, box_y, 161 wmove(dialog, box_y, box_x);
173 box_x); 162 for (i = 0; i < box_width - 1; i++)
174 for (i = 0; 163 waddch(dialog, instr [scroll + i]);
175 i < box_width - 1;
176 i++)
177 waddch(dialog,
178 instr
179 [scroll +
180 i]);
181 } else { 164 } else {
182 wmove(dialog, box_y, 165 wmove(dialog, box_y, input_x++ + box_x);
183 input_x++ +
184 box_x);
185 waddch(dialog, key); 166 waddch(dialog, key);
186 } 167 }
187 wrefresh(dialog); 168 wrefresh(dialog);