diff --git a/connect4.c b/connect4.c index db13ac1..5487c26 100644 --- a/connect4.c +++ b/connect4.c @@ -23,7 +23,7 @@ #include "types.h" #include "ui.h" -#define VERSION 0.0.2 +#define VERSION 0.0.3 int main(){ // First the boilerplate stuffs diff --git a/ui_vt100.c b/ui_vt100.c index fed7055..beda124 100644 --- a/ui_vt100.c +++ b/ui_vt100.c @@ -18,6 +18,7 @@ */ #include "ui.h" #include +#include #include "macros.h" #define BOARD_WIDTH_CHARS ( 3 * BOARD_WIDTH + 6 ) @@ -131,7 +132,20 @@ int askColumn( printf( "Wher player %d put? ", board.player ); #endif /* ONLYPUT */ printf( "\033[K" ); // clear everything after cursor - scanf( "%d", &column ); + fflush( stdout ); + column = -1; + for( char ch = '0'; ch != '\n'; read( STDIN_FILENO, &ch, 1 ) ){ + if( ch >= '0' && ch <= '9' ){ + if( column == -1 ) + column = 0; + else + column *= 10; + if( column >= 0 ) + column += ( int )( ch - '0' ); + } else { + column = -2; + } + } column -= FIRST_NUMBER; if( column >= 0 && column < BOARD_WIDTH ) #ifndef ONLYPUT