diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 619b0c1ae3..1170018728 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,22 @@ +Thu Oct 21 14:02:53 1999 Gonzalo A. Diethelm + + * config/linux/gcc.cf: + Added linking against ncurses. + + * include/gtapi.h: + Added hb_gtReadKey() and hb_gt_ReadKey() functions. + + * include/hbsetup.h: + * source/rtl/gtxxx.c: + Made sure LIN_GTAPI is taken into account. + + * source/rtl/console.c: + * source/rtl/filesys.c: + * source/rtl/gtapi.c: + * source/rtl/inkey.c: + * source/rtl/gt/gtwin.c: + Fixed several warnings. + Thu Oct 21 11:56:55 1999 Gonzalo A. Diethelm * source/common/hbtrace.c: diff --git a/harbour/config/linux/gcc.cf b/harbour/config/linux/gcc.cf index 3fe21c06b3..13e7569ad1 100644 --- a/harbour/config/linux/gcc.cf +++ b/harbour/config/linux/gcc.cf @@ -33,7 +33,7 @@ LINKPATHS += $(foreach drv, $(HB_DB_DRIVERS), -L$(TOP)$(ROOT)source/rdd/$(drv)/$ LINKLIBS += $(foreach drv, $(HB_DB_DRIVERS), -l$(drv)) endif -LINKLIBS += -lm -Wl,--end-group +LINKLIBS += -lncurses -lm -Wl,--end-group LDFLAGS = $(LINKPATHS) AR = ar diff --git a/harbour/include/gtapi.h b/harbour/include/gtapi.h index 648314d5de..0f0e7e376d 100644 --- a/harbour/include/gtapi.h +++ b/harbour/include/gtapi.h @@ -48,6 +48,7 @@ extern void hb_gtInit( void ); extern void hb_gtExit( void ); +extern int hb_gtReadKey( void ); extern USHORT hb_gtBox( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight, BYTE * pbyBoxString ); extern USHORT hb_gtBoxD( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight ); extern USHORT hb_gtBoxS( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight ); @@ -85,6 +86,7 @@ extern USHORT hb_gtWriteCon( BYTE * pbyStr, ULONG ulLen ); extern void hb_gt_Init( void ); extern BOOL hb_gt_IsColor( void ); extern void hb_gt_Done( void ); +extern int hb_gt_ReadKey( void ); extern USHORT hb_gt_GetScreenWidth( void ); extern USHORT hb_gt_GetScreenHeight( void ); extern void hb_gt_SetPos( USHORT uiRow, USHORT uiCol ); diff --git a/harbour/include/hbsetup.h b/harbour/include/hbsetup.h index c27ebeed5f..023f1b70ed 100644 --- a/harbour/include/hbsetup.h +++ b/harbour/include/hbsetup.h @@ -155,9 +155,13 @@ /*#define HARBOUR_USE_DOS_GTAPI*/ /*#define HARBOUR_USE_OS2_GTAPI*/ /*#define HARBOUR_USE_WIN_GTAPI*/ +/*#define HARBOUR_USE_LIN_GTAPI*/ /* Indicate that one of the GTAPIs is defined */ -#if defined(HARBOUR_USE_DOS_GTAPI) || defined(HARBOUR_USE_OS2_GTAPI) || defined(HARBOUR_USE_WIN_GTAPI) +#if defined(HARBOUR_USE_DOS_GTAPI) || \ + defined(HARBOUR_USE_OS2_GTAPI) || \ + defined(HARBOUR_USE_WIN_GTAPI) || \ + defined(HARBOUR_USE_LIN_GTAPI) #define HARBOUR_USE_GTAPI #endif diff --git a/harbour/source/rtl/console.c b/harbour/source/rtl/console.c index fad716f3e0..5b80e32899 100644 --- a/harbour/source/rtl/console.c +++ b/harbour/source/rtl/console.c @@ -460,14 +460,17 @@ static void hb_devout( char * pStr, ULONG ulLen ) /* Output an item to the screen */ static void hb_dispout( char * pStr, ULONG ulLen ) { + USHORT user_ferror; + HB_TRACE(("hb_dispout(%s, %lu)", pStr, ulLen)); #ifdef HARBOUR_USE_GTAPI /* Display to console */ hb_gtWriteAt( s_iDevRow, s_iDevCol, ( BYTE * ) pStr, ulLen ); hb_gtGetPos( &s_iDevRow, &s_iDevCol ); + HB_SYMBOL_UNUSED( user_ferror ); #else - USHORT user_ferror = hb_fsError(); /* Save current user file error code */ + user_ferror = hb_fsError(); /* Save current user file error code */ hb_fsWriteLarge( s_iFilenoStdout, ( BYTE * ) pStr, ulLen ); hb_fsSetError( user_ferror ); /* Restore last user file error code */ adjust_pos( pStr, ulLen, &s_iDevRow, &s_iDevCol, hb_max_row(), hb_max_col() ); diff --git a/harbour/source/rtl/filesys.c b/harbour/source/rtl/filesys.c index 1885e13d60..f39199f595 100644 --- a/harbour/source/rtl/filesys.c +++ b/harbour/source/rtl/filesys.c @@ -342,10 +342,11 @@ FHANDLE hb_fsOpen( BYTE * pFilename, USHORT uiFlags ) errno = 0; hFileHandle = open( ( char * ) pFilename, convert_open_flags( uiFlags ) ); s_uiErrorLast = errno; + HB_SYMBOL_UNUSED( iShare ); #elif defined(_MSC_VER) - int iShare = _SH_DENYNO; + iShare = _SH_DENYNO; if( ( uiFlags & FO_DENYREAD ) == FO_DENYREAD ) iShare = _SH_DENYRD; @@ -387,6 +388,7 @@ FHANDLE hb_fsOpen( BYTE * pFilename, USHORT uiFlags ) hFileHandle = FS_ERROR; s_uiErrorLast = FS_ERROR; + HB_SYMBOL_UNUSED( iShare ); #endif diff --git a/harbour/source/rtl/gt/gtwin.c b/harbour/source/rtl/gt/gtwin.c index afd2ea0e50..f41c580bff 100644 --- a/harbour/source/rtl/gt/gtwin.c +++ b/harbour/source/rtl/gt/gtwin.c @@ -89,26 +89,9 @@ static HANDLE HCursor; /* When DispBegin is in effect, all cursor related be different than the one being written to. */ -#define HB_LOG 0 - -#if (defined(HB_LOG) && (HB_LOG != 0)) -static FILE * flog = 0; -static int line = 0; -#define LOG(x) \ -do \ -{ \ - flog = fopen( "c:/tmp/gt.log", "a" ); \ - fprintf( flog, "%5d> GT: %s\n", line++, x ); \ - fflush( flog ); \ - fclose( flog ); \ -} while ( 0 ) -#else -#define LOG(x) -#endif /* #if (defined(HB_LOG) && (HB_LOG != 0)) */ - void hb_gt_Init( void ) { - LOG( "Initializing" ); + HB_TRACE(("hb_gt_Init()")); if( ( hb_gtHInput = GetStdHandle( STD_INPUT_HANDLE ) ) == INVALID_HANDLE_VALUE ) { @@ -131,6 +114,8 @@ void hb_gt_Init( void ) void hb_gt_Done( void ) { + HB_TRACE(("hb_gt_Done()")); + if( HOutput != HOriginal ) { /* ptucker */ @@ -154,11 +139,12 @@ void hb_gt_Done( void ) CloseHandle( HStealth ); HStealth = INVALID_HANDLE_VALUE; } - LOG( "Ending" ); } BOOL hb_gt_IsColor( void ) { + HB_TRACE(("hb_gt_IsColor()")); + /* TODO: need to call something to do this instead of returning TRUE */ return TRUE; } @@ -167,7 +153,8 @@ USHORT hb_gt_GetScreenWidth( void ) { CONSOLE_SCREEN_BUFFER_INFO csbi; - LOG( "GetScreenWidth" ); + HB_TRACE(("hb_gt_GetScreenWidth()")); + GetConsoleScreenBufferInfo( HOutput, &csbi ); /* return csbi.dwMaximumWindowSize.X; */ /* return max( csbi.srWindow.Right - csbi.srWindow.Left + 1, 40 ); */ @@ -178,7 +165,8 @@ USHORT hb_gt_GetScreenHeight( void ) { CONSOLE_SCREEN_BUFFER_INFO csbi; - LOG( "GetScreenHeight" ); + HB_TRACE(("hb_gt_GetScreenHeight()")); + GetConsoleScreenBufferInfo( HOutput, &csbi ); /* return csbi.dwMaximumWindowSize.Y; */ /* return max( csbi.srWindow.Bottom - csbi.srWindow.Top + 1, 25 ); */ @@ -189,12 +177,11 @@ void hb_gt_SetPos( USHORT cRow, USHORT cCol ) { COORD dwCursorPosition; - LOG( "GotoXY" ); + HB_TRACE(("hb_gt_SetPos(%hu, %hu)", cRow, cCol)); + dwCursorPosition.X = ( SHORT ) cCol; dwCursorPosition.Y = ( SHORT ) cRow; - LOG( ".. Calling SetConsoleCursorPosition()" ); SetConsoleCursorPosition( HCursor, dwCursorPosition ); - LOG( ".. Called SetConsoleCursorPosition()" ); } USHORT hb_gt_GetCursorStyle( void ) @@ -202,7 +189,8 @@ USHORT hb_gt_GetCursorStyle( void ) CONSOLE_CURSOR_INFO cci; int rc; - LOG( "GetCursorStyle" ); + HB_TRACE(("hb_gt_GetCursorStyle()")); + GetConsoleCursorInfo( HCursor, &cci ); if( ! cci.bVisible ) @@ -240,7 +228,8 @@ void hb_gt_SetCursorStyle( USHORT style ) { CONSOLE_CURSOR_INFO cci; - LOG( "SetCursorStyle" ); + HB_TRACE(("hb_gt_SetCursorStyle(%hu)", style)); + GetConsoleCursorInfo( HCursor, &cci ); cci.bVisible = 1; /* always visible unless explicitly request off */ switch( style ) @@ -276,7 +265,8 @@ void hb_gt_Puts( USHORT cRow, USHORT cCol, BYTE attr, BYTE *str, ULONG len ) DWORD dwlen; COORD coord; - LOG( "Puts" ); + HB_TRACE(("hb_gt_Puts(%hu, %hu, %d, %p, %lu)", cRow, cCol, (int) attr, str, len)); + coord.X = ( DWORD ) cCol; coord.Y = ( DWORD ) cRow; FillConsoleOutputAttribute( HOutput, ( WORD )( attr & 0xFF ), ( DWORD ) len, coord, &dwlen ); @@ -291,7 +281,7 @@ void hb_gt_GetText( USHORT usTop, USHORT usLeft, USHORT usBottom, USHORT usRight BYTE * pstr; USHORT width, i, y; - LOG( "GetText" ); + HB_TRACE(("hb_gt_GetText(%hu, %hu, %hu, %hu, %p)", usTop, usLeft, usBottom, usRight, dest)); width = ( usRight - usLeft + 1 ); pwattr = ( LPWORD ) hb_xgrab( width * sizeof( *pwattr ) ); @@ -324,7 +314,7 @@ void hb_gt_PutText( USHORT usTop, USHORT usLeft, USHORT usBottom, USHORT usRight BYTE * pstr; USHORT width, i, y; - LOG( "PutText") ; + HB_TRACE(("hb_gt_PutText(%hu, %hu, %hu, %hu, %p)", usTop, usLeft, usBottom, usRight, srce)); width = ( usRight - usLeft + 1 ); pwattr = ( LPWORD ) hb_xgrab( width * sizeof( *pwattr ) ); @@ -357,6 +347,8 @@ void hb_gt_SetAttribute( USHORT usTop, USHORT usLeft, USHORT usBottom, USHORT us COORD coord; USHORT width, y; + HB_TRACE(("hb_gt_SetAttribute(%hu, %hu, %hu, %hu, %d)", usTop, usLeft, usBottom, usRight, (int) attr)); + width = ( usRight - usLeft + 1 ); coord.X = ( DWORD ) usLeft; @@ -376,6 +368,8 @@ void hb_gt_DrawShadow( USHORT usTop, USHORT usLeft, USHORT usBottom, USHORT usRi COORD coord; USHORT width; + HB_TRACE(("hb_gt_DrawShadow(%hu, %hu, %hu, %hu, %d)", usTop, usLeft, usBottom, usRight, (int) attr)); + width = ( usRight - usLeft + 1 ); coord.X = ( DWORD ) usLeft; @@ -389,7 +383,8 @@ USHORT hb_gt_Col( void ) { CONSOLE_SCREEN_BUFFER_INFO csbi; - LOG( "WhereX" ); + HB_TRACE(("hb_gt_Col()")); + GetConsoleScreenBufferInfo( HCursor, &csbi ); return csbi.dwCursorPosition.X; } @@ -398,7 +393,8 @@ USHORT hb_gt_Row( void ) { CONSOLE_SCREEN_BUFFER_INFO csbi; - LOG( "WhereY" ); + HB_TRACE(("hb_gt_Row()")); + GetConsoleScreenBufferInfo( HCursor, &csbi ); return csbi.dwCursorPosition.Y; } @@ -411,6 +407,8 @@ void hb_gt_Scroll( USHORT usTop, USHORT usLeft, USHORT usBottom, USHORT usRight, COORD Target; CHAR_INFO FillChar; + HB_TRACE(("hb_gt_Scroll(%hu, %hu, %hu, %hu, %d, %hd, %hd)", usTop, usLeft, usBottom, usRight, (int) attr, sVert, sHoriz)); + Source.Top = usTop; Source.Left = usLeft; Source.Bottom = usBottom; @@ -436,6 +434,8 @@ void hb_gt_Scroll( USHORT usTop, USHORT usLeft, USHORT usBottom, USHORT usRight, void hb_gt_DispBegin( void ) { + HB_TRACE(("hb_gt_DispBegin()")); + /* ptucker */ if( hb_gtDispCount() == 1 ) { @@ -486,6 +486,8 @@ void hb_gt_DispBegin( void ) void hb_gt_DispEnd( void ) { + HB_TRACE(("hb_gt_DispEnd()")); + /* ptucker */ if( hb_gtDispCount() == 1 ) @@ -506,6 +508,8 @@ static BOOL hb_gt_SetScreenBuffer( HANDLE HNew, HANDLE HOld ) CONSOLE_SCREEN_BUFFER_INFO csbi; SMALL_RECT srWin; + HB_TRACE(("hb_gt_SetScreenBuffer(%p, %p)", HNew, HOld)); + GetConsoleScreenBufferInfo( HOld, &csbi ); /* new console window size and scroll position */ @@ -528,6 +532,8 @@ BOOL hb_gt_SetMode( USHORT uiRows, USHORT uiCols ) SMALL_RECT srWin; COORD coBuf; + HB_TRACE(("hb_gt_SetMode(%hu, %hu)", uiRows, uiCols)); + GetConsoleScreenBufferInfo( HOutput, &csbi ); coBuf = GetLargestConsoleWindowSize( HOutput ); @@ -565,6 +571,8 @@ void hb_gt_Replicate( BYTE c, ULONG ulLength ) COORD coBuf = { 0, 0 }; DWORD dwWritten; + HB_TRACE(("hb_gt_Replicate(%d, %lu)", (int) c, ulLength)); + /* TODO: This is not used and may be eliminated after further review */ FillConsoleOutputCharacter( HOutput, /* handle to screen buffer */ @@ -578,16 +586,24 @@ void hb_gt_Replicate( BYTE c, ULONG ulLength ) BOOL hb_gt_GetBlink() { + HB_TRACE(("hb_gt_GetBlink()")); + + /* TODO */ return FALSE; } void hb_gt_SetBlink( BOOL bBlink ) { + HB_TRACE(("hb_gt_SetBlink(%d)", (int) bBlink)); + + /* TODO: set the bit if it's supported */ HB_SYMBOL_UNUSED( bBlink ); } void hb_gt_DebugScreen( BOOL activate ) { + HB_TRACE(("hb_gt_DebugScreen(%d)", (int) activate)); + /* ptucker */ /* TODO: This is not used and is still a work in progress */ if( activate ) diff --git a/harbour/source/rtl/gtapi.c b/harbour/source/rtl/gtapi.c index 558bfdffd9..f2cca165fd 100644 --- a/harbour/source/rtl/gtapi.c +++ b/harbour/source/rtl/gtapi.c @@ -148,6 +148,17 @@ void hb_gtExit( void ) hb_xfree( s_Color ); } +int hb_gtReadKey( void ) +{ + HB_TRACE(("hb_gtReadKey()")); + +#if defined(OS_UNIX_COMPATIBLE) + return hb_gt_ReadKey(); +#else + return 0; +#endif +} + USHORT hb_gtBox( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight, BYTE * pbyFrame ) { BYTE pszBox[ 10 ]; diff --git a/harbour/source/rtl/gtxxx.c b/harbour/source/rtl/gtxxx.c index f61f433716..69e72aa3fb 100644 --- a/harbour/source/rtl/gtxxx.c +++ b/harbour/source/rtl/gtxxx.c @@ -41,4 +41,6 @@ #include "gt/gtos2.c" #elif defined(HARBOUR_USE_WIN_GTAPI) #include "gt/gtwin.c" +#elif defined(HARBOUR_USE_LIN_GTAPI) + #include "gt/gtlin.c" #endif diff --git a/harbour/source/rtl/inkey.c b/harbour/source/rtl/inkey.c index e0d6b5cd40..7c48ee8684 100644 --- a/harbour/source/rtl/inkey.c +++ b/harbour/source/rtl/inkey.c @@ -778,9 +778,13 @@ printf("\nhb_inkeyPoll: wKey is %d", wKey); ch = 349 - ch; } #elif defined(OS_UNIX_COMPATIBLE) +#if 1 + ch = hb_gtReadKey(); +#else /* TODO: */ if( ! read( STDIN_FILENO, &ch, 1 ) ) ch = 0; +#endif #else /* TODO: Support for other platforms, such as Mac */ #endif