From 9787ada7e755be634922a406e9c82389bd4154e0 Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Tue, 21 Feb 2012 22:40:33 +0000 Subject: [PATCH] 2012-02-21 23:40 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * harbour/contrib/hbct/ctwin.c * harbour/contrib/hbct/ctwin.h * harbour/contrib/hbct/ctwfunc.c * modified CTWLASTKEY() to set optionaly last key value TODO: finish support for KEYREAD()/KEYSEND() --- harbour/ChangeLog | 7 +++++++ harbour/contrib/hbct/ctwfunc.c | 8 +++++++- harbour/contrib/hbct/ctwin.c | 6 ++++-- harbour/contrib/hbct/ctwin.h | 2 +- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 19fcf17983..252fd46169 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,13 @@ The license applies to all entries newer than 2009-04-28. */ +2012-02-21 23:40 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) + * harbour/contrib/hbct/ctwin.c + * harbour/contrib/hbct/ctwin.h + * harbour/contrib/hbct/ctwfunc.c + * modified CTWLASTKEY() to set optionaly last key value + TODO: finish support for KEYREAD()/KEYSEND() + 2012-02-21 12:31 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * harbour/src/3rd/zlib/zutil.h * removed not longer necessary workaround for fdopen(), diff --git a/harbour/contrib/hbct/ctwfunc.c b/harbour/contrib/hbct/ctwfunc.c index 7360ff3539..5bbd8558ea 100644 --- a/harbour/contrib/hbct/ctwfunc.c +++ b/harbour/contrib/hbct/ctwfunc.c @@ -333,7 +333,13 @@ HB_FUNC( WMOVE ) HB_FUNC( CTWLASTKEY ) { - hb_retni( hb_ctwLastKey() ); + if( HB_ISNUM( 1 ) ) + { + int iNewKey = hb_parni( 1 ); + hb_retni( hb_ctwLastKey( &iNewKey ) ); + } + else + hb_retni( hb_ctwLastKey( NULL ) ); } /* NOTE: These two functions are emulating the MaxRow()/MaxCol() core functions diff --git a/harbour/contrib/hbct/ctwin.c b/harbour/contrib/hbct/ctwin.c index 4c5fda012e..0024455eb6 100644 --- a/harbour/contrib/hbct/ctwin.c +++ b/harbour/contrib/hbct/ctwin.c @@ -2464,18 +2464,20 @@ int hb_ctwGetPosWindow( int iRow, int iCol ) return iResult; } -int hb_ctwLastKey( void ) +int hb_ctwLastKey( int * piNewKey ) { /* keyread() in CT3 uses 64512 bytes length buffer * when it reach this limit and new key is added the * buffer size is decreased by 1024 to 63488 bytes * before adding key. TODO: check if buffer is shifted */ - int iResult = -1; + int iResult = 0; PHB_GTCTW pCTW = hb_ctw_base(); if( pCTW ) { iResult = pCTW->iLastKey; + if( piNewKey ) + pCTW->iLastKey = * piNewKey; hb_gt_BaseFree( pCTW->pGT ); } return iResult; diff --git a/harbour/contrib/hbct/ctwin.h b/harbour/contrib/hbct/ctwin.h index 1993fdb037..5a2c8b3add 100644 --- a/harbour/contrib/hbct/ctwin.h +++ b/harbour/contrib/hbct/ctwin.h @@ -92,7 +92,7 @@ extern HB_EXPORT int hb_ctwCenterWindow( int iWindow, HB_BOOL fCenter ); extern HB_EXPORT int hb_ctwAddWindowBox( int iWindow, const char * szBox, int iColor ); extern HB_EXPORT int hb_ctwSwapWindows( int iWindow1, int iWindow2 ); extern HB_EXPORT int hb_ctwGetPosWindow( int iRow, int iCol ); -extern HB_EXPORT int hb_ctwLastKey( void ); +extern HB_EXPORT int hb_ctwLastKey( int * piNewKey ); HB_EXTERN_END