static void updateBootArgs( int key ) { key &= kASCIIKeyMask; switch ( key ) { case kBackspaceKey: if ( gBootArgsPtr > gBootArgs ) { int x, y, t; getCursorPositionAndType( &x, &y, &t ); if ( x == 0 && y ) { x = 80; y--; } if (x) x--; setCursorPosition( x, y, 0 ); putca(' ', 0x07, 1); *gBootArgsPtr-- = '\0'; } break; default: if ( key >= ' ' && gBootArgsPtr < gBootArgsEnd) { putchar(key); // echo to screen *gBootArgsPtr++ = key; } break; } }
int selectAlternateBootDevice(int bootdevice) { int key; int newbootdevice; int digitsI = 0; char *end; char digits[3] = {0,0,0}; // We've already printed the current boot device so user knows what it is printf("Typical boot devices are 80 (First HD), 81 (Second HD)\n"); printf("Enter two-digit hexadecimal boot device [%02x]: ", bootdevice); do { key = getc(); switch (key & kASCIIKeyMask) { case kBackspaceKey: if (digitsI > 0) { int x, y, t; getCursorPositionAndType(&x, &y, &t); // Assume x is not 0; x--; setCursorPosition(x,y,0); // back up one char // Overwrite with space without moving cursor position putca(' ', 0x07, 1); digitsI--; } else { // TODO: Beep or something } break; case kReturnKey: digits[digitsI] = '\0'; newbootdevice = strtol(digits, &end, 16); if (end == digits && *end == '\0') { // User entered empty string printf("\nUsing default boot device %x\n", bootdevice); key = 0; } else if(end != digits && *end == '\0') { bootdevice = newbootdevice; printf("\n"); key = 0; // We gots da boot device } else { printf("\nCouldn't parse. try again: "); digitsI = 0; } break; default: if (isxdigit(key & kASCIIKeyMask) && digitsI < 2) { putc(key & kASCIIKeyMask); digits[digitsI++] = key & kASCIIKeyMask; } else { // TODO: Beep or something } break; }; } while (key != 0); return bootdevice; }
static void GUI_updateBootArgs( int key ) { key &= kASCIIKeyMask; switch ( key ) { case kBackspaceKey: if ( gBootArgsPtr > gBootArgs ) { int x, y, t; getCursorPositionAndType( &x, &y, &t ); if ( x == 0 && y ) { x = 80; y--; } if (x) x--; if( bootArgs->Video.v_display == VGA_TEXT_MODE ) { setCursorPosition( x, y, 0 ); putca(' ', 0x07, 1); } else { updateGraphicBootPrompt(kBackspaceKey); } *gBootArgsPtr-- = '\0'; } break; default: if ( key >= ' ' && gBootArgsPtr < gBootArgsEnd) { if( bootArgs->Video.v_display == VGA_TEXT_MODE ) { putchar(key); // echo to screen } else { updateGraphicBootPrompt(key); } *gBootArgsPtr++ = key; } break; } }
static void updateBootArgs( int key ) { key = ASCII_KEY(key); switch ( key ) { case KEY_BKSP: if ( gBootArgsPtr > gBootArgs ) { *--gBootArgsPtr = '\0'; int x, y, t; getCursorPositionAndType( &x, &y, &t ); if ( x == 0 && y ) { x = 80; y--; } if (x) { x--; } if( bootArgs->Video.v_display == VGA_TEXT_MODE ) { setCursorPosition( x, y, 0 ); putca(' ', 0x07, 1); } else { updateGraphicBootPrompt(); } } break; default: if ( key >= ' ' && gBootArgsPtr < gBootArgsEnd) { *gBootArgsPtr++ = key; if( bootArgs->Video.v_display != VGA_TEXT_MODE ) updateGraphicBootPrompt(); else if ( key >= ' ' && key < 0x7f) putchar(key); } break; } }
static void changeCursor( int col, int row, int type, CursorState * cs ) { if (cs) getCursorPositionAndType( &cs->x, &cs->y, &cs->type ); setCursorType( type ); setCursorPosition( col, row, 0 ); }