static void printMenuItem( const MenuItem * item, int highlight ) { printf(" "); if ( highlight ) putca(' ', 0x70, strlen(item->name) + 4); else putca(' ', 0x07, 40); printf(" %40s\n", item->name); }
static void printMenuItem( const MenuItem * item, int highlight ) { printf(" "); if ( highlight ) putca(' ', 0x70, strlen(item->name) + 4); else putca(' ', 0x07, 40); char Item[40]; snprintf(Item, sizeof(Item), item->name); printf(" %s\n", Item); }
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; } }
/* Process any keyboard input - removed from main() to make accessable * by other processes - K5JB */ void check_kbd() { char *ttybuf; int c; int16 cnt; int ttydriv(),cmdparse(),kbread(); #ifdef FLOW extern int ttyflow; #endif extern struct cmds cmds[]; extern char prompt[]; #ifdef SYS5 #ifdef USE_QUIT if(reportquit_flag) /* set by quit signal and report is deferred */ report_quit(); /* until now */ #endif /* note that if shellpid, kbread() always returns -1 */ while((background == 0) && ((c = kbread()) != -1)) #else while((c = kbread()) != -1) #endif { #ifdef MSDOS /* c == -2 means the command escape key (F10) */ Keyhit = c; /* a global we use for haktc */ if(c == -2) { if(mode != CMD_MODE) { #ifdef CUTE_VIDEO putca('\n',saved_attrib); /* in case we were in session */ #else printf("\n"); #endif cmdmode(); } continue; } #endif #if defined(UNIX) || defined(_OSK) if(c == escape && escape != 0) { if(mode != CMD_MODE) { printf("\n"); cmdmode(); } continue; } #endif /* UNIX or _OSK */ #ifndef FLOW if ((cnt = ttydriv(c, &ttybuf)) == 0) continue; #else cnt = ttydriv(c, &ttybuf); if (ttyflow && (mode != CMD_MODE)) go(); /* display pending chars */ if (cnt == 0) continue; #endif /* FLOW */ switch(mode) { case CMD_MODE: (void)cmdparse(cmds,ttybuf); fflush(stdout); break; case CONV_MODE: if(current->parse != NULLFP) (*current->parse)(ttybuf,cnt); break; } #if defined(FORKSHELL) && defined(SYS5) if(mode == CMD_MODE && !shellpid) #else if(mode == CMD_MODE) #endif { if(noprompt) /* k35 */ noprompt = 0; else { printf(prompt); fflush(stdout); } } } /* while */ }