2012-04-24 08:43 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)

* harbour/src/rtl/inkey.c
    * modified HB_KEYPUT() and HB_KEYINS() to convert strings
      into key codes instead of passing them directly to keyboard
      buffer like in __KEYBOARD() function.

  * harbour/include/hbgtcore.h
  * harbour/src/rtl/hbgtcore.c
    * modified hb_inkeySetText() (PRG __KEYBOARD() function) to translate
      passed string into unicode values
      This modification affects also HB_GTI_CLIPBOARDPASTE
This commit is contained in:
Przemyslaw Czerpak
2012-04-24 06:43:44 +00:00
parent 8d23393d83
commit bc5cfa6b3c
4 changed files with 72 additions and 13 deletions

View File

@@ -16,6 +16,18 @@
The license applies to all entries newer than 2009-04-28.
*/
2012-04-24 08:43 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
* harbour/src/rtl/inkey.c
* modified HB_KEYPUT() and HB_KEYINS() to convert strings
into key codes instead of passing them directly to keyboard
buffer like in __KEYBOARD() function.
* harbour/include/hbgtcore.h
* harbour/src/rtl/hbgtcore.c
* modified hb_inkeySetText() (PRG __KEYBOARD() function) to translate
passed string into unicode values
This modification affects also HB_GTI_CLIPBOARDPASTE
2012-04-24 07:18 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
* harbour/include/hbgtcore.h
! fixed typo in HB_GTSELF_KEYTRANS() macro.

View File

@@ -337,7 +337,7 @@ typedef struct _HB_GT_BASE
int inkeyTail;
int iLastPut;
int inkeyLast;
HB_BYTE * StrBuffer;
HB_WCHAR * StrBuffer;
HB_SIZE StrBufferSize;
HB_SIZE StrBufferPos;

View File

@@ -2743,6 +2743,12 @@ static HB_BOOL hb_gt_def_InkeyNextCheck( PHB_GT pGT, int iEventMask, int * iKey
if( pGT->StrBuffer )
{
*iKey = pGT->StrBuffer[ pGT->StrBufferPos ];
if( *iKey >= 128 )
{
*iKey = HB_INKEY_NEW_UNICODE( *iKey );
if( ( iEventMask & HB_INKEY_EXT ) == 0 )
*iKey = hb_inkeyKeyStd( *iKey );
}
}
else if( pGT->inkeyHead != pGT->inkeyTail )
{
@@ -2922,16 +2928,20 @@ static void hb_gt_def_InkeySetText( PHB_GT pGT, const char * szText, HB_SIZE nLe
if( szText && nLen )
{
pGT->StrBuffer = ( HB_BYTE * ) hb_xgrab( nLen );
memcpy( pGT->StrBuffer, szText, nLen );
pGT->StrBufferSize = nLen;
pGT->StrBufferPos = 0;
do
PHB_CODEPAGE cdp = hb_vmCDP();
HB_SIZE nIndex = 0;
HB_WCHAR wc;
pGT->StrBufferSize = pGT->StrBufferPos = 0;
pGT->StrBuffer = ( HB_WCHAR * ) hb_xgrab( nLen * sizeof( HB_WCHAR ) );
while( HB_CDPCHAR_GET( cdp, szText, nLen, &nIndex, &wc ) )
pGT->StrBuffer[ pGT->StrBufferSize++ ] = wc == ';' ? HB_CHAR_CR : wc;
if( pGT->StrBufferSize == 0 )
{
if( pGT->StrBuffer[ --nLen ] == ';' )
pGT->StrBuffer[ nLen ] = HB_CHAR_CR;
hb_xfree( pGT->StrBuffer );
pGT->StrBuffer = NULL;
}
while( nLen );
}
}

View File

@@ -65,12 +65,47 @@
*/
#include "hbapigt.h"
#include "hbgtcore.h"
#include "hbapiitm.h"
#include "hbapicdp.h"
#include "hbset.h"
#include "hbstack.h"
#include "hbvm.h"
static void hb_inkeySetTextKeys( const char * pszText, HB_SIZE nSize, HB_BOOL fInsert )
{
PHB_CODEPAGE cdp = hb_vmCDP();
HB_SIZE nIndex = 0;
HB_WCHAR wc;
if( fInsert )
{
HB_WCHAR buffer[ 32 ], * keys;
HB_SIZE n = 0;
keys = nSize <= HB_SIZEOFARRAY( buffer ) ? buffer :
( HB_WCHAR * ) hb_xgrab( nSize * sizeof( HB_WCHAR ) );
while( HB_CDPCHAR_GET( cdp, pszText, nSize, &nIndex, &wc ) )
keys[ n++ ] = wc;
while( n-- )
{
int iKey = keys[ n ] >= 128 ? HB_INKEY_NEW_UNICODE( keys[ n ] ) : keys[ n ];
hb_inkeyIns( iKey );
}
if( nSize > HB_SIZEOFARRAY( buffer ) )
hb_xfree( keys );
}
else
{
while( HB_CDPCHAR_GET( cdp, pszText, nSize, &nIndex, &wc ) )
{
int iKey = wc >= 128 ? HB_INKEY_NEW_UNICODE( wc ) : wc;
hb_inkeyPut( iKey );
}
}
}
HB_FUNC( INKEY )
{
int iPCount = hb_pcount();
@@ -101,7 +136,7 @@ HB_FUNC( HB_KEYPUT )
}
else if( HB_ISCHAR( 1 ) )
{
hb_inkeySetText( hb_parc( 1 ), hb_parclen( 1 ) );
hb_inkeySetTextKeys( hb_parc( 1 ), hb_parclen( 1 ), HB_FALSE );
}
else if( HB_ISARRAY( 1 ) )
{
@@ -119,7 +154,8 @@ HB_FUNC( HB_KEYPUT )
}
else if( type & HB_IT_STRING )
{
hb_inkeySetText( hb_arrayGetCPtr( pArray, nIndex ), hb_arrayGetCLen( pArray, nIndex ) );
hb_inkeySetTextKeys( hb_arrayGetCPtr( pArray, nIndex ),
hb_arrayGetCLen( pArray, nIndex ), HB_FALSE );
}
}
}
@@ -133,7 +169,7 @@ HB_FUNC( HB_KEYINS )
}
else if( HB_ISCHAR( 1 ) )
{
hb_inkeySetText( hb_parc( 1 ), hb_parclen( 1 ) );
hb_inkeySetTextKeys( hb_parc( 1 ), hb_parclen( 1 ), HB_TRUE );
}
else if( HB_ISARRAY( 1 ) )
{
@@ -151,7 +187,8 @@ HB_FUNC( HB_KEYINS )
}
else if( type & HB_IT_STRING )
{
hb_inkeySetText( hb_arrayGetCPtr( pArray, nIndex ), hb_arrayGetCLen( pArray, nIndex ) );
hb_inkeySetTextKeys( hb_arrayGetCPtr( pArray, nIndex ),
hb_arrayGetCLen( pArray, nIndex ), HB_TRUE );
}
}
}