int main(void) { wchar_t key; wprintf(L"Hello from tty0!\n"); wprintf(L"Here's an escape sequence: \x1b[31mThis should be red!\x1b[37m\n"); wprintf(L"And this is \x1b[1;5;32mbright green and flashing!\n\x1b[37m"); wprintf(L"This is the first of two lines of text.\x1b[0m\n" L"\x1b[1B\x1b[2CAnd this is the second...\n"); wprintf(L"Now the third...\n" L"...and fourth lines\n"); wprintf(L"Here's a tab, just for a laugh...\tHa ha!\n"); /*printf("The Möbius Operating System\n");*/ do { wprintf( L"OS Test Menu\n" L"------------\n" L"1)\tTest file I/O (/hd/test.txt)\n" L"2)\tTest block device I/O (" SYS_DEVICES L"/fdc0)\n" L"3)\tTest character device I/O (" SYS_DEVICES L"/keyboard)\n" L"Esc\tQuit\n" L"Choice: "); fflush(stdout); key = _wgetch(); switch (key) { case '1': testFileIo(L"/hd/test.txt"); break; case '2': testBlockDeviceIo(SYS_DEVICES L"/fdc0"); break; case '3': testCharDeviceIo(SYS_DEVICES L"/keyboard"); break; } } while (key != 27); wprintf(L"Bye now...\n"); return EXIT_SUCCESS; }
DFhackCExport int wgetch(WINDOW *win) { static int (*_wgetch)(WINDOW * win) = (int (*)( WINDOW * )) dlsym(RTLD_NEXT, "wgetch"); if(!_wgetch) { exit(EXIT_FAILURE); } DFHack::Core & c = DFHack::Core::getInstance(); wgetch_again: int in = _wgetch(win); int out; if(c.ncurses_wgetch(in, out)) { // not consumed, give to DF return out; } else { // consumed, repeat goto wgetch_again; } }