Loading yaht.c +19 −14 Original line number Diff line number Diff line Loading @@ -60,20 +60,21 @@ int main(void) { } char key_pressed = (char)getchar(); // with terminal settings above, this will no longer wait for Enter key; note that Enter key is handled with \n case // handle arrow keys todo fix this // if (key_pressed == '\033') { // char which_arrow = (char)getchar(); // switch (which_arrow) { // case 'B': // key_pressed = 'j'; // break; // case 'A': // key_pressed = 'k'; // break; // default: // break; // } // } if (key_pressed == '\033') { getchar(); // skip over the '[' from the arrow key key_pressed = (char)getchar(); switch (key_pressed) { case 'B': key_pressed = 'j'; // todo messy! make this better break; case 'A': key_pressed = 'k'; // todo messy! make this better break; default: break; } } switch (key_pressed) { case 'j': Loading Loading @@ -109,6 +110,10 @@ int main(void) { do_demo_dice_rolls(&ctx, next_roll); } // cleanup items // restore terminal mode tcsetattr(STDIN_FILENO, TCSANOW, &old_terminal_configuration); // close random device fd fclose(ctx.random_device_fd); return 0; } Loading Loading
yaht.c +19 −14 Original line number Diff line number Diff line Loading @@ -60,20 +60,21 @@ int main(void) { } char key_pressed = (char)getchar(); // with terminal settings above, this will no longer wait for Enter key; note that Enter key is handled with \n case // handle arrow keys todo fix this // if (key_pressed == '\033') { // char which_arrow = (char)getchar(); // switch (which_arrow) { // case 'B': // key_pressed = 'j'; // break; // case 'A': // key_pressed = 'k'; // break; // default: // break; // } // } if (key_pressed == '\033') { getchar(); // skip over the '[' from the arrow key key_pressed = (char)getchar(); switch (key_pressed) { case 'B': key_pressed = 'j'; // todo messy! make this better break; case 'A': key_pressed = 'k'; // todo messy! make this better break; default: break; } } switch (key_pressed) { case 'j': Loading Loading @@ -109,6 +110,10 @@ int main(void) { do_demo_dice_rolls(&ctx, next_roll); } // cleanup items // restore terminal mode tcsetattr(STDIN_FILENO, TCSANOW, &old_terminal_configuration); // close random device fd fclose(ctx.random_device_fd); return 0; } Loading