From 918d33dea31cbbeebdae893d10d42fe480ce29ba Mon Sep 17 00:00:00 2001 From: Ryszard Glab Date: Sat, 21 Aug 1999 12:29:24 +0000 Subject: [PATCH] ChangeLog 19990821-14:20 GMT+2 --- harbour/ChangeLog | 7 +++++++ harbour/source/rtl/inkey.c | 36 +++++++++++++++++++++++++++++------- 2 files changed, 36 insertions(+), 7 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 9ca8611d31..8a821eba32 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,10 @@ +19990821-14:20 GMT+2 Ryszard Glab + + *source/rtl/inkey.c + * added test code for OS_UNIX_COMPATIBLE based on noncanonical + low-level terminal functions - we need however to extend this + code to support different terminals + 19990821-00:05 GMT+1 Antonio Linares * source/debug/debugger.prg * improved debugger functionality. diff --git a/harbour/source/rtl/inkey.c b/harbour/source/rtl/inkey.c index 842be81327..0478877d52 100644 --- a/harbour/source/rtl/inkey.c +++ b/harbour/source/rtl/inkey.c @@ -96,6 +96,31 @@ HB_INIT_SYMBOLS_END( INKEY__InitSymbols ) #pragma startup INKEY__InitSymbols #endif +#if defined( OS_UNIX_COMPATIBLE ) +#include +#include + +static struct termios startup_attributes; + +static void restore_input_mode( void ) +{ + tcsetattr( STDIN_FILENO, TCSANOW, &startup_attributes ); +} + +HB_CALL_ON_STARTUP_BEGIN( init_input_mode ) + struct termios ta; + + tcgetattr( STDIN_FILENO, &startup_attributes ); + atexit( restore_input_mode ); + + tcgetattr( STDIN_FILENO, &ta ); + ta.c_lflag &= ~(ICANON | ECHO); + ta.c_cc[ VMIN ] =0; + ta.c_cc[ VTIME ] =0; + tcsetattr( STDIN_FILENO, TCSAFLUSH, &ta ); +HB_CALL_ON_STARTUP_END( init_input_mode ) +#endif + static int *s_inkeyBuffer=0; /* Harbour keyboard buffer (empty if head == tail) */ static int s_inkeyHead; /* Harbour keyboard buffer head pointer (next insert) */ static int s_inkeyTail; /* Harbour keyboard buffer tail pointer (next extract) */ @@ -374,11 +399,8 @@ void hb_inkeyPoll( void ) /* Poll the console keyboard to stuff the Harbour } #elif defined(OS_UNIX_COMPATIBLE) /* TODO: */ - /* Note: If GCC for Linux on PCs uses the same keyboard codes as the - other PC platforms in the previous #if section, then it should - be possible to add a user-defined HARBOUR_GCC_PC #define and - include it in the previous #if section, with the appropriate - #elif or || defined(HARBOUR_GCC_PC) to get the keyboard input */ + if( ! read( STDIN_FILENO, &ch, 1 ) ) + ch =0; #else /* TODO: Support for other platforms, such as Mac */ #endif @@ -510,8 +532,8 @@ HARBOUR HB_INKEY( void ) /* When not using the GT API, flush both stdout and stderr, because we are waiting for input and want to ensure that any user prompts are visible. */ - fflush( stdout ); - fflush( stderr ); +// fflush( stdout ); +// fflush( stderr ); #endif }