From 507ea35468425238e27d35ad1278ed3c0f1ddaae Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Sat, 17 Jan 2009 02:35:29 +0000 Subject: [PATCH] 2009-01-17 03:39 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/include/hbgtcore.h * harbour/source/rtl/hbgtcore.c + added two new methods: TOUCHLINE() - marks line as modified REDRAWDIFF() - it contains REFRESH() from which is now called so it's possible to overload this method by upper level RDDs without touching REFRESH() method which can be overloaded by intermediate RDDs * harbour/contrib/hbct/ctwin.c % do not use EXPOSEAREA() and TOUCHCELL() methods but TOUCHLINE() only and overloaded REDRAWDIFF() - it should gives noticeable speed improvement in some where cost of screen update is very big and GT does not calculate minimal update area. * harbour/source/rdd/dbfnsx/dbfnsx1.c % minor speed improvement in key decoding --- harbour/ChangeLog | 19 ++++ harbour/contrib/hbct/ctwin.c | 154 ++++++++++++++++++++-------- harbour/include/hbgtcore.h | 25 ++--- harbour/source/rdd/dbfnsx/dbfnsx1.c | 46 ++++++--- harbour/source/rtl/hbgtcore.c | 20 +++- 5 files changed, 190 insertions(+), 74 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index b22c3b74fc..4659be74bf 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,25 @@ 2008-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org) */ +2009-01-17 03:39 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/include/hbgtcore.h + * harbour/source/rtl/hbgtcore.c + + added two new methods: + TOUCHLINE() - marks line as modified + REDRAWDIFF() - it contains REFRESH() from which is now called so + it's possible to overload this method by upper level RDDs without + touching REFRESH() method which can be overloaded by intermediate + RDDs + + * harbour/contrib/hbct/ctwin.c + % do not use EXPOSEAREA() and TOUCHCELL() methods but TOUCHLINE() + only and overloaded REDRAWDIFF() - it should gives noticeable + speed improvement in some where cost of screen update is very + big and GT does not calculate minimal update area. + + * harbour/source/rdd/dbfnsx/dbfnsx1.c + % minor speed improvement in key decoding + 2009-01-16 22:05 UTC+0100 Francesco Saverio Giudice (info/at/fsgiudice.com) * harbour/source/rdd/usrrdd/rdds/logrdd.prg - removed sample at end of file diff --git a/harbour/contrib/hbct/ctwin.c b/harbour/contrib/hbct/ctwin.c index 477477a95a..0daf4e64db 100644 --- a/harbour/contrib/hbct/ctwin.c +++ b/harbour/contrib/hbct/ctwin.c @@ -194,6 +194,17 @@ static void hb_ctw_ClearMap( PHB_GTCTW pCTW ) memset( pCTW->pShadowMap, 0, ulSize ); } +static void hb_ctw_TouchLines( PHB_GTCTW pCTW, int iFrom, int iTo ) +{ + HB_TRACE(HB_TR_DEBUG, ("hb_ctw_TouchLines(%p,%d,%d)", pCTW, iFrom, iTo)); + + while( iFrom <= iTo ) + { + HB_GTSELF_TOUCHLINE( pCTW->pGT, iFrom ); + ++iFrom; + } +} + static void hb_ctw_WindowMap( PHB_GTCTW pCTW, int iWindow, BOOL fExpose ) { PHB_CT_WND pWnd; @@ -227,25 +238,22 @@ static void hb_ctw_WindowMap( PHB_GTCTW pCTW, int iWindow, BOOL fExpose ) iLastRow - 1, iLastCol ); } if( fExpose ) - { - HB_GTSUPER_EXPOSEAREA( pCTW->pGT, pWnd->iFirstRow, pWnd->iFirstCol, - iLastRow, iLastCol ); - } + hb_ctw_TouchLines( pCTW, pWnd->iFirstRow, iLastRow ); } } -static void hb_ctw_RemapAllWindows( PHB_GTCTW pCTW ) +static void hb_ctw_RemapAllWindows( PHB_GTCTW pCTW, int iFrom ) { - HB_TRACE(HB_TR_DEBUG, ("hb_ctw_RemapAllWindows(%p)", pCTW)); + HB_TRACE(HB_TR_DEBUG, ("hb_ctw_RemapAllWindows(%p,%d)", pCTW, iFrom)); if( pCTW->iMaxWindow ) { int i; hb_ctw_ClearMap( pCTW ); - for( i = 0; i < pCTW->iOpenWindows; ++i ) + for( i = iFrom; i < pCTW->iOpenWindows; ++i ) hb_ctw_WindowMap( pCTW, pCTW->windowStack[ i ], FALSE ); - HB_GTSUPER_EXPOSEAREA( pCTW->pGT, 0, 0, pCTW->iMapHeight, pCTW->iMapWidth ); + hb_ctw_TouchLines( pCTW, 0, pCTW->iMapHeight ); } } @@ -311,7 +319,7 @@ static int hb_ctw_SetWindowBoard( PHB_GTCTW pCTW, int iTop, int iLeft, int iBott pCTW->iBoardBottom = iBottom; pCTW->iBoardRight = iRight; pCTW->fBoardSet = TRUE; - hb_ctw_RemapAllWindows( pCTW ); + hb_ctw_RemapAllWindows( pCTW, 0 ); return 0; } @@ -358,28 +366,31 @@ static int hb_ctw_SelectWindow( PHB_GTCTW pCTW, int iWindow, BOOL fToTop ) /* update window level */ i = pCTW->iOpenWindows - 1; - while( i >= 0 && pCTW->windowStack[ i ] != iWindow ) - --i; - if( i >= 0 && i < pCTW->iOpenWindows - 1 ) + while( i >= 0 ) { - iPos = i; - while( i < pCTW->iOpenWindows - 1 && - pCTW->windows[ pCTW->windowStack[ i + 1 ] ]->iLevel <= - pCTW->windows[ iWindow ]->iLevel ) + if( pCTW->windowStack[ i ] == iWindow ) { - pCTW->windowStack[ i ] = pCTW->windowStack[ i + 1 ]; - ++i; - } - pCTW->windowStack[ i ] = iWindow; + iPos = i; + while( i < pCTW->iOpenWindows - 1 && + pCTW->windows[ pCTW->windowStack[ i + 1 ] ]->iLevel <= + pCTW->windows[ iWindow ]->iLevel ) + { + pCTW->windowStack[ i ] = pCTW->windowStack[ i + 1 ]; + ++i; + } + pCTW->windowStack[ i ] = iWindow; - if( iPos != i && !pCTW->windows[ iWindow ]->fHidden ) - { - /* INFO: CT effectively calls hb_ctw_RemapAllWindows() here */ - if( i < pCTW->iOpenWindows - 1 ) - hb_ctw_RemapAllWindows( pCTW ); - else - hb_ctw_WindowMap( pCTW, iWindow, TRUE ); + if( iPos != i && !pCTW->windows[ iWindow ]->fHidden ) + { + /* INFO: CT effectively calls hb_ctw_RemapAllWindows() here */ + if( i < pCTW->iOpenWindows - 1 ) + hb_ctw_RemapAllWindows( pCTW, i ); + else + hb_ctw_WindowMap( pCTW, iWindow, TRUE ); + } + break; } + --i; } } } @@ -405,7 +416,7 @@ static int hb_ctw_Visible( PHB_GTCTW pCTW, int iWindow, int iVisible ) pWnd->fHidden != ( iVisible == HB_CTW_HIDDEN ) ) { pWnd->fHidden = ( iVisible == HB_CTW_HIDDEN ); - hb_ctw_RemapAllWindows( pCTW ); + hb_ctw_RemapAllWindows( pCTW, 0 ); } } @@ -461,7 +472,7 @@ static int hb_ctw_SetWindowLevel( PHB_GTCTW pCTW, int iWindow, int iLevel ) pCTW->windowStack[ i ] = iWindow; } if( !pWnd->fHidden && iPos != i ) - hb_ctw_RemapAllWindows( pCTW ); + hb_ctw_RemapAllWindows( pCTW, HB_MIN( iPos, i ) ); } } } @@ -486,7 +497,7 @@ static int hb_ctw_SetWindowShadow( PHB_GTCTW pCTW, int iWindow, int iAttr ) { pWnd->iShadowAttr = iAttr; if( !pWnd->fHidden ) - hb_ctw_RemapAllWindows( pCTW ); + hb_ctw_RemapAllWindows( pCTW, 0 ); } } @@ -526,7 +537,7 @@ static int hb_ctw_CreateWindow( PHB_GTCTW pCTW, int iTop, int iLeft, int iBottom { ULONG ulSize; - HB_GTSUPER_GETSIZE( pCTW->pGT, &pCTW->iMapHeight, &pCTW->iMapWidth ); + HB_GTSELF_GETSIZE( pCTW->pGT, &pCTW->iMapHeight, &pCTW->iMapWidth ); pCTW->iShadowWidth = hb_ctw_CalcShadowWidth( pCTW->iMapHeight, pCTW->iMapWidth ); if( !pCTW->fBoardSet ) hb_ctw_SetWindowBoard( pCTW, 0, 0, pCTW->iMapHeight - 1, pCTW->iMapWidth - 1 ); @@ -645,7 +656,7 @@ static int hb_ctw_CreateWindow( PHB_GTCTW pCTW, int iTop, int iLeft, int iBottom if( !pWnd->fHidden ) { if( iTmp < pCTW->iOpenWindows - 1 ) - hb_ctw_RemapAllWindows( pCTW ); + hb_ctw_RemapAllWindows( pCTW, iTmp ); else hb_ctw_WindowMap( pCTW, pWnd->iHandle, TRUE ); } @@ -685,7 +696,7 @@ static int hb_ctw_CloseWindow( PHB_GTCTW pCTW, int iWindow ) pCTW->iCurrWindow = pCTW->iOpenWindows > 0 ? pCTW->windowStack[ pCTW->iOpenWindows - 1 ] : 0; if( !fHidden ) - hb_ctw_RemapAllWindows( pCTW ); + hb_ctw_RemapAllWindows( pCTW, 0 ); return pCTW->iCurrWindow; } @@ -713,7 +724,7 @@ static int hb_ctw_CloseAllWindows( PHB_GTCTW pCTW ) hb_xfree( pWnd ); } pCTW->iOpenWindows = pCTW->iCurrWindow = 0; - hb_ctw_RemapAllWindows( pCTW ); + hb_ctw_RemapAllWindows( pCTW, 0 ); return 0; } @@ -779,7 +790,7 @@ static int hb_ctw_MoveWindow( PHB_GTCTW pCTW, int iWindow, int iRow, int iCol ) pWnd->iFirstRow = iRow; pWnd->iFirstCol = iCol; if( ! pWnd->fHidden ) - hb_ctw_RemapAllWindows( pCTW ); + hb_ctw_RemapAllWindows( pCTW, 0 ); return iWindow; } } @@ -1001,7 +1012,7 @@ static int hb_ctw_SwapWindows( PHB_GTCTW pCTW, int iWindow1, int iWindow2 ) pCTW->windows[ iWindow1 ]->fHidden = fHidden; if( !fHidden || !pWnd->fHidden ) - hb_ctw_RemapAllWindows( pCTW ); + hb_ctw_RemapAllWindows( pCTW, 0 ); return iWindow1; } @@ -1022,7 +1033,7 @@ static void hb_ctw_Init( PHB_GTCTW pCTW ) pCTW->iVerticalStep = 2; pCTW->iHorizontalStep = 5; - HB_GTSUPER_GETSIZE( pCTW->pGT, &pCTW->iMapHeight, &pCTW->iMapWidth ); + HB_GTSELF_GETSIZE( pCTW->pGT, &pCTW->iMapHeight, &pCTW->iMapWidth ); /* update cursor position to the rules used by CTWIN */ HB_GTSELF_GETPOS( pCTW->pGT, &iRow, &iCol ); @@ -1659,11 +1670,12 @@ static BOOL hb_ctw_gt_PutChar( PHB_GT pGT, int iRow, int iCol, pWnd->screenBuffer[ lIndex ].c.bAttr = bAttr; if( ! pWnd->fHidden ) { - if( pCTW->iCurrWindow == 0 ) - HB_GTSUPER_TOUCHCELL( pGT, iRow, iCol ); - else if( iRow >= pCTW->iBoardTop && iRow <= pCTW->iBoardBottom && - iCol >= pCTW->iBoardLeft && iCol <= pCTW->iBoardRight ) - HB_GTSUPER_TOUCHCELL( pGT, iRow, iCol ); + if( pCTW->iCurrWindow == 0 || + ( iRow >= pCTW->iBoardTop && iRow <= pCTW->iBoardBottom && + iCol >= pCTW->iBoardLeft && iCol <= pCTW->iBoardRight ) ) + { + HB_GTSELF_TOUCHLINE( pGT, iRow ); + } } return TRUE; } @@ -1965,6 +1977,63 @@ static int hb_ctw_gt_ReadKey( PHB_GT pGT, int iEventMask ) return iKey; } +/* helper function */ +static UINT32 hb_ctw_gt_cellValue( PHB_GT pGT, int iRow, int iCol ) +{ + HB_SCREENCELL cell; + + cell.uiValue = 0; + HB_GTSELF_GETSCRCHAR( pGT, iRow, iCol, + &cell.c.bColor, &cell.c.bAttr, &cell.c.usChar ); + return cell.uiValue; +} + +static void hb_ctw_gt_RedrawDiff( PHB_GT pGT ) +{ + if( HB_GTCTW_GET( pGT )->iOpenWindows == 0 ) + HB_GTSUPER_REDRAWDIFF( pGT ); + else if( pGT->fRefresh ) + { + int i, l, r; + long lIndex; + + for( i = 0; i < pGT->iHeight; ++i ) + { + if( pGT->pLines[ i ] ) + { + lIndex = ( long ) i * pGT->iWidth; + for( l = 0; l < pGT->iWidth; ++l, ++lIndex ) + { + if( pGT->prevBuffer[ lIndex ].uiValue != + hb_ctw_gt_cellValue( pGT, i, l ) ) + break; + } + if( l < pGT->iWidth ) + { + lIndex = ( long ) ( i + 1 ) * pGT->iWidth - 1; + for( r = pGT->iWidth - 1; r > l; --r, --lIndex ) + { + if( pGT->prevBuffer[ lIndex ].uiValue != + hb_ctw_gt_cellValue( pGT, i, r ) ) + break; + } + HB_GTSELF_REDRAW( pGT, i, l, r - l + 1 ); + lIndex = ( long ) i * pGT->iWidth + l; + do + { + pGT->prevBuffer[ lIndex ].uiValue = + hb_ctw_gt_cellValue( pGT, i, l ); + ++lIndex; + } + while( ++l <= r ); + } + pGT->pLines[ i ] = FALSE; + } + } + pGT->fRefresh = FALSE; + } +} + /* PUBLIC FUNCTIONS */ BOOL hb_ctwInit( void ) @@ -2296,6 +2365,7 @@ static BOOL hb_gt_FuncInit( PHB_GT_FUNCS pFuncTable ) pFuncTable->Info = hb_ctw_gt_Info; pFuncTable->Alert = hb_ctw_gt_Alert; pFuncTable->ReadKey = hb_ctw_gt_ReadKey; + pFuncTable->RedrawDiff = hb_ctw_gt_RedrawDiff; return TRUE; } diff --git a/harbour/include/hbgtcore.h b/harbour/include/hbgtcore.h index 99cd13ec8a..39d1969755 100644 --- a/harbour/include/hbgtcore.h +++ b/harbour/include/hbgtcore.h @@ -123,8 +123,10 @@ typedef struct void (* ColdArea) ( HB_GT_PTR, int, int, int, int ); void (* ExposeArea) ( HB_GT_PTR, int, int, int, int ); void (* ScrollArea) ( HB_GT_PTR, int, int, int, int, BYTE, BYTE, int, int ); + void (* TouchLine) ( HB_GT_PTR, int ); void (* TouchCell) ( HB_GT_PTR, int, int ); void (* Redraw) ( HB_GT_PTR, int, int, int ); + void (* RedrawDiff) ( HB_GT_PTR ); void (* Refresh) ( HB_GT_PTR ); void (* Flush) ( HB_GT_PTR ); int (* MaxCol) ( HB_GT_PTR ); @@ -235,24 +237,7 @@ typedef struct int (* GfxPrimitive) ( HB_GT_PTR, int, int, int, int, int, int ); void (* GfxText) ( HB_GT_PTR, int, int, const char *, int, int, int ); -#if 0 - /* keyboard */ - int (* ExtendedKeySupport) ( HB_GT_PTR ); - - /* GT CLIPBOARD functions */ - void (* GetClipboard) ( HB_GT_PTR, char *, ULONG * ); - void (* SetClipboard) ( HB_GT_PTR, char *, ULONG ); - ULONG (* GetClipboardSize) ( HB_GT_PTR ); - - void (* ProcessMessages) ( HB_GT_PTR ); - - /* GT to DRIVER communication functions */ - void (* update ) ( HB_GT_PTR, int ); - int (* info ) ( HB_GT_PTR, int, BOOL , int , void * ); - -#endif - - void (* WhoCares) ( HB_GT_PTR, void * ); + void (* WhoCares) ( HB_GT_PTR, void * ); } HB_GT_FUNCS, * PHB_GT_FUNCS; @@ -371,8 +356,10 @@ extern PHB_GT hb_gt_ItemBase( PHB_ITEM pItemGT ); #define HB_GTSELF_COLDAREA(g,t,l,b,r) (g)->pFuncTable->ColdArea(g,t,l,b,r) #define HB_GTSELF_EXPOSEAREA(g,t,l,b,r) (g)->pFuncTable->ExposeArea(g,t,l,b,r) #define HB_GTSELF_SCROLLAREA(g,t,l,b,r,m,u,v,h) (g)->pFuncTable->ScrollArea(g,t,l,b,r,m,u,v,h) +#define HB_GTSELF_TOUCHLINE(g,r) (g)->pFuncTable->TouchLine(g,r) #define HB_GTSELF_TOUCHCELL(g,r,c) (g)->pFuncTable->TouchCell(g,r,c) #define HB_GTSELF_REDRAW(g,r,c,l) (g)->pFuncTable->Redraw(g,r,c,l) +#define HB_GTSELF_REDRAWDIFF(g) (g)->pFuncTable->RedrawDiff(g) #define HB_GTSELF_REFRESH(g) (g)->pFuncTable->Refresh(g) #define HB_GTSELF_FLUSH(g) (g)->pFuncTable->Flush(g) #define HB_GTSELF_MAXCOL(g) (g)->pFuncTable->MaxCol(g) @@ -492,8 +479,10 @@ extern PHB_GT hb_gt_ItemBase( PHB_ITEM pItemGT ); #define HB_GTSUPER_COLDAREA(g,t,l,b,r) (HB_GTSUPERTABLE(g))->ColdArea(g,t,l,b,r) #define HB_GTSUPER_EXPOSEAREA(g,t,l,b,r) (HB_GTSUPERTABLE(g))->ExposeArea(g,t,l,b,r) #define HB_GTSUPER_SCROLLAREA(g,t,l,b,r,m,u,v,h) (HB_GTSUPERTABLE(g))->ScrollArea(g,t,l,b,r,m,u,v,h) +#define HB_GTSUPER_TOUCHLINE(g,r) (HB_GTSUPERTABLE(g))->TouchLine(g,r) #define HB_GTSUPER_TOUCHCELL(g,r,c) (HB_GTSUPERTABLE(g))->TouchCell(g,r,c) #define HB_GTSUPER_REDRAW(g,r,c,l) (HB_GTSUPERTABLE(g))->Redraw(g,r,c,l) +#define HB_GTSUPER_REDRAWDIFF(g) (HB_GTSUPERTABLE(g))->RedrawDiff(g) #define HB_GTSUPER_REFRESH(g) (HB_GTSUPERTABLE(g))->Refresh(g) #define HB_GTSUPER_FLUSH(g) (HB_GTSUPERTABLE(g))->Flush(g) #define HB_GTSUPER_MAXCOL(g) (HB_GTSUPERTABLE(g))->MaxCol(g) diff --git a/harbour/source/rdd/dbfnsx/dbfnsx1.c b/harbour/source/rdd/dbfnsx/dbfnsx1.c index 5d672fed4e..038838141e 100644 --- a/harbour/source/rdd/dbfnsx/dbfnsx1.c +++ b/harbour/source/rdd/dbfnsx/dbfnsx1.c @@ -85,6 +85,7 @@ static USHORT s_uiRddId; #define hb_nsxPageType(p) ( hb_nsxPageBuffer(p)[0] ) #define hb_nsxSetPageType(p,t) do hb_nsxPageBuffer(p)[0]=(t); while(0) #define hb_nsxGetKeyRecSize(p) (hb_nsxPageBuffer(p)[1]) +#define hb_nsxGetKeyRecSizePtr(p) ((p)[1]) #define hb_nsxSetKeyRecSize(p,n) do hb_nsxPageBuffer(p)[1]=(n); while(0) #define hb_nsxGetBranchKeyPtr(p,l,n) (hb_nsxPageBuffer(p)+(n)*((l)+8)+8) #define hb_nsxBranchKeyVal(p) ((p)+8) @@ -212,15 +213,19 @@ static void hb_nsxLeafSetFreeOffset( LPPAGEINFO pPage, USHORT uiOffset ) #endif +/* #define HB_NSX_NO_CORRUPT_PROTECT */ + static USHORT hb_nsxLeafGetKey( LPTAGINFO pTag, LPPAGEINFO pPage, USHORT uiOffset, UCHAR * bPrevValue, ULONG * pulRecNo ) { UCHAR * ptr = ( UCHAR * ) hb_nsxPageBuffer( pPage ); - UCHAR ucRecLen = hb_nsxGetKeyRecSize( pPage ), ucSize, ucDupCount; + UCHAR ucRecLen = hb_nsxGetKeyRecSizePtr( ptr ), ucSize, ucDupCount; +#ifndef HB_NSX_NO_CORRUPT_PROTECT /* protection against corrupted NSX files */ if( ucRecLen + uiOffset >= pPage->uiOffset ) return 0; +#endif /* HB_NSX_NO_CORRUPT_PROTECT */ switch( ucRecLen ) { @@ -246,26 +251,31 @@ static USHORT hb_nsxLeafGetKey( LPTAGINFO pTag, LPPAGEINFO pPage, USHORT uiOffse ucSize = ptr[ uiOffset++ ]; if( ucSize != ucRecLen + 1 ) /* key value is not fully duplicated */ { + UCHAR len = pTag->KeyLength; + /* ucSize = 0 is a special case when RecLen is 4 and KeySize is 250 * in such case ucSize - ( ucRecLen + 2 ) gives 250 = NSX_MAXKEYLEN */ ucSize -= ucRecLen + 2; +#ifndef HB_NSX_NO_CORRUPT_PROTECT /* protection against corrupted NSX files */ if( ucSize > NSX_MAXKEYLEN || uiOffset + ucSize >= pPage->uiOffset ) return 0; +#endif /* HB_NSX_NO_CORRUPT_PROTECT */ ucDupCount = ptr[ uiOffset++ ]; - if( ucSize + ucDupCount == pTag->KeyLength ) + if( ucSize + ucDupCount == len ) { /* key value is stored as raw data and can be copied as is */ memcpy( &bPrevValue[ ucDupCount ], &ptr[ uiOffset ], ucSize ); uiOffset += ucSize; } - +#ifndef HB_NSX_NO_CORRUPT_PROTECT /* protection against corrupted NSX files */ - else if( ucSize + ucDupCount > pTag->KeyLength ) + else if( ucSize + ucDupCount > len ) return 0; +#endif /* HB_NSX_NO_CORRUPT_PROTECT */ else { @@ -277,32 +287,42 @@ static USHORT hb_nsxLeafGetKey( LPTAGINFO pTag, LPPAGEINFO pPage, USHORT uiOffse { UCHAR ucRepl; +#ifndef HB_NSX_NO_CORRUPT_PROTECT /* protection against corrupted NSX files */ if( !ucSize-- ) return 0; +#else + --ucSize; +#endif /* HB_NSX_NO_CORRUPT_PROTECT */ - ucRepl = ptr[ uiOffset++ ]; - if( ucRepl != 1 ) + if( ( ucRepl = ptr[ uiOffset++ ] ) != 1 ) { +#ifndef HB_NSX_NO_CORRUPT_PROTECT /* protection against corrupted NSX files */ - if( !ucSize-- || ucRepl + ucDupCount > pTag->KeyLength ) + if( !ucSize-- || ucRepl + ucDupCount > len ) return 0; +#else + --ucSize; +#endif /* HB_NSX_NO_CORRUPT_PROTECT */ - memset( &bPrevValue[ ucDupCount ], ptr[ uiOffset++ ], ucRepl ); - ucDupCount += ucRepl; + uc = ptr[ uiOffset++ ]; + while( ucRepl-- ) + bPrevValue[ ucDupCount++ ] = uc; continue; } } +#ifndef HB_NSX_NO_CORRUPT_PROTECT /* protection against corrupted NSX files */ - if( ucDupCount >= pTag->KeyLength ) + if( ucDupCount >= len ) return 0; +#endif /* HB_NSX_NO_CORRUPT_PROTECT */ bPrevValue[ ucDupCount++ ] = uc; } - if( ucDupCount < pTag->KeyLength ) - memset( &bPrevValue[ ucDupCount ], pTag->TrailChar, - pTag->KeyLength - ucDupCount ); + + while( ucDupCount < len ) + bPrevValue[ ucDupCount++ ] = pTag->TrailChar; } } return uiOffset; diff --git a/harbour/source/rtl/hbgtcore.c b/harbour/source/rtl/hbgtcore.c index 5d80ae80ca..9a23a5ed42 100644 --- a/harbour/source/rtl/hbgtcore.c +++ b/harbour/source/rtl/hbgtcore.c @@ -2099,6 +2099,15 @@ static void hb_gt_def_ExposeArea( PHB_GT pGT, int iTop, int iLeft, int iBottom, } } +static void hb_gt_def_TouchLine( PHB_GT pGT, int iRow ) +{ + if( iRow >= 0 && iRow < pGT->iHeight ) + { + pGT->pLines[ iRow ] = TRUE; + pGT->fRefresh = TRUE; + } +} + static void hb_gt_def_TouchCell( PHB_GT pGT, int iRow, int iCol ) { long lIndex; @@ -2119,7 +2128,7 @@ static void hb_gt_def_Redraw( PHB_GT pGT, int iRow, int iCol, int iSize ) HB_SYMBOL_UNUSED( iSize ); } -static void hb_gt_def_Refresh( PHB_GT pGT ) +static void hb_gt_def_RedrawDiff( PHB_GT pGT ) { if( pGT->fRefresh ) { @@ -2163,6 +2172,11 @@ static void hb_gt_def_Refresh( PHB_GT pGT ) } } +static void hb_gt_def_Refresh( PHB_GT pGT ) +{ + HB_GTSELF_REDRAWDIFF( pGT ); +} + static void hb_gt_def_Flush( PHB_GT pGT ) { if( HB_GTSELF_DISPCOUNT( pGT ) == 0 ) @@ -2830,8 +2844,10 @@ static const HB_GT_FUNCS s_gtCoreFunc = ColdArea : hb_gt_def_ColdArea , ExposeArea : hb_gt_def_ExposeArea , ScrollArea : hb_gt_def_ScrollArea , + TouchLine : hb_gt_def_TouchLine , TouchCell : hb_gt_def_TouchCell , Redraw : hb_gt_def_Redraw , + RedrawDiff : hb_gt_def_RedrawDiff , Refresh : hb_gt_def_Refresh , Flush : hb_gt_def_Flush , MaxCol : hb_gt_def_MaxCol , @@ -2950,8 +2966,10 @@ static const HB_GT_FUNCS s_gtCoreFunc = hb_gt_def_ColdArea , hb_gt_def_ExposeArea , hb_gt_def_ScrollArea , + hb_gt_def_TouchLine , hb_gt_def_TouchCell , hb_gt_def_Redraw , + hb_gt_def_RedrawDiff , hb_gt_def_Refresh , hb_gt_def_Flush , hb_gt_def_MaxCol ,