Use getkey() and symbolic key names.

pull/1/head
Michael Brown 2006-12-20 22:25:54 +00:00
parent cacd6b1d04
commit f33a03c1e5
1 changed files with 8 additions and 6 deletions

View File

@ -23,6 +23,7 @@
#include <console.h> #include <console.h>
#include <gpxe/settings.h> #include <gpxe/settings.h>
#include <gpxe/editbox.h> #include <gpxe/editbox.h>
#include <gpxe/keys.h>
#include <gpxe/settings_ui.h> #include <gpxe/settings_ui.h>
/** @file /** @file
@ -345,18 +346,19 @@ static int main_loop ( struct config_context *context ) {
draw_setting ( &widget ); draw_setting ( &widget );
color_set ( CPAIR_NORMAL, NULL ); color_set ( CPAIR_NORMAL, NULL );
key = getchar(); key = getkey();
if ( widget.editing ) { if ( widget.editing ) {
key = edit_setting ( &widget, key ); key = edit_setting ( &widget, key );
switch ( key ) { switch ( key ) {
case 0x0a: /* Enter */ case CR:
case LF:
if ( ( rc = save_setting ( &widget ) ) != 0 ) { if ( ( rc = save_setting ( &widget ) ) != 0 ) {
alert ( " Could not set %s: %s ", alert ( " Could not set %s: %s ",
widget.setting->name, widget.setting->name,
strerror ( rc ) ); strerror ( rc ) );
} }
/* Fall through */ /* Fall through */
case 0x03: /* Ctrl-C */ case CTRL_C:
load_setting ( &widget ); load_setting ( &widget );
break; break;
default: default:
@ -366,15 +368,15 @@ static int main_loop ( struct config_context *context ) {
} else { } else {
next = current; next = current;
switch ( key ) { switch ( key ) {
case '+': case KEY_DOWN:
if ( next < ( NUM_SETTINGS - 1 ) ) if ( next < ( NUM_SETTINGS - 1 ) )
next++; next++;
break; break;
case '-': case KEY_UP:
if ( next > 0 ) if ( next > 0 )
next--; next--;
break; break;
case 0x13: /* Ctrl-S */ case CTRL_S:
if ( ( rc = nvo_save ( ugly_nvo_hack ) ) != 0){ if ( ( rc = nvo_save ( ugly_nvo_hack ) ) != 0){
alert ( " Could not save options: %s ", alert ( " Could not save options: %s ",
strerror ( rc ) ); strerror ( rc ) );