diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 52e19ea329..b4f6a7a17c 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,68 @@ 2008-12-31 13:59 UTC+0100 Foo Bar */ +2008-06-13 19:19 UTC+0200 Viktor Szakats (harbour.01 syenar hu) + * source/rtl/gtwvt/gtwvt.h + * source/rtl/gtwvt/gtwvt.c + * tests/wvtext.prg + + Added hb_gtInfo( HB_GTI_SELECTCOPY, ) + to set the menu text ("Mark and Copy" on startup). + cMenuText mustn't be zero length. Setting the menu text + also enables select© automatically. The call + will return the previously set menu text. To get + the menu text without setting a new one, use: + hb_gtInfo( HB_GTI_SELECTCOPY, "" ) + This is good if someone wants to adapt the menu + text to the OS's or app's language. + + * doc/en/hb_apiit.txt + * include/hbapi.h + * include/hbapiitm.h + * source/rtl/gtwin/gtwin.c + * source/rtl/hbgtcore.c + * source/rtl/gtgui/gtgui.c + * source/rtl/gtwvt/gtwvt.c + * source/vm/macro.c + * source/vm/debug.c + * source/vm/itemapi.c + * source/vm/hvm.c + * source/vm/arrays.c + * source/vm/extend.c + * source/rdd/dbfntx/dbfntx1.c + * source/rdd/sdf1.c + * source/rdd/dbfcdx/dbfcdx1.c + * source/rdd/delim1.c + * source/rdd/dbf1.c + * source/rdd/dbffpt/dbffpt1.c + * contrib/hbw32/w32_ole.c + * contrib/gtwvg/gtwvg.c + * contrib/rddads/ads1.c + * contrib/hbmisc/spd.c + * contrib/hbbmcdx/bmdbfcdx1.c + * contrib/examples/rdddbt/dbfdbt1.c + * I did a mistake in 1999 by giving the name hb_itemPutCPtr() + to the function which would have to be correctly named + hb_itemPutCLPtr() (notice the 'L' for 'length'). + So, now this was renamed to hb_itemPutCLPtr(), and stub was + added with the old name, and Harbour code was changed to use + the new one. I've also added hb_itemPutCPtr2() as a version + not requiring len parameter, the proper name would be hb_itemPutCPtr() + for this, but we cannot use without breakin compatiblity. + + IMPORTANT: I'd strongly suggest all 3rd parties to update + their code to use the call hb_itemPutCLPtr() instead of + hb_itemPutCLPtr(). + + The final goal would be to have hb_itemPutCPtr() with two + parameters instead of the hakish looking hb_itemPutCPtr2(). + + I'd welcome any opinions how to reach this goal. I didn't want to + break compatiblity with 3rd parties this time, but IMO we may do + it in 1.1, or even before 1.0. + + ! The above also fixes the (potential) problem when hb_retc_buffer()'s + szText parameter was evaluated twice if HB_API_MACROS was #defined. + 2008-06-14 06:18 UTC+0800 Pritpal Bedi (pritpal@vouchcac.com) * harbour/source/rtl/gtwvt/gtwvt.c ! Replaced min()/max() functions with HB_MIN()/HB_MAX() macro. diff --git a/harbour/contrib/examples/rdddbt/dbfdbt1.c b/harbour/contrib/examples/rdddbt/dbfdbt1.c index 31e4b63bad..5fc466112c 100644 --- a/harbour/contrib/examples/rdddbt/dbfdbt1.c +++ b/harbour/contrib/examples/rdddbt/dbfdbt1.c @@ -324,7 +324,7 @@ static void hb_dbtGetMemo( DBTAREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) else *pBuffer = '\0'; - hb_itemPutCPtr( pItem, ( char * ) pBuffer, ulSize ); + hb_itemPutCLPtr( pItem, ( char * ) pBuffer, ulSize ); hb_itemSetCMemo( pItem ); } diff --git a/harbour/contrib/gtwvg/gtwvg.c b/harbour/contrib/gtwvg/gtwvg.c index 97f482f04b..eb7fbfcf48 100644 --- a/harbour/contrib/gtwvg/gtwvg.c +++ b/harbour/contrib/gtwvg/gtwvg.c @@ -2371,7 +2371,7 @@ static BOOL hb_gt_wvt_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) { char * szTitle = NULL; if( hb_gt_wvt_GetWindowTitle( &szTitle ) ) - pInfo->pResult = hb_itemPutCPtr( pInfo->pResult, szTitle, strlen( szTitle ) ); + pInfo->pResult = hb_itemPutCPtr2( pInfo->pResult, szTitle ); else pInfo->pResult = hb_itemPutC( pInfo->pResult, "" ); if( hb_itemType( pInfo->pNewVal ) & HB_IT_STRING ) @@ -2460,7 +2460,7 @@ static BOOL hb_gt_wvt_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) CF_OEMTEXT : CF_TEXT, &szClipboardData, &ulLen ) ) { - pInfo->pResult = hb_itemPutCPtr( pInfo->pResult, + pInfo->pResult = hb_itemPutCLPtr( pInfo->pResult, szClipboardData, ulLen ); } diff --git a/harbour/contrib/hbbmcdx/bmdbfcdx1.c b/harbour/contrib/hbbmcdx/bmdbfcdx1.c index 37e9627446..04de646705 100644 --- a/harbour/contrib/hbbmcdx/bmdbfcdx1.c +++ b/harbour/contrib/hbbmcdx/bmdbfcdx1.c @@ -705,7 +705,7 @@ static PHB_ITEM hb_cdxKeyGetItem( LPCDXKEY pKey, PHB_ITEM pItem, LPCDXTAG pTag, pVal[ pKey->len ] = '\0'; hb_cdpnTranslate( pVal, pTag->pIndex->pArea->cdPage, hb_cdp_page, pKey->len ); - pItem = hb_itemPutCPtr( pItem, pVal, pKey->len ); + pItem = hb_itemPutCLPtr( pItem, pVal, pKey->len ); } else #else diff --git a/harbour/contrib/hbmisc/spd.c b/harbour/contrib/hbmisc/spd.c index 770def083f..9bfb86fdc0 100644 --- a/harbour/contrib/hbmisc/spd.c +++ b/harbour/contrib/hbmisc/spd.c @@ -69,7 +69,7 @@ static void STAItm( PHB_ITEM pItmPar ) cRes[i++] = *c++; } cRes[i++] = '\''; /* cRes[i] = '\0'; */ - hb_itemPutCPtr( pItmPar, cRes, i ); + hb_itemPutCLPtr( pItmPar, cRes, i ); } static ULONG SCItm( char *cBuffer, ULONG ulMaxBuf, char *cParFrm, int iCOut, int IsIndW, int iIndWidth, int IsIndP, int iIndPrec, PHB_ITEM pItmPar ) diff --git a/harbour/contrib/hbw32/w32_ole.c b/harbour/contrib/hbw32/w32_ole.c index 41322b5ce9..6021c1f8eb 100644 --- a/harbour/contrib/hbw32/w32_ole.c +++ b/harbour/contrib/hbw32/w32_ole.c @@ -724,12 +724,12 @@ static void FreeParams( DISPPARAMS *pDispParams, PHB_ITEM *aPrgParams ) case VT_BYREF | VT_BSTR: SysFreeString( *pVariant->n1.n2.n3.pbstrVal ); sString = hb_oleWideToAnsi( *( pVariant->n1.n2.n3.pbstrVal ) ); - hb_itemPutCPtr( pItem, sString, strlen( sString ) ); + hb_itemPutCPtr2( pItem, sString ); break; case VT_BSTR: sString = hb_oleWideToAnsi( pVariant->n1.n2.n3.bstrVal ); - hb_itemPutCPtr( pItem, sString, strlen( sString ) ); + hb_itemPutCPtr2( pItem, sString ); break; case VT_BYREF | VT_BOOL: @@ -1048,7 +1048,7 @@ HRESULT hb_oleVariantToItem( PHB_ITEM pItem, VARIANT *pVariant ) if( sString ) { - hb_itemPutCPtr( pItem, sString, strlen( sString ) ); + hb_itemPutCPtr2( pItem, sString ); } else { @@ -2120,7 +2120,7 @@ HB_FUNC( TOLEAUTO_ONERROR ) //HB_TRACE(HB_TR_INFO, ("Class: '%s'\n", sOleClassName)); - hb_itemPutCPtr( pOleClassName, sOleClassName, iClassNameLen + 1 + iMsgNameLen ); + hb_itemPutCLPtr( pOleClassName, sOleClassName, iClassNameLen + 1 + iMsgNameLen ); hb_vmPushSymbol( hb_dynsymSymbol( s_pSym_cClassName ) ); hb_vmPush( pReturn ); diff --git a/harbour/contrib/rddads/ads1.c b/harbour/contrib/rddads/ads1.c index 531481828d..6a966ddc72 100644 --- a/harbour/contrib/rddads/ads1.c +++ b/harbour/contrib/rddads/ads1.c @@ -2138,7 +2138,7 @@ static ERRCODE adsGetValue( ADSAREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) pulLen++; /* make room for NULL */ pucBuf = ( UNSIGNED8 * ) hb_xgrab( pulLen ); AdsGetBinary( pArea->hTable, ADSFIELD( uiIndex ), 0, pucBuf, &pulLen ); - hb_itemPutCPtr( pItem, ( char * ) pucBuf, pulLen ); + hb_itemPutCLPtr( pItem, ( char * ) pucBuf, pulLen ); } } hb_itemSetCMemo( pItem ); diff --git a/harbour/doc/en/hb_apiit.txt b/harbour/doc/en/hb_apiit.txt index f3c82962a0..4be921efe3 100644 --- a/harbour/doc/en/hb_apiit.txt +++ b/harbour/doc/en/hb_apiit.txt @@ -947,7 +947,7 @@ /* $DOC$ * $FUNCNAME$ - * hb_itemPutCPtr() + * hb_itemPutCPtr2() * $CATEGORY$ * Item API * $ONELINER$ @@ -956,7 +956,44 @@ * C Prototype * * #include - * hb_itemPutCPtr( PHB_ITEM pItem, char * szText, ULONG ulLen ) --> ( PHB_ITEM )pResult + * hb_itemPutCPtr2( PHB_ITEM pItem, char * szText ) --> ( PHB_ITEM )pResult + * $ARGUMENTS$ + * + * + * + * + * + * $RETURNS$ + * + * $DESCRIPTION$ + * + * $EXAMPLES$ + * + * $STATUS$ + * R + * $COMPLIANCE$ + * Compliance is not applicable to API calls. + * $FILES$ + * Library is rtl + * $PLATFORMS$ + * All + * $SEEALSO$ + * + * $END$ + */ + +/* $DOC$ + * $FUNCNAME$ + * hb_itemPutCLPtr() + * $CATEGORY$ + * Item API + * $ONELINER$ + * + * $SYNTAX$ + * C Prototype + * + * #include + * hb_itemPutCLPtr( PHB_ITEM pItem, char * szText, ULONG ulLen ) --> ( PHB_ITEM )pResult * $ARGUMENTS$ * * diff --git a/harbour/include/hbapi.h b/harbour/include/hbapi.h index 7fcf5c84c8..41a973a14e 100644 --- a/harbour/include/hbapi.h +++ b/harbour/include/hbapi.h @@ -646,10 +646,10 @@ extern HB_EXPORT void hb_retnlllen( LONGLONG lNumber, int iWidth ); /* returns #define hb_reta( ulLen ) hb_arrayNew( hb_stackReturnItem(), ulLen ) #define hb_retc( szText ) hb_itemPutC( hb_stackReturnItem(), szText ) #define hb_retc_null() hb_itemPutC( hb_stackReturnItem(), NULL ) -#define hb_retc_buffer( szText ) hb_itemPutCPtr( hb_stackReturnItem(), szText, strlen( szText ) ) +#define hb_retc_buffer( szText ) hb_itemPutCPtr2( hb_stackReturnItem(), szText ) #define hb_retc_const( szText ) hb_itemPutCConst( hb_stackReturnItem(), szText ) #define hb_retclen( szText, ulLen ) hb_itemPutCL( hb_stackReturnItem(), szText, ulLen ) -#define hb_retclen_buffer( szText, ulLen ) hb_itemPutCPtr( hb_stackReturnItem(), szText, ulLen ) +#define hb_retclen_buffer( szText, ulLen ) hb_itemPutCLPtr( hb_stackReturnItem(), szText, ulLen ) #define hb_retds( szDate ) hb_itemPutDS( hb_stackReturnItem(), szDate ) #define hb_retd( iYear, iMonth, iDay ) hb_itemPutD( hb_stackReturnItem(), iYear, iMonth, iDay ) #define hb_retdl( lJulian ) hb_itemPutDL( hb_stackReturnItem(), lJulian ) diff --git a/harbour/include/hbapiitm.h b/harbour/include/hbapiitm.h index bc99c3917c..21dce91632 100644 --- a/harbour/include/hbapiitm.h +++ b/harbour/include/hbapiitm.h @@ -107,7 +107,9 @@ extern HB_EXPORT PHB_ITEM hb_itemPutC ( PHB_ITEM pItem, const char * szTe extern HB_EXPORT PHB_ITEM hb_itemPutCL ( PHB_ITEM pItem, const char * szText, ULONG ulLen ); extern HB_EXPORT PHB_ITEM hb_itemPutCConst ( PHB_ITEM pItem, const char * szText ); extern HB_EXPORT PHB_ITEM hb_itemPutCLConst( PHB_ITEM pItem, const char * szText, ULONG ulLen ); +extern HB_EXPORT PHB_ITEM hb_itemPutCPtr2 ( PHB_ITEM pItem, char * szText ); extern HB_EXPORT PHB_ITEM hb_itemPutCPtr ( PHB_ITEM pItem, char * szText, ULONG ulLen ); +extern HB_EXPORT PHB_ITEM hb_itemPutCLPtr ( PHB_ITEM pItem, char * szText, ULONG ulLen ); extern HB_EXPORT void hb_itemSetCMemo ( PHB_ITEM pItem ); extern HB_EXPORT PHB_ITEM hb_itemPutD ( PHB_ITEM pItem, int iYear, int iMonth, int iDay ); extern HB_EXPORT PHB_ITEM hb_itemPutDS ( PHB_ITEM pItem, const char * szDate ); diff --git a/harbour/source/rdd/dbf1.c b/harbour/source/rdd/dbf1.c index 0638149281..c94f9dcc79 100644 --- a/harbour/source/rdd/dbf1.c +++ b/harbour/source/rdd/dbf1.c @@ -1868,7 +1868,7 @@ static ERRCODE hb_dbfGetValue( DBFAREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) memcpy( pVal, pArea->pRecord + pArea->pFieldOffset[ uiIndex ], pField->uiLen ); pVal[ pField->uiLen ] = '\0'; hb_cdpnTranslate( pVal, pArea->cdPage, hb_cdp_page, pField->uiLen ); - hb_itemPutCPtr( pItem, pVal, pField->uiLen ); + hb_itemPutCLPtr( pItem, pVal, pField->uiLen ); } else #endif @@ -3526,7 +3526,7 @@ static ERRCODE hb_dbfRecInfo( DBFAREAP pArea, PHB_ITEM pRecID, USHORT uiInfoType } } } - hb_itemPutCPtr( pInfo, ( char * ) pResult, ulLength ); + hb_itemPutCLPtr( pInfo, ( char * ) pResult, ulLength ); break; } @@ -5408,7 +5408,7 @@ static ERRCODE hb_dbfRddInfo( LPRDDNODE pRDD, USHORT uiIndex, ULONG ulConnect, P } if( fFree && szTrigger ) - hb_itemPutCPtr( pItem, szTrigger, strlen( szTrigger ) ); + hb_itemPutCPtr2( pItem, szTrigger ); else hb_itemPutC( pItem, szTrigger ); @@ -5430,8 +5430,7 @@ static ERRCODE hb_dbfRddInfo( LPRDDNODE pRDD, USHORT uiIndex, ULONG ulConnect, P } else if( pData->szPendingTrigger ) { - hb_itemPutCPtr( pItem, pData->szPendingTrigger, - strlen( pData->szPendingTrigger ) ); + hb_itemPutCPtr2( pItem, pData->szPendingTrigger ); pData->szPendingTrigger = NULL; } else @@ -5451,7 +5450,7 @@ static ERRCODE hb_dbfRddInfo( LPRDDNODE pRDD, USHORT uiIndex, ULONG ulConnect, P } if( fFree && szPasswd ) - hb_itemPutCPtr( pItem, szPasswd, strlen( szPasswd ) ); + hb_itemPutCPtr2( pItem, szPasswd ); else hb_itemPutC( pItem, szPasswd ); @@ -5473,8 +5472,7 @@ static ERRCODE hb_dbfRddInfo( LPRDDNODE pRDD, USHORT uiIndex, ULONG ulConnect, P } else if( pData->szPendingPasswd ) { - hb_itemPutCPtr( pItem, pData->szPendingPasswd, - strlen( pData->szPendingPasswd ) ); + hb_itemPutCPtr2( pItem, pData->szPendingPasswd ); pData->szPendingPasswd = NULL; } else diff --git a/harbour/source/rdd/dbfcdx/dbfcdx1.c b/harbour/source/rdd/dbfcdx/dbfcdx1.c index fefb54e7c1..ad96a05659 100644 --- a/harbour/source/rdd/dbfcdx/dbfcdx1.c +++ b/harbour/source/rdd/dbfcdx/dbfcdx1.c @@ -684,7 +684,7 @@ static PHB_ITEM hb_cdxKeyGetItem( LPCDXKEY pKey, PHB_ITEM pItem, LPCDXTAG pTag, pVal[ pKey->len ] = '\0'; hb_cdpnTranslate( pVal, pTag->pIndex->pArea->cdPage, hb_cdp_page, pKey->len ); - pItem = hb_itemPutCPtr( pItem, pVal, pKey->len ); + pItem = hb_itemPutCLPtr( pItem, pVal, pKey->len ); } else #else diff --git a/harbour/source/rdd/dbffpt/dbffpt1.c b/harbour/source/rdd/dbffpt/dbffpt1.c index 118358ffb6..dc83305941 100644 --- a/harbour/source/rdd/dbffpt/dbffpt1.c +++ b/harbour/source/rdd/dbffpt/dbffpt1.c @@ -1456,7 +1456,7 @@ static ERRCODE hb_fptReadRawSMTItem( FPTAREAP pArea, PHB_ITEM pItem ) #ifndef HB_CDP_SUPPORT_OFF hb_cdpnTranslate( ( char *) pBuffer, pArea->cdPage, hb_cdp_page, ulLen ); #endif - hb_itemPutCPtr( pItem, ( char *) pBuffer, ulLen ); + hb_itemPutCLPtr( pItem, ( char *) pBuffer, ulLen ); break; case SMT_IT_INT: @@ -2497,7 +2497,7 @@ static ERRCODE hb_fptReadBlobBlock( FPTAREAP pArea, PHB_ITEM pItem, hb_xfree( bBuffer ); return EDBF_READ; } - hb_itemPutCPtr( pItem, ( char * ) bBuffer, ulSize ); + hb_itemPutCLPtr( pItem, ( char * ) bBuffer, ulSize ); } return SUCCESS; } @@ -2652,7 +2652,7 @@ static ERRCODE hb_fptGetMemo( FPTAREAP pArea, USHORT uiIndex, PHB_ITEM pItem, hb_cdpnTranslate( ( char *) pBuffer, pArea->cdPage, hb_cdp_page, ulSize ); #endif pBuffer[ ulSize ] = '\0'; - hb_itemPutCPtr( pItem, ( char * ) pBuffer, ulSize ); + hb_itemPutCLPtr( pItem, ( char * ) pBuffer, ulSize ); hb_itemSetCMemo( pItem ); pBuffer = NULL; } @@ -2664,7 +2664,7 @@ static ERRCODE hb_fptGetMemo( FPTAREAP pArea, USHORT uiIndex, PHB_ITEM pItem, hb_cdpnTranslate( ( char *) pBuffer, pArea->cdPage, hb_cdp_page, ulSize ); #endif pBuffer[ ulSize ] = '\0'; - hb_itemPutCPtr( pItem, ( char * ) pBuffer, ulSize ); + hb_itemPutCLPtr( pItem, ( char * ) pBuffer, ulSize ); hb_itemSetCMemo( pItem ); pBuffer = NULL; } @@ -2744,13 +2744,13 @@ static ERRCODE hb_fptGetMemo( FPTAREAP pArea, USHORT uiIndex, PHB_ITEM pItem, hb_cdpnTranslate( ( char *) pBuffer, pArea->cdPage, hb_cdp_page, ulSize ); #endif pBuffer[ ulSize ] = '\0'; - hb_itemPutCPtr( pItem, ( char * ) pBuffer, ulSize ); + hb_itemPutCLPtr( pItem, ( char * ) pBuffer, ulSize ); hb_itemSetCMemo( pItem ); pBuffer = NULL; break; case FPTIT_PICT: pBuffer[ ulSize ] = '\0'; - hb_itemPutCPtr( pItem, ( char * ) pBuffer, ulSize ); + hb_itemPutCLPtr( pItem, ( char * ) pBuffer, ulSize ); pBuffer = NULL; break; default: @@ -3271,7 +3271,7 @@ static ERRCODE hb_fptGetVarField( FPTAREAP pArea, USHORT uiIndex, PHB_ITEM pItem } else { - hb_itemPutCPtr( pItem, pString, uiType ); + hb_itemPutCLPtr( pItem, pString, uiType ); } } else @@ -4204,7 +4204,7 @@ static ERRCODE hb_fptPutValueFile( FPTAREAP pArea, USHORT uiIndex, BYTE * szFile else { pAlloc[ ulSize ] = '\0'; - pItem = hb_itemPutCPtr( NULL, ( char * ) pAlloc, ulSize ); + pItem = hb_itemPutCLPtr( NULL, ( char * ) pAlloc, ulSize ); uiError = hb_fptPutVarField( pArea, uiIndex, pItem ); hb_itemRelease( pItem ); } diff --git a/harbour/source/rdd/dbfntx/dbfntx1.c b/harbour/source/rdd/dbfntx/dbfntx1.c index a8521d5b8e..1056421389 100644 --- a/harbour/source/rdd/dbfntx/dbfntx1.c +++ b/harbour/source/rdd/dbfntx/dbfntx1.c @@ -477,7 +477,7 @@ static PHB_ITEM hb_ntxKeyGetItem( PHB_ITEM pItem, LPKEYINFO pKey, pVal[ pTag->KeyLength ] = '\0'; hb_cdpnTranslate( pVal, pTag->Owner->Owner->cdPage, hb_cdp_page, pTag->KeyLength ); - pItem = hb_itemPutCPtr( pItem, pVal, pTag->KeyLength ); + pItem = hb_itemPutCLPtr( pItem, pVal, pTag->KeyLength ); } else #else diff --git a/harbour/source/rdd/delim1.c b/harbour/source/rdd/delim1.c index 620f3f3676..a8cfa4a4d6 100644 --- a/harbour/source/rdd/delim1.c +++ b/harbour/source/rdd/delim1.c @@ -559,7 +559,7 @@ static ERRCODE hb_delimGetValue( DELIMAREAP pArea, USHORT uiIndex, PHB_ITEM pIte memcpy( pVal, pArea->pRecord + pArea->pFieldOffset[ uiIndex ], pField->uiLen ); pVal[ pField->uiLen ] = '\0'; hb_cdpnTranslate( pVal, pArea->cdPage, hb_cdp_page, pField->uiLen ); - hb_itemPutCPtr( pItem, pVal, pField->uiLen ); + hb_itemPutCLPtr( pItem, pVal, pField->uiLen ); } else #endif diff --git a/harbour/source/rdd/sdf1.c b/harbour/source/rdd/sdf1.c index 95221e507b..b02904f234 100644 --- a/harbour/source/rdd/sdf1.c +++ b/harbour/source/rdd/sdf1.c @@ -385,7 +385,7 @@ static ERRCODE hb_sdfGetValue( SDFAREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) memcpy( pVal, pArea->pRecord + pArea->pFieldOffset[ uiIndex ], pField->uiLen ); pVal[ pField->uiLen ] = '\0'; hb_cdpnTranslate( pVal, pArea->cdPage, hb_cdp_page, pField->uiLen ); - hb_itemPutCPtr( pItem, pVal, pField->uiLen ); + hb_itemPutCLPtr( pItem, pVal, pField->uiLen ); } else #endif diff --git a/harbour/source/rtl/gtgui/gtgui.c b/harbour/source/rtl/gtgui/gtgui.c index 0631cf3b92..4cd98d1c78 100644 --- a/harbour/source/rtl/gtgui/gtgui.c +++ b/harbour/source/rtl/gtgui/gtgui.c @@ -118,7 +118,7 @@ static BOOL hb_gt_gui_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) if( hb_gt_w32_getClipboard( CF_TEXT, &szClipboardData, &ulLen ) ) { - pInfo->pResult = hb_itemPutCPtr( pInfo->pResult, + pInfo->pResult = hb_itemPutCLPtr( pInfo->pResult, szClipboardData, ulLen ); } else diff --git a/harbour/source/rtl/gtwin/gtwin.c b/harbour/source/rtl/gtwin/gtwin.c index a3346f982d..6318f22c18 100644 --- a/harbour/source/rtl/gtwin/gtwin.c +++ b/harbour/source/rtl/gtwin/gtwin.c @@ -1590,7 +1590,7 @@ static BOOL hb_gt_win_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) dwLen = GetConsoleTitle( buff, sizeof( buff ) / sizeof( TCHAR ) ); szTitle = ( char * ) hb_xgrab( dwLen + 1 ); HB_TCHAR_GETFROM( szTitle, buff, dwLen ); - pInfo->pResult = hb_itemPutCPtr( pInfo->pResult, szTitle, dwLen ); + pInfo->pResult = hb_itemPutCLPtr( pInfo->pResult, szTitle, dwLen ); if( hb_itemType( pInfo->pNewVal ) & HB_IT_STRING ) { LPTSTR lpTitle = HB_TCHAR_CONVTO( hb_itemGetCPtr( pInfo->pNewVal ) ); @@ -1651,7 +1651,7 @@ static BOOL hb_gt_win_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) ULONG ulLen; if( hb_gt_w32_getClipboard( CF_OEMTEXT, &szClipboardData, &ulLen ) ) { - pInfo->pResult = hb_itemPutCPtr( pInfo->pResult, + pInfo->pResult = hb_itemPutCLPtr( pInfo->pResult, szClipboardData, ulLen ); } diff --git a/harbour/source/rtl/gtwvt/gtwvt.c b/harbour/source/rtl/gtwvt/gtwvt.c index 080ff7498b..821000f8a6 100644 --- a/harbour/source/rtl/gtwvt/gtwvt.c +++ b/harbour/source/rtl/gtwvt/gtwvt.c @@ -152,6 +152,10 @@ static void hb_gt_wvt_Free( PHB_GTWVT pWVT ) { --s_wvtCount; s_wvtWindows[pWVT->iHandle] = NULL; + + if( pWVT->wSelectCopy ) + HB_TCHAR_FREE( pWVT->wSelectCopy ); + hb_xfree( pWVT ); } @@ -225,6 +229,7 @@ static PHB_GTWVT hb_gt_wvt_New( PHB_GT pGT ) pWVT->bBeingMarked = FALSE; pWVT->bBeginMarked = FALSE; + pWVT->wSelectCopy = HB_TCHAR_CONVTO( "Mark and Copy" ); pWVT->bSelectCopy = TRUE; pWVT->bResizable = TRUE; pWVT->bClosable = TRUE; @@ -1637,7 +1642,7 @@ static void hb_gt_wvt_Init( PHB_GT pGT, FHANDLE hFilenoStdin, FHANDLE hFilenoStd /* Create "Mark" prompt in SysMenu to allow console type copy operation */ { HMENU hSysMenu = GetSystemMenu( pWVT->hWnd, FALSE ); - AppendMenu( hSysMenu, MF_STRING, SYS_EV_MARK, TEXT( "Mark and Copy" ) ); + AppendMenu( hSysMenu, MF_STRING, SYS_EV_MARK, pWVT->wSelectCopy ); } /* SUPER GT initialization */ @@ -2038,7 +2043,7 @@ static BOOL hb_gt_wvt_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) { char * szTitle = NULL; if( hb_gt_wvt_GetWindowTitle( pWVT->hWnd, &szTitle ) ) - pInfo->pResult = hb_itemPutCPtr( pInfo->pResult, szTitle, strlen( szTitle ) ); + pInfo->pResult = hb_itemPutCPtr2( pInfo->pResult, szTitle ); else pInfo->pResult = hb_itemPutC( pInfo->pResult, NULL ); if( hb_itemType( pInfo->pNewVal ) & HB_IT_STRING ) @@ -2127,7 +2132,7 @@ static BOOL hb_gt_wvt_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) CF_OEMTEXT : CF_TEXT, &szClipboardData, &ulLen ) ) { - pInfo->pResult = hb_itemPutCPtr( pInfo->pResult, + pInfo->pResult = hb_itemPutCLPtr( pInfo->pResult, szClipboardData, ulLen ); } @@ -2197,7 +2202,25 @@ static BOOL hb_gt_wvt_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) case HB_GTI_SELECTCOPY: { pInfo->pResult = hb_itemPutL( pInfo->pResult, pWVT->bSelectCopy ); - if( pInfo->pNewVal ) + + if( hb_itemType( pInfo->pNewVal ) & HB_IT_STRING ) + { + pInfo->pResult = hb_itemPutCPtr2( pInfo->pResult, HB_TCHAR_CONVFROM( pWVT->wSelectCopy ) ); + + if( hb_itemGetCLen( pInfo->pNewVal ) ) + { + HMENU hSysMenu = GetSystemMenu( pWVT->hWnd, FALSE ); + + if( pWVT->wSelectCopy ) + HB_TCHAR_FREE( pWVT->wSelectCopy ); + + pWVT->wSelectCopy = HB_TCHAR_CONVTO( hb_itemGetCPtr( pInfo->pNewVal ) ); + pWVT->bSelectCopy = TRUE; + + ModifyMenu( hSysMenu, SYS_EV_MARK, MF_BYCOMMAND | MF_STRING | MF_ENABLED, SYS_EV_MARK, pWVT->wSelectCopy ); + } + } + else if( pInfo->pNewVal ) { BOOL bNewValue = hb_itemGetL( pInfo->pNewVal ); if( bNewValue != pWVT->bSelectCopy ) diff --git a/harbour/source/rtl/gtwvt/gtwvt.h b/harbour/source/rtl/gtwvt/gtwvt.h index 6f3895a79d..729deec1ac 100644 --- a/harbour/source/rtl/gtwvt/gtwvt.h +++ b/harbour/source/rtl/gtwvt/gtwvt.h @@ -118,7 +118,7 @@ typedef struct USHORT ROWS; /* number of displayable rows in window */ USHORT COLS; /* number of displayable columns in window */ - COLORREF COLORS[16]; /* colors */ + COLORREF COLORS[ 16 ]; /* colors */ BOOL CaretExist; /* TRUE if a caret has been created */ BOOL CaretHidden; /* TRUE if a caret has been hiden */ @@ -160,6 +160,7 @@ typedef struct BOOL bResizable; BOOL bSelectCopy; + LPWSTR wSelectCopy; BOOL bClosable; } HB_GTWVT, * PHB_GTWVT; diff --git a/harbour/source/rtl/hbgtcore.c b/harbour/source/rtl/hbgtcore.c index d3ca256687..84ab025273 100644 --- a/harbour/source/rtl/hbgtcore.c +++ b/harbour/source/rtl/hbgtcore.c @@ -1537,7 +1537,7 @@ static BOOL hb_gt_def_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) ULONG ulLen; if( hb_gt_getClipboard( &pszClipData, &ulLen ) ) - pInfo->pResult = hb_itemPutCPtr( pInfo->pResult, pszClipData, ulLen ); + pInfo->pResult = hb_itemPutCLPtr( pInfo->pResult, pszClipData, ulLen ); else pInfo->pResult = hb_itemPutC( pInfo->pResult, NULL ); } diff --git a/harbour/source/vm/arrays.c b/harbour/source/vm/arrays.c index 8f9b332513..70d2e72d96 100644 --- a/harbour/source/vm/arrays.c +++ b/harbour/source/vm/arrays.c @@ -747,7 +747,7 @@ HB_EXPORT BOOL hb_arraySetCPtr( PHB_ITEM pArray, ULONG ulIndex, char * szText, U if( HB_IS_ARRAY( pArray ) && ulIndex > 0 && ulIndex <= pArray->item.asArray.value->ulLen ) { - hb_itemPutCPtr( pArray->item.asArray.value->pItems + ulIndex - 1, szText, ulLen ); + hb_itemPutCLPtr( pArray->item.asArray.value->pItems + ulIndex - 1, szText, ulLen ); return TRUE; } else diff --git a/harbour/source/vm/debug.c b/harbour/source/vm/debug.c index f3f4e07f3d..c3b7520e3b 100644 --- a/harbour/source/vm/debug.c +++ b/harbour/source/vm/debug.c @@ -75,7 +75,7 @@ static void AddToArray( PHB_ITEM pItem, PHB_ITEM pReturn, ULONG ulPos ) char * szBuff = ( char * ) hb_xgrab( ulLen + 1 ); snprintf( szBuff, ulLen + 1, "[%s]", pItem->item.asSymbol.value->szName ); - hb_itemPutCPtr( pArrayItem, szBuff, ulLen ); + hb_itemPutCLPtr( pArrayItem, szBuff, ulLen ); } } else /* Normal types */ diff --git a/harbour/source/vm/extend.c b/harbour/source/vm/extend.c index b4d4c641e0..fefc7480fd 100644 --- a/harbour/source/vm/extend.c +++ b/harbour/source/vm/extend.c @@ -747,7 +747,7 @@ HB_EXPORT void hb_retc_buffer( char * szText ) { HB_TRACE(HB_TR_DEBUG, ("hb_retc_buffer(%s)", szText)); - hb_itemPutCPtr( hb_stackReturnItem(), szText, strlen( szText ) ); + hb_itemPutCPtr2( hb_stackReturnItem(), szText ); } #undef hb_retc_const @@ -771,7 +771,7 @@ HB_EXPORT void hb_retclen_buffer( char * szText, ULONG ulLen ) { HB_TRACE(HB_TR_DEBUG, ("hb_retclen_buffer(%s, %lu)", szText, ulLen)); - hb_itemPutCPtr( hb_stackReturnItem(), szText, ulLen ); + hb_itemPutCLPtr( hb_stackReturnItem(), szText, ulLen ); } /* szDate must have YYYYMMDD format */ @@ -1002,7 +1002,7 @@ HB_EXPORT int hb_storclen_buffer( char * szText, ULONG ulLen, int iParam, ... ) } else if( bByRef || iParam == -1 ) { - hb_itemPutCPtr( pItem, szText, ulLen ); + hb_itemPutCLPtr( pItem, szText, ulLen ); return 1; } } diff --git a/harbour/source/vm/hvm.c b/harbour/source/vm/hvm.c index ff4451d18e..51cef8f4a5 100644 --- a/harbour/source/vm/hvm.c +++ b/harbour/source/vm/hvm.c @@ -1512,7 +1512,7 @@ HB_EXPORT void hb_vmExecute( const BYTE * pCode, PHB_SYMB pSymbols ) { ULONG ulSize = ( ULONG ) HB_PCODE_MKUSHORT( &pCode[ w + 2 ] ); char * szText = hb_compDecodeString( pCode[ w + 1 ], ( char * ) pCode + w + 4, &ulSize ); - hb_itemPutCPtr( hb_stackAllocItem(), szText, ulSize ); + hb_itemPutCLPtr( hb_stackAllocItem(), szText, ulSize ); w += ( 4 + ulSize ); break; } diff --git a/harbour/source/vm/itemapi.c b/harbour/source/vm/itemapi.c index a6b9c5cf73..046c85ea4e 100644 --- a/harbour/source/vm/itemapi.c +++ b/harbour/source/vm/itemapi.c @@ -346,9 +346,54 @@ HB_EXPORT PHB_ITEM hb_itemPutCLConst( PHB_ITEM pItem, const char * szText, ULONG return pItem; } +HB_EXPORT PHB_ITEM hb_itemPutCPtr2( PHB_ITEM pItem, char * szText ) +{ + ULONG ulLen; + + HB_TRACE(HB_TR_DEBUG, ("hb_itemPutCPtr2(%p, %s)", pItem, szText)); + + if( pItem ) + { + if( HB_IS_COMPLEX( pItem ) ) + hb_itemClear( pItem ); + } + else + pItem = hb_itemNew( NULL ); + + ulLen = szText ? strlen( szText ) : 0; + + pItem->type = HB_IT_STRING; + pItem->item.asString.length = ulLen; + if( ulLen == 0 ) + { + pItem->item.asString.allocated = 0; + pItem->item.asString.value = ""; + hb_xfree( szText ); + } + else if( ulLen == 1 ) + { + pItem->item.asString.allocated = 0; + pItem->item.asString.value = ( char * ) hb_szAscii[ (unsigned char) ( szText[0] ) ]; + hb_xfree( szText ); + } + else + { + szText[ ulLen ] = '\0'; + pItem->item.asString.allocated = ulLen + 1; + pItem->item.asString.value = szText; + } + + return pItem; +} + HB_EXPORT PHB_ITEM hb_itemPutCPtr( PHB_ITEM pItem, char * szText, ULONG ulLen ) { - HB_TRACE(HB_TR_DEBUG, ("hb_itemPutCPtr(%p, %s, %lu)", pItem, szText, ulLen)); + return hb_itemPutCLPtr( pItem, szText, ulLen ); +} + +HB_EXPORT PHB_ITEM hb_itemPutCLPtr( PHB_ITEM pItem, char * szText, ULONG ulLen ) +{ + HB_TRACE(HB_TR_DEBUG, ("hb_itemPutCLPtr(%p, %s, %lu)", pItem, szText, ulLen)); if( pItem ) { @@ -2521,7 +2566,7 @@ HB_EXPORT PHB_ITEM hb_itemValToStr( PHB_ITEM pItem ) buffer = hb_itemString( pItem, &ulLen, &bFreeReq ); if( bFreeReq ) - pResult = hb_itemPutCPtr( NULL, buffer, ulLen ); + pResult = hb_itemPutCLPtr( NULL, buffer, ulLen ); else pResult = hb_itemPutCL( NULL, buffer, ulLen ); diff --git a/harbour/source/vm/macro.c b/harbour/source/vm/macro.c index 9115b99d26..b516a0ce8c 100644 --- a/harbour/source/vm/macro.c +++ b/harbour/source/vm/macro.c @@ -792,7 +792,7 @@ void hb_macroTextValue( HB_ITEM_PTR pItem ) { /* replace the old value on the eval stack with the new one */ - hb_itemPutCPtr( pItem, szString, ulLength ); + hb_itemPutCLPtr( pItem, szString, ulLength ); } /* * else diff --git a/harbour/tests/wvtext.prg b/harbour/tests/wvtext.prg index 7f5405ac05..a6ffc78df9 100644 --- a/harbour/tests/wvtext.prg +++ b/harbour/tests/wvtext.prg @@ -73,6 +73,9 @@ FUNCTION Main() CASE nKey == K_F7 SetPaletteIndex() + CASE nKey == K_F8 + Alert( "Menu text changed. Was: " + hb_GtInfo( HB_GTI_SELECTCOPY, DToS(Date()) + " " + Time() ) ) + ENDCASE ENDDO @@ -122,6 +125,7 @@ STATIC FUNCTION DispScreen() DispOutAt( ++nRow, nCol, '< F5 Palette L Repeat >', cColor ) DispOutAt( ++nRow, nCol, '< F6 Palette D Repeat >', cColor ) DispOutAt( ++nRow, nCol, '< F7 Palette By Index R >', cColor ) + DispOutAt( ++nRow, nCol, '< F8 MarkCopy menu text >', cColor ) DispOutAt( ++nRow, nCol, '< Click Other Window >', cColor ) DispOutAt( ++nRow, nCol, '< Click X Button >', cColor )