void prompt_quit(int height) { if (prompt("Really quit?", height)) { exit(0); } else { prflush("\x1B[2K"); } }
void HERE(void) { print("here\n"); prflush(); delay(5000); }
void panic(char *fmt, ...) { int s; va_list arg; char buf[PRINTSIZE]; kprintoq = nil; /* don't try to write to /dev/kprint */ if(panicking) for(;;); panicking = 1; s = splhi(); strcpy(buf, "panic: "); va_start(arg, fmt); vseprint(buf+strlen(buf), buf+sizeof(buf), fmt, arg); va_end(arg); iprint("%s\n", buf); if(consdebug) (*consdebug)(); splx(s); prflush(); dumpstack(); if(!cpuserver) for(;;); exit(1); }
void initscreen(void) { struct termios tios; tcgetattr(0, &tios_bak); tios=tios_bak; tios.c_lflag&=~( ECHO|ECHOE // no echo of normal characters, erasing #ifdef ECHOKE |ECHOKE // ...and killing #endif #ifdef ECHOCTL |ECHOCTL // don't visibly echo control characters (^V etc.) #endif |ECHONL // don't even echo a newline |ICANON // disable canonical mode #ifdef NOKERNINFO |NOKERNINFO // don't print a status line on ^T #endif |IEXTEN // don't handle things like ^V specially //|ISIG // disable ^C ^\ and ^Z ); tios.c_cc[VMIN]=1; // read one char at a time tios.c_cc[VTIME]=0; // no timeout on reading, make it a blocking read tcsetattr(0, TCSAFLUSH, &tios); prflush("\x1B[?1049h\x1B[2J\x1B[H"); }
void DONE(void) { print("DONE\n"); prflush(); delay(10000); ndnr(); }
bool prompt(const char *msg, int height) { gotoxy(0, height); prflush("%s [y/N] ", msg); bool res; Key key; while (true) { getkey(&key); if (key.ch == 'n' || key.ch == 10) { res = false; break; } else if (key.ch == 'y') { res = true; break; } } prflush("\x1B[2K\x1B[A\x1B[2K"); return res; }
void gotoxy(int x, int y) { prflush("\x1B[%d;%dH", y+1, x+1); }
void endscreen(void) { tcsetattr(0, TCSAFLUSH, &tios_bak); prflush("\x1B[?1049l"); }
inline void bel() { prflush("\x07"); }