From f75bc7b0511b8cc2fd31174eb86751e67563d8ba Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Tue, 7 Oct 2008 07:35:38 +0000 Subject: [PATCH] 2008-10-07 09:33 UTC+0200 Viktor Szakats (harbour.01 syenar hu) * include/hbextern.ch * source/rtl/inkey.c + Added HB_KEYCLEAR() a documented function equivalent to "CLEAR TYPEAHEAD" command, or undocumented __KEYBOARD() function. * contrib/rddads/rddads.h * contrib/rddads/ads1.c + Added support for ADS_USE_OEM_TRANSLATION for old ads versions. Borrowed from xhb/Pavel Tsarenko. --- harbour/ChangeLog | 11 +++++++++ harbour/contrib/rddads/ads1.c | 40 ++++++++++++++++++++++++++++++++- harbour/contrib/rddads/rddads.h | 2 +- harbour/include/hbextern.ch | 1 + harbour/source/rtl/inkey.c | 5 +++++ 5 files changed, 57 insertions(+), 2 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index c693b1ab9e..b2718933f2 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-07 09:33 UTC+0200 Viktor Szakats (harbour.01 syenar hu) + * include/hbextern.ch + * source/rtl/inkey.c + + Added HB_KEYCLEAR() a documented function equivalent + to "CLEAR TYPEAHEAD" command, or undocumented __KEYBOARD() function. + + * contrib/rddads/rddads.h + * contrib/rddads/ads1.c + + Added support for ADS_USE_OEM_TRANSLATION for old ads versions. + Borrowed from xhb/Pavel Tsarenko. + 2008-10-07 02:57 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/include/Makefile + harbour/include/hbatomic.h diff --git a/harbour/contrib/rddads/ads1.c b/harbour/contrib/rddads/ads1.c index f165b25ecd..bd2fb01b97 100644 --- a/harbour/contrib/rddads/ads1.c +++ b/harbour/contrib/rddads/ads1.c @@ -515,13 +515,21 @@ static ERRCODE adsScopeSet( ADSAREAP pArea, ADSHANDLE hOrder, USHORT nScope, PHB if( HB_IS_STRING( pItem ) ) { /* bTypeError = FALSE; */ + pucScope = ( UNSIGNED8 * ) hb_itemGetCPtr( pItem ); #ifdef ADS_USE_OEM_TRANSLATION if( hb_ads_bOEM ) { +#if ADS_LIB_VERSION >= 600 u16DataType = ADS_RAWKEY; +#else + USHORT uiLen = ( USHORT ) hb_itemGetCLen( pItem ); + + char * pBuffer = hb_adsOemToAnsi( ( char * ) pucScope, uiLen ); + memcpy( ( char * ) pucScope, pBuffer, uiLen ); + hb_adsOemAnsiFree( pBuffer ); +#endif } #endif - pucScope = ( UNSIGNED8 * ) hb_itemGetCPtr( pItem ); AdsSetScope( hOrder, nScope, ( UNSIGNED8 * ) pucScope, ( UNSIGNED16 ) hb_itemGetCLen( pItem ), u16DataType ); @@ -901,7 +909,17 @@ static ERRCODE adsSeek( ADSAREAP pArea, BOOL bSoftSeek, PHB_ITEM pKey, BOOL bFin pszKey = ( UNSIGNED8* ) hb_itemGetCPtr( pKey ); u16KeyLen = ( UNSIGNED16 ) hb_itemGetCLen( pKey ); #ifdef ADS_USE_OEM_TRANSLATION +#if ADS_LIB_VERSION >= 600 u16KeyType = hb_ads_bOEM ? ADS_RAWKEY : ADS_STRINGKEY; +#else + u16KeyType = ADS_STRINGKEY; + if( hb_ads_bOEM ) + { + char * pBuffer = hb_adsOemToAnsi( ( char * ) pszKey, u16KeyLen ); + memcpy( ( char * ) pszKey, pBuffer, u16KeyLen ); + hb_adsOemAnsiFree( pBuffer ); + } +#endif #else u16KeyType = ADS_STRINGKEY; #endif @@ -1888,7 +1906,21 @@ static ERRCODE adsGetValue( ADSAREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) #ifdef ADS_USE_OEM_TRANSLATION else if( hb_ads_bOEM ) { +#if ADS_LIB_VERSION >= 600 AdsGetFieldRaw( pArea->hTable, ADSFIELD( uiIndex ), pBuffer, &u32Length ); +#else + if( AdsGetField( pArea->hTable, ADSFIELD( uiIndex ), pBuffer, &u32Length, ADS_NONE ) == AE_NO_CURRENT_RECORD ) + { + memset( pBuffer, ' ', pField->uiLen ); + hb_adsUpdateAreaFlags( pArea ); + } + else + { + char * pBufOem = hb_adsAnsiToOem( ( char * ) pBuffer, pField->uiLen ); + memcpy( pBuffer, pBufOem, pField->uiLen ); + hb_adsOemAnsiFree( pBufOem ); + } +#endif } #endif else if( AdsGetField( pArea->hTable, ADSFIELD( uiIndex ), pBuffer, &u32Length, ADS_NONE ) == AE_NO_CURRENT_RECORD ) @@ -2224,7 +2256,13 @@ static ERRCODE adsPutValue( ADSAREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) #ifdef ADS_USE_OEM_TRANSLATION if( hb_ads_bOEM ) { +#if ADS_LIB_VERSION >= 600 ulRetVal = AdsSetFieldRaw( pArea->hTable, ADSFIELD( uiIndex ), ( UNSIGNED8 * ) hb_itemGetCPtr( pItem ), uiCount ); +#else + char * pBuffer = hb_adsOemToAnsi( hb_itemGetCPtr( pItem ), uiCount ); + ulRetVal = AdsSetString( pArea->hTable, ADSFIELD( uiIndex ), ( UNSIGNED8 * ) pBuffer, uiCount ); + hb_adsOemAnsiFree( pBuffer ); +#endif } else #endif diff --git a/harbour/contrib/rddads/rddads.h b/harbour/contrib/rddads/rddads.h index 8e4f230730..c6db2569f9 100644 --- a/harbour/contrib/rddads/rddads.h +++ b/harbour/contrib/rddads/rddads.h @@ -216,7 +216,7 @@ typedef ADSAREA * ADSAREAP; #define HB_RDD_ADS_VERSION_STRING "ADS RDD 1.4" -#if ADS_LIB_VERSION >= 600 && defined( HB_OS_WIN_32 ) +#if defined( HB_OS_WIN_32 ) # define ADS_USE_OEM_TRANSLATION #else # undef ADS_USE_OEM_TRANSLATION diff --git a/harbour/include/hbextern.ch b/harbour/include/hbextern.ch index 785aed2f82..7782b37a67 100644 --- a/harbour/include/hbextern.ch +++ b/harbour/include/hbextern.ch @@ -1075,6 +1075,7 @@ EXTERNAL HB_FEOF EXTERNAL HB_FCOMMIT EXTERNAL HB_FTEMPCREATE EXTERNAL HB_GCALL +EXTERNAL HB_KEYCLEAR EXTERNAL HB_KEYPUT EXTERNAL HB_KEYINS EXTERNAL HB_OEMTOANSI diff --git a/harbour/source/rtl/inkey.c b/harbour/source/rtl/inkey.c index 9bab8c2708..22eb321485 100644 --- a/harbour/source/rtl/inkey.c +++ b/harbour/source/rtl/inkey.c @@ -173,6 +173,11 @@ HB_FUNC( __KEYBOARD ) hb_inkeySetText( hb_parc( 1 ), hb_parclen( 1 ) ); } +HB_FUNC( HB_KEYCLEAR ) +{ + hb_inkeyReset(); +} + HB_FUNC( HB_KEYPUT ) { if( ISNUM( 1 ) )