|
@@ -16,6 +16,7 @@
|
16
|
16
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
17
|
17
|
*/
|
18
|
18
|
|
|
19
|
+#include <stdarg.h>
|
19
|
20
|
#include <unistd.h>
|
20
|
21
|
#include <string.h>
|
21
|
22
|
#include <curses.h>
|
|
@@ -39,8 +40,10 @@ extern struct nvo_block *ugly_nvo_hack;
|
39
|
40
|
#define CPAIR_ALERT 4
|
40
|
41
|
|
41
|
42
|
/* Screen layout */
|
|
43
|
+#define BANNER_ROW 1
|
42
|
44
|
#define SETTINGS_LIST_ROW 3
|
43
|
45
|
#define SETTINGS_LIST_COL 1
|
|
46
|
+#define INFO_ROW 20
|
44
|
47
|
#define ALERT_ROW 20
|
45
|
48
|
|
46
|
49
|
/** Layout of text within a setting widget */
|
|
@@ -203,21 +206,72 @@ static void init_setting_index ( struct setting_widget *widget,
|
203
|
206
|
( SETTINGS_LIST_ROW + index ), SETTINGS_LIST_COL );
|
204
|
207
|
}
|
205
|
208
|
|
206
|
|
-static void alert ( const char *fmt, ... ) {
|
|
209
|
+/**
|
|
210
|
+ * Print message centred on specified row
|
|
211
|
+ *
|
|
212
|
+ * @v row Row
|
|
213
|
+ * @v fmt printf() format string
|
|
214
|
+ * @v args printf() argument list
|
|
215
|
+ */
|
|
216
|
+static void vmsg ( unsigned int row, const char *fmt, va_list args ) {
|
207
|
217
|
char buf[COLS];
|
208
|
|
- va_list args;
|
209
|
218
|
size_t len;
|
210
|
219
|
|
211
|
|
- va_start ( args, fmt );
|
212
|
220
|
len = vsnprintf ( buf, sizeof ( buf ), fmt, args );
|
|
221
|
+ mvprintw ( row, ( ( COLS - len ) / 2 ), "%s", buf );
|
|
222
|
+}
|
|
223
|
+
|
|
224
|
+/**
|
|
225
|
+ * Print message centred on specified row
|
|
226
|
+ *
|
|
227
|
+ * @v row Row
|
|
228
|
+ * @v fmt printf() format string
|
|
229
|
+ * @v .. printf() arguments
|
|
230
|
+ */
|
|
231
|
+static void msg ( unsigned int row, const char *fmt, ... ) {
|
|
232
|
+ va_list args;
|
|
233
|
+
|
|
234
|
+ va_start ( args, fmt );
|
|
235
|
+ vmsg ( row, fmt, args );
|
213
|
236
|
va_end ( args );
|
|
237
|
+}
|
|
238
|
+
|
|
239
|
+/**
|
|
240
|
+ * Clear message on specified row
|
|
241
|
+ *
|
|
242
|
+ * @v row Row
|
|
243
|
+ */
|
|
244
|
+static void clearmsg ( unsigned int row ) {
|
|
245
|
+ move ( row, 0 );
|
|
246
|
+ clrtoeol();
|
|
247
|
+}
|
214
|
248
|
|
|
249
|
+/**
|
|
250
|
+ * Print alert message
|
|
251
|
+ *
|
|
252
|
+ * @v fmt printf() format string
|
|
253
|
+ * @v args printf() argument list
|
|
254
|
+ */
|
|
255
|
+static void valert ( const char *fmt, va_list args ) {
|
215
|
256
|
color_set ( CPAIR_ALERT, NULL );
|
216
|
|
- mvprintw ( ALERT_ROW, ( ( COLS - len ) / 2 ), "%s", buf );
|
|
257
|
+ vmsg ( ALERT_ROW, fmt, args );
|
217
|
258
|
sleep ( 2 );
|
218
|
259
|
color_set ( CPAIR_NORMAL, NULL );
|
219
|
|
- move ( ALERT_ROW, 0 );
|
220
|
|
- clrtoeol();
|
|
260
|
+ clearmsg ( ALERT_ROW );
|
|
261
|
+}
|
|
262
|
+
|
|
263
|
+/**
|
|
264
|
+ * Print alert message
|
|
265
|
+ *
|
|
266
|
+ * @v fmt printf() format string
|
|
267
|
+ * @v ... printf() arguments
|
|
268
|
+ */
|
|
269
|
+static void alert ( const char *fmt, ... ) {
|
|
270
|
+ va_list args;
|
|
271
|
+
|
|
272
|
+ va_start ( args, fmt );
|
|
273
|
+ valert ( fmt, args );
|
|
274
|
+ va_end ( args );
|
221
|
275
|
}
|
222
|
276
|
|
223
|
277
|
static void main_loop ( struct config_context *context ) {
|
|
@@ -230,12 +284,21 @@ static void main_loop ( struct config_context *context ) {
|
230
|
284
|
|
231
|
285
|
/* Print initial screen content */
|
232
|
286
|
color_set ( CPAIR_NORMAL, NULL );
|
|
287
|
+ attron ( A_BOLD );
|
|
288
|
+ msg ( BANNER_ROW, "gPXE option configuration console" );
|
|
289
|
+ attroff ( A_BOLD );
|
233
|
290
|
for ( i = ( NUM_SETTINGS - 1 ) ; i >= 0 ; i-- ) {
|
234
|
291
|
init_setting_index ( &widget, context, i );
|
235
|
292
|
draw_setting ( &widget );
|
236
|
293
|
}
|
237
|
294
|
|
238
|
295
|
while ( 1 ) {
|
|
296
|
+ /* Redraw information row */
|
|
297
|
+ clearmsg ( INFO_ROW );
|
|
298
|
+ msg ( INFO_ROW, "%s (%s) - %s", widget.setting->name,
|
|
299
|
+ widget.setting->type->description,
|
|
300
|
+ widget.setting->description );
|
|
301
|
+
|
239
|
302
|
/* Redraw current setting */
|
240
|
303
|
color_set ( ( widget.editing ? CPAIR_EDIT : CPAIR_SELECT ),
|
241
|
304
|
NULL );
|
|
@@ -293,7 +356,7 @@ void uitest ( void ) {
|
293
|
356
|
initscr();
|
294
|
357
|
start_color();
|
295
|
358
|
init_pair ( CPAIR_NORMAL, COLOR_WHITE, COLOR_BLUE );
|
296
|
|
- init_pair ( CPAIR_SELECT, COLOR_BLACK, COLOR_WHITE );
|
|
359
|
+ init_pair ( CPAIR_SELECT, COLOR_WHITE, COLOR_RED );
|
297
|
360
|
init_pair ( CPAIR_EDIT, COLOR_BLACK, COLOR_CYAN );
|
298
|
361
|
init_pair ( CPAIR_ALERT, COLOR_WHITE, COLOR_RED );
|
299
|
362
|
color_set ( CPAIR_NORMAL, NULL );
|