From 15054c311b39b2bf115277c70245f98fc01aec4c Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Thu, 9 Oct 2008 22:15:01 +0000 Subject: [PATCH] 2008-10-10 00:14 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/include/hbapigt.h * harbour/source/rtl/gtapi.c + added hb_gtPutText() C function * harbour/source/rtl/console.c + added HB_DISPOUTAT() which works like DISPOUTAT but does not change cursor position. xBase++ users can use #xtranslate DispOutAt( ) => hb_dispOutAt( ) for xBase++ compatible code --- harbour/ChangeLog | 11 +++++++++++ harbour/include/hbapigt.h | 1 + harbour/source/rtl/console.c | 35 +++++++++++++++++++++++++++++++++++ harbour/source/rtl/gtapi.c | 17 +++++++++++++++++ 4 files changed, 64 insertions(+) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 76c51a7734..ddeb120f0b 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,17 @@ 2008-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org) */ +2008-10-10 00:14 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/include/hbapigt.h + * harbour/source/rtl/gtapi.c + + added hb_gtPutText() C function + + * harbour/source/rtl/console.c + + added HB_DISPOUTAT() which works like DISPOUTAT but does not change + cursor position. xBase++ users can use + #xtranslate DispOutAt( ) => hb_dispOutAt( ) + for xBase++ compatible code + 2008-10-09 20:51 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/common.mak * harbour/source/rtl/Makefile diff --git a/harbour/include/hbapigt.h b/harbour/include/hbapigt.h index 4c757b8626..27c7257327 100644 --- a/harbour/include/hbapigt.h +++ b/harbour/include/hbapigt.h @@ -186,6 +186,7 @@ extern HB_EXPORT ERRCODE hb_gtTone( double dFrequency, double dDuration ); extern HB_EXPORT ERRCODE hb_gtWrite( BYTE * pbyStr, ULONG ulLen ); extern HB_EXPORT ERRCODE hb_gtWriteAt( USHORT uiRow, USHORT uiCol, BYTE * pbyStr, ULONG ulLen ); extern HB_EXPORT ERRCODE hb_gtWriteCon( BYTE * pbyStr, ULONG ulLen ); +extern HB_EXPORT ERRCODE hb_gtPutText( USHORT uiRow, USHORT uiCol, BYTE * pStr, ULONG ulLength ); extern HB_EXPORT const char * hb_gtVersion( int iType ); extern HB_EXPORT ERRCODE hb_gtOutStd( BYTE * pbyStr, ULONG ulLen ); extern HB_EXPORT ERRCODE hb_gtOutErr( BYTE * pbyStr, ULONG ulLen ); diff --git a/harbour/source/rtl/console.c b/harbour/source/rtl/console.c index a7e3d387ab..75b08a1c00 100644 --- a/harbour/source/rtl/console.c +++ b/harbour/source/rtl/console.c @@ -570,6 +570,41 @@ HB_FUNC( DISPOUTAT ) /* writes a single value to the screen at speficic position } } +/* Harbour extension, works like DISPOUTAT but does not change cursor position */ + +HB_FUNC( HB_DISPOUTAT ) +{ + char * pszString; + ULONG ulLen; + BOOL bFreeReq; + + if( ISCHAR( 4 ) ) + { + char szOldColor[ HB_CLRSTR_LEN ]; + + hb_gtGetColorStr( szOldColor ); + hb_gtSetColorStr( hb_parc( 4 ) ); + + pszString = hb_itemStringCon( hb_param( 3, HB_IT_ANY ), &ulLen, &bFreeReq ); + + hb_gtPutText( ( USHORT ) hb_parni( 1 ), ( USHORT ) hb_parni( 2 ), ( BYTE * ) pszString, ulLen ); + + if( bFreeReq ) + hb_xfree( pszString ); + + hb_gtSetColorStr( szOldColor ); + } + else if( hb_pcount() >= 3 ) + { + pszString = hb_itemStringCon( hb_param( 3, HB_IT_ANY ), &ulLen, &bFreeReq ); + + hb_gtPutText( ( USHORT ) hb_parni( 1 ), ( USHORT ) hb_parni( 2 ), ( BYTE * ) pszString, ulLen ); + + if( bFreeReq ) + hb_xfree( pszString ); + } +} + HB_FUNC( HB_GETSTDIN ) /* Return Handel for STDIN */ { diff --git a/harbour/source/rtl/gtapi.c b/harbour/source/rtl/gtapi.c index ed3e26a87d..ab57f1e744 100644 --- a/harbour/source/rtl/gtapi.c +++ b/harbour/source/rtl/gtapi.c @@ -714,6 +714,23 @@ HB_EXPORT ERRCODE hb_gtSetMode( USHORT uiRows, USHORT uiCols ) return errCode; } +HB_EXPORT ERRCODE hb_gtPutText( USHORT uiRow, USHORT uiCol, BYTE * pStr, ULONG ulLength ) +{ + PHB_GT pGT; + + HB_TRACE(HB_TR_DEBUG, ("hb_gtPutText(%hu, %hu, %p, %lu)", uiRow, uiCol, pStr, ulLength)); + + pGT = hb_gt_Base(); + if( pGT ) + { + HB_GTSELF_PUTTEXT( pGT, uiRow, uiCol, HB_GTSELF_GETCOLOR( pGT ), pStr, ulLength ); + HB_GTSELF_FLUSH( pGT ); + hb_gt_BaseFree( pGT ); + return SUCCESS; + } + return FAILURE; +} + HB_EXPORT ERRCODE hb_gtWriteAt( USHORT uiRow, USHORT uiCol, BYTE * pStr, ULONG ulLength ) { PHB_GT pGT;