mirror of
https://github.com/ipxe/ipxe
synced 2025-12-14 16:01:38 +03:00
Use getkey() and symbolic key names.
This commit is contained in:
@@ -19,6 +19,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <console.h>
|
#include <console.h>
|
||||||
|
#include <gpxe/keys.h>
|
||||||
#include <gpxe/editstring.h>
|
#include <gpxe/editstring.h>
|
||||||
#include <readline/readline.h>
|
#include <readline/readline.h>
|
||||||
|
|
||||||
@@ -92,17 +93,17 @@ char * readline ( const char *prompt ) {
|
|||||||
|
|
||||||
buf[0] = '\0';
|
buf[0] = '\0';
|
||||||
while ( 1 ) {
|
while ( 1 ) {
|
||||||
key = edit_string ( &string, getchar() );
|
key = edit_string ( &string, getkey() );
|
||||||
sync_console ( &string );
|
sync_console ( &string );
|
||||||
switch ( key ) {
|
switch ( key ) {
|
||||||
case 0x0d: /* Carriage return */
|
case CR:
|
||||||
case 0x0a: /* Line feed */
|
case LF:
|
||||||
putchar ( '\n' );
|
putchar ( '\n' );
|
||||||
line = strdup ( buf );
|
line = strdup ( buf );
|
||||||
if ( ! line )
|
if ( ! line )
|
||||||
printf ( "Out of memory\n" );
|
printf ( "Out of memory\n" );
|
||||||
return line;
|
return line;
|
||||||
case 0x03: /* Ctrl-C */
|
case CTRL_C:
|
||||||
putchar ( '\n' );
|
putchar ( '\n' );
|
||||||
return NULL;
|
return NULL;
|
||||||
default:
|
default:
|
||||||
|
|||||||
Reference in New Issue
Block a user