diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 76f8cb92e2..7c186d42da 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,16 @@ +2001-08-17 16:10 UTC-0400 David G. Holm + + Update from "Fergus McDonald" : + + * source/rtl/gtstd/gtstd.c + * tests/gtstdtst.c + + Added conditional functionality for MS C compiler to use io and + conio libs to map stdin in the same manner as already implemented + for unix version (i.e. no blocking). That is, if stdin is coming + from console, inkey() returns 0 if no key waiting, and if stdin is + coming from a file, inkey() returns each char of file and then + always returns 0 once EOF is reached. + 2001-08-17 20:15 UTC+0100 Ryszard Glab *doc/en/compiler.txt diff --git a/harbour/source/rtl/gtstd/gtstd.c b/harbour/source/rtl/gtstd/gtstd.c index 6ac6369b08..572b522c2c 100644 --- a/harbour/source/rtl/gtstd/gtstd.c +++ b/harbour/source/rtl/gtstd/gtstd.c @@ -60,6 +60,11 @@ #if defined( OS_UNIX_COMPATIBLE ) #include /* read() function requires it */ #include +#else +#if defined(_MSC_VER) + #include + #include +#endif #endif /* Add time function for BEL flood throttling.. */ @@ -87,6 +92,11 @@ static ULONG s_ulCrLf; static struct termios startup_attributes; #endif +#if defined(_MSC_VER) + static BOOL s_bStdinConsole; +#endif + + void hb_gt_Init( int iFilenoStdin, int iFilenoStdout, int iFilenoStderr ) { HB_TRACE(HB_TR_DEBUG, ("hb_gt_Init()")); @@ -110,18 +120,22 @@ void hb_gt_Init( int iFilenoStdin, int iFilenoStdout, int iFilenoStderr ) } #endif +#if defined(_MSC_VER) + s_bStdinConsole = _isatty(0); +#endif + s_uiDispCount = 0; s_iRow = 0; s_iCol = 0; -#if defined(OS_UNIX_COMPATIBLE) +// #if defined(OS_UNIX_COMPATIBLE) s_uiMaxRow = 24; s_uiMaxCol = 80; -#else - s_uiMaxRow = 32767; - s_uiMaxCol = 32767; -#endif +// #else +// s_uiMaxRow = 32767; +// s_uiMaxCol = 32767; +// #endif s_uiCursorStyle = SC_NORMAL; s_bBlink = FALSE; @@ -174,7 +188,18 @@ int hb_gt_ReadKey( HB_inkey_enum eventmask ) if( ! read( STDIN_FILENO, &ch, 1 ) ) ch = 0; #else - ch = 0; + +#if defined(_MSC_VER) + if( s_bStdinConsole ) + { + if( _kbhit() ) ch = _getch(); + } + else + { + if(! _eof(0) ) _read(0, &ch, 1); + } +#endif + #endif /* TODO: */ diff --git a/harbour/tests/gtstdtst.prg b/harbour/tests/gtstdtst.prg index cb38d7fce5..4ca044b7b2 100644 --- a/harbour/tests/gtstdtst.prg +++ b/harbour/tests/gtstdtst.prg @@ -4,18 +4,14 @@ /* gtstd test */ -func PosNow() - ?? "[" + alltrim(str(row())) + "," + alltrim(str(col())) + "]" - return NIL - func Main() local n PosNow() ?? "Output test. First line, no newlines." - ? "Press RETURN to continue." - while inkey(0) <> 13 ; enddo + ? "Press a key to continue: " + ?? inkey(0) ? "This is row " + alltrim(str(row())) @@ -56,3 +52,8 @@ func Main() next return NIL + +func PosNow() + ?? "[" + alltrim(str(row())) + "," + alltrim(str(col())) + "]" + return NIL +