From beab897d85931d9868fc582eba419b93b99ce595 Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Fri, 8 Aug 2008 00:19:01 +0000 Subject: [PATCH] 2008-08-08 02:18 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/make_deb.sh * harbour/make_tgz.sh * harbour/make_rpm.sh * harbour/make_rpmce.sh * harbour/make_rpmw32.sh * harbour/bin/pack_src.sh * force using BASH in all files which includes hb-func.sh * harbour/include/hbgtcore.h * harbour/include/hbapigt.h * harbour/include/hbextern.ch * harbour/source/rtl/hbgtcore.c * harbour/source/rtl/inkeyapi.c * harbour/source/rtl/inkey.c + added HB_KEYINS() which works like HB_KEYPUT() but numeric key values puts at the beginning of keyboard buffer. It does not clear keyboard buffer contents. --- harbour/ChangeLog | 19 +++++++++++++++++ harbour/bin/pack_src.sh | 1 + harbour/include/hbapigt.h | 1 + harbour/include/hbextern.ch | 1 + harbour/include/hbgtcore.h | 3 +++ harbour/make_deb.sh | 1 + harbour/make_rpm.sh | 1 + harbour/make_rpmce.sh | 1 + harbour/make_rpmw32.sh | 1 + harbour/make_tgz.sh | 2 ++ harbour/source/rtl/hbgtcore.c | 40 +++++++++++++++++++++++++++-------- harbour/source/rtl/inkey.c | 32 ++++++++++++++++++++++++++++ harbour/source/rtl/inkeyapi.c | 11 ++++++++++ 13 files changed, 105 insertions(+), 9 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 93438726f1..1628f694cc 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,25 @@ 2008-12-31 13:59 UTC+0100 Foo Bar */ +2008-08-08 02:18 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/make_deb.sh + * harbour/make_tgz.sh + * harbour/make_rpm.sh + * harbour/make_rpmce.sh + * harbour/make_rpmw32.sh + * harbour/bin/pack_src.sh + * force using BASH in all files which includes hb-func.sh + + * harbour/include/hbgtcore.h + * harbour/include/hbapigt.h + * harbour/include/hbextern.ch + * harbour/source/rtl/hbgtcore.c + * harbour/source/rtl/inkeyapi.c + * harbour/source/rtl/inkey.c + + added HB_KEYINS() which works like HB_KEYPUT() but numeric + key values puts at the beginning of keyboard buffer. + It does not clear keyboard buffer contents. + 2008-08-07 17:20 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) * harbour/source/rtl/achoice.prg - Removed K_MOUSEMOVE functionality. diff --git a/harbour/bin/pack_src.sh b/harbour/bin/pack_src.sh index 6ab3d5a5d4..ef6669b104 100755 --- a/harbour/bin/pack_src.sh +++ b/harbour/bin/pack_src.sh @@ -1,4 +1,5 @@ #!/bin/sh +[ "$BASH" ] || exec bash `which $0` ${1+"$@"} # # $Id$ # diff --git a/harbour/include/hbapigt.h b/harbour/include/hbapigt.h index 300efca69e..9773d10f8f 100644 --- a/harbour/include/hbapigt.h +++ b/harbour/include/hbapigt.h @@ -272,6 +272,7 @@ extern HB_EXPORT ERRCODE hb_gtSetBorder( HB_GT_RGB * color ); /* Harbour keyboard support functions */ extern HB_EXPORT int hb_inkey( BOOL bWait, double dSeconds, int iEvenMask ); /* Wait for keyboard input */ extern HB_EXPORT void hb_inkeyPut( int ch ); /* Inserts an inkey code into the keyboard buffer */ +extern HB_EXPORT void hb_inkeyIns( int ch ); /* Inserts an inkey code into the keyboard buffer */ extern HB_EXPORT int hb_inkeyLast( int iEvenMask ); /* Return the value of the last key that was extracted */ extern HB_EXPORT int hb_inkeyNext( int iEvenMask ); /* Return the next key without extracting it */ extern HB_EXPORT void hb_inkeyPoll( void ); /* Poll the console keyboard to stuff the Harbour buffer */ diff --git a/harbour/include/hbextern.ch b/harbour/include/hbextern.ch index 5f1560f3a3..81b877fc6e 100644 --- a/harbour/include/hbextern.ch +++ b/harbour/include/hbextern.ch @@ -1049,6 +1049,7 @@ EXTERNAL HB_FCOMMIT EXTERNAL HB_FTEMPCREATE EXTERNAL HB_GCALL EXTERNAL HB_KEYPUT +EXTERNAL HB_KEYINS EXTERNAL HB_OEMTOANSI EXTERNAL HB_OSERROR EXTERNAL HB_OSDRIVESEPARATOR diff --git a/harbour/include/hbgtcore.h b/harbour/include/hbgtcore.h index f8e2921937..4999fbb046 100644 --- a/harbour/include/hbgtcore.h +++ b/harbour/include/hbgtcore.h @@ -202,6 +202,7 @@ typedef struct int (* InkeyGet) ( HB_GT_PTR, BOOL fWait, double dSeconds, int iEventMask ); void (* InkeyPut) ( HB_GT_PTR, int iKey ); + void (* InkeyIns) ( HB_GT_PTR, int iKey ); int (* InkeyLast) ( HB_GT_PTR, int iEventMask ); int (* InkeyNext) ( HB_GT_PTR, int iEventMask ); void (* InkeyPoll) ( HB_GT_PTR ); @@ -437,6 +438,7 @@ extern PHB_GT hb_gt_Base( void ); #define HB_GTSELF_READKEY(g,m) (g)->pFuncTable->ReadKey(g,m) #define HB_GTSELF_INKEYGET(g,w,d,m) (g)->pFuncTable->InkeyGet(g,w,d,m) #define HB_GTSELF_INKEYPUT(g,k) (g)->pFuncTable->InkeyPut(g,k) +#define HB_GTSELF_INKEYINS(g,k) (g)->pFuncTable->InkeyIns(g,k) #define HB_GTSELF_INKEYLAST(g,m) (g)->pFuncTable->InkeyLast(g,m) #define HB_GTSELF_INKEYNEXT(g,m) (g)->pFuncTable->InkeyNext(g,m) #define HB_GTSELF_INKEYPOLL(g) (g)->pFuncTable->InkeyPoll(g) @@ -551,6 +553,7 @@ extern PHB_GT hb_gt_Base( void ); #define HB_GTSUPER_READKEY(g,m) (HB_GTSUPER)->ReadKey(g,m) #define HB_GTSUPER_INKEYGET(g,w,d,m) (HB_GTSUPER)->InkeyGet(g,w,d,m) #define HB_GTSUPER_INKEYPUT(g,k) (HB_GTSUPER)->InkeyPut(g,k) +#define HB_GTSUPER_INKEYINS(g,k) (HB_GTSUPER)->InkeyIns(g,k) #define HB_GTSUPER_INKEYLAST(g,m) (HB_GTSUPER)->InkeyLast(g,m) #define HB_GTSUPER_INKEYNEXT(g,m) (HB_GTSUPER)->InkeyNext(g,m) #define HB_GTSUPER_INKEYPOLL(g) (HB_GTSUPER)->InkeyPoll(g) diff --git a/harbour/make_deb.sh b/harbour/make_deb.sh index bf88c3dbcf..705e243b08 100755 --- a/harbour/make_deb.sh +++ b/harbour/make_deb.sh @@ -1,4 +1,5 @@ #!/bin/sh +[ "$BASH" ] || exec bash `which $0` ${1+"$@"} # # $Id$ # diff --git a/harbour/make_rpm.sh b/harbour/make_rpm.sh index f7c0920cfb..476371c1d8 100755 --- a/harbour/make_rpm.sh +++ b/harbour/make_rpm.sh @@ -1,4 +1,5 @@ #!/bin/sh +[ "$BASH" ] || exec bash `which $0` ${1+"$@"} # # $Id$ # diff --git a/harbour/make_rpmce.sh b/harbour/make_rpmce.sh index 424a012e86..6e107cadde 100755 --- a/harbour/make_rpmce.sh +++ b/harbour/make_rpmce.sh @@ -1,4 +1,5 @@ #!/bin/sh +[ "$BASH" ] || exec bash `which $0` ${1+"$@"} # # $Id$ # diff --git a/harbour/make_rpmw32.sh b/harbour/make_rpmw32.sh index f0f0bfebf4..18f0a2f52a 100755 --- a/harbour/make_rpmw32.sh +++ b/harbour/make_rpmw32.sh @@ -1,4 +1,5 @@ #!/bin/sh +[ "$BASH" ] || exec bash `which $0` ${1+"$@"} # # $Id$ # diff --git a/harbour/make_tgz.sh b/harbour/make_tgz.sh index abbd0be22b..27671523f7 100755 --- a/harbour/make_tgz.sh +++ b/harbour/make_tgz.sh @@ -1,4 +1,5 @@ #!/bin/sh +[ "$BASH" ] || exec bash `which $0` ${1+"$@"} # # $Id$ # @@ -308,6 +309,7 @@ if [ -n "${hb_instfile}" ]; then # if $TAR exists in the installation environment cat > "${hb_instfile}" < "${hb_archfile}" exit diff --git a/harbour/source/rtl/hbgtcore.c b/harbour/source/rtl/hbgtcore.c index d46dea4453..b260437fdf 100644 --- a/harbour/source/rtl/hbgtcore.c +++ b/harbour/source/rtl/hbgtcore.c @@ -2243,6 +2243,26 @@ static void hb_gt_def_InkeyPut( PHB_GT pGT, int iKey ) pGT->inkeyHead = iHead; } +/* Inset the key into head of keyboard buffer */ +static void hb_gt_def_InkeyIns( PHB_GT pGT, int iKey ) +{ + HB_TRACE(HB_TR_DEBUG, ("hb_gt_def_InkeyIns(%p,%d)", pGT, iKey)); + + if( --pGT->inkeyTail < 0 ) + pGT->inkeyTail = pGT->inkeyBufferSize -1; + + pGT->inkeyBuffer[ pGT->inkeyTail ] = iKey; + + /* When the buffer is full new event overwrite the last one + * in the buffer. [druzus] + */ + if( pGT->inkeyHead == pGT->inkeyTail ) + { + if( --pGT->inkeyHead < 0 ) + pGT->inkeyHead = pGT->inkeyBufferSize -1; + } +} + /* helper internal function */ static BOOL hb_gt_def_InkeyNextCheck( PHB_GT pGT, int iEventMask, int * iKey ) { @@ -2836,15 +2856,16 @@ static HB_GT_FUNCS s_gtCoreFunc = SetDispCP : hb_gt_def_SetDispCP , SetKeyCP : hb_gt_def_SetKeyCP , ReadKey : hb_gt_def_ReadKey , - InkeyGet : hb_gt_def_InkeyGet , - InkeyPut : hb_gt_def_InkeyPut , - InkeyLast : hb_gt_def_InkeyLast , - InkeyNext : hb_gt_def_InkeyNext , - InkeyPoll : hb_gt_def_InkeyPoll , - InkeySetText : hb_gt_def_InkeySetText , - InkeySetLast : hb_gt_def_InkeySetLast , - InkeyReset : hb_gt_def_InkeyReset , - InkeyExit : hb_gt_def_InkeyExit , + InkeyGet : hb_gt_def_InkeyGet , + InkeyPut : hb_gt_def_InkeyPut , + InkeyIns : hb_gt_def_InkeyIns , + InkeyLast : hb_gt_def_InkeyLast , + InkeyNext : hb_gt_def_InkeyNext , + InkeyPoll : hb_gt_def_InkeyPoll , + InkeySetText : hb_gt_def_InkeySetText , + InkeySetLast : hb_gt_def_InkeySetLast , + InkeyReset : hb_gt_def_InkeyReset , + InkeyExit : hb_gt_def_InkeyExit , MouseInit : hb_gt_def_MouseInit , MouseExit : hb_gt_def_MouseExit , MouseIsPresent : hb_gt_def_MouseIsPresent , @@ -2955,6 +2976,7 @@ static HB_GT_FUNCS s_gtCoreFunc = hb_gt_def_ReadKey , hb_gt_def_InkeyGet , hb_gt_def_InkeyPut , + hb_gt_def_InkeyIns , hb_gt_def_InkeyLast , hb_gt_def_InkeyNext , hb_gt_def_InkeyPoll , diff --git a/harbour/source/rtl/inkey.c b/harbour/source/rtl/inkey.c index 80a9e90571..53738eb27b 100644 --- a/harbour/source/rtl/inkey.c +++ b/harbour/source/rtl/inkey.c @@ -224,6 +224,38 @@ HB_FUNC( HB_KEYPUT ) } } +HB_FUNC( HB_KEYINS ) +{ + if( ISNUM( 1 ) ) + { + hb_inkeyIns( hb_parni( 1 ) ); + } + else if( ISCHAR( 1 ) ) + { + hb_inkeySetText( hb_parc( 1 ), hb_parclen( 1 ) ); + } + else if( ISARRAY( 1 ) ) + { + PHB_ITEM pArray = hb_param( 1, HB_IT_ARRAY ); + ULONG ulIndex; + ULONG ulElements = hb_arrayLen( pArray ); + + for( ulIndex = 1; ulIndex <= ulElements; ulIndex++ ) + { + PHB_ITEM pItem = hb_arrayGetItemPtr( pArray, ulIndex ); + + if( HB_IS_NUMBER( pItem ) ) + { + hb_inkeyIns( hb_itemGetNI( pItem ) ); + } + else if( HB_IS_STRING( pItem ) ) + { + hb_inkeySetText( ( const char * ) hb_itemGetCPtr( pItem ), hb_itemGetCLen( pItem ) ); + } + } + } +} + HB_FUNC( NEXTKEY ) { hb_retni( hb_inkeyNext( ISNUM( 1 ) ? hb_parni( 1 ) : hb_set.HB_SET_EVENTMASK ) ); diff --git a/harbour/source/rtl/inkeyapi.c b/harbour/source/rtl/inkeyapi.c index aefc79c211..d28699a0e3 100644 --- a/harbour/source/rtl/inkeyapi.c +++ b/harbour/source/rtl/inkeyapi.c @@ -73,6 +73,17 @@ HB_EXPORT void hb_inkeyPut( int iKey ) HB_GTSELF_INKEYPUT( pGT, iKey ); } +HB_EXPORT void hb_inkeyIns( int iKey ) +{ + PHB_GT pGT; + + HB_TRACE(HB_TR_DEBUG, ("hb_inkeyIns(%d)", iKey)); + + pGT = hb_gt_Base(); + if( pGT ) + HB_GTSELF_INKEYINS( pGT, iKey ); +} + HB_EXPORT int hb_inkeyLast( int iEventMask ) { PHB_GT pGT;