From 786b91612b74a50ec5fa4c72e8e4f8accf981201 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Czerpak?= Date: Wed, 31 Dec 2014 01:45:42 +0100 Subject: [PATCH] 2014-12-31 01:45 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * src/rtl/memoedit.prg ! fixed repeat condition for ME_INIT initial user function call (correctly fixes #21) * src/rtl/mlcfunc.c * added temporary extension to MemoLine() which will be removed and replaced in the future * src/rtl/teditor.prg ! use temporary MemoLine() extension to fix problem with line trailing spaces I introduced with previous modification * src/rtl/replic.c % optimization for Replicate( , 1 ) --- ChangeLog.txt | 16 ++++++++++++++++ src/rtl/memoedit.prg | 20 +++++++++++++------- src/rtl/mlcfunc.c | 9 +++++++-- src/rtl/replic.c | 11 +++++++---- src/rtl/teditor.prg | 2 +- 5 files changed, 44 insertions(+), 14 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index b8122767c3..34b95cd50a 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -10,6 +10,22 @@ * Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment */ +2014-12-31 01:45 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) + * src/rtl/memoedit.prg + ! fixed repeat condition for ME_INIT initial user function call + (correctly fixes #21) + + * src/rtl/mlcfunc.c + * added temporary extension to MemoLine() which will be removed and + replaced in the future + + * src/rtl/teditor.prg + ! use temporary MemoLine() extension to fix problem with line trailing + spaces I introduced with previous modification + + * src/rtl/replic.c + % optimization for Replicate( , 1 ) + 2014-12-30 01:19 UTC-0800 Pritpal Bedi (bedipritpal/at/hotmail.com) * src/rtl/memoedit.prg ! Fixed: nUdfReturn value ME_UNKEY (1-31) were not being processed. diff --git a/src/rtl/memoedit.prg b/src/rtl/memoedit.prg index be78acf50c..8ad7487591 100644 --- a/src/rtl/memoedit.prg +++ b/src/rtl/memoedit.prg @@ -92,13 +92,19 @@ METHOD MemoInit( xUserFunction ) CLASS HBMemoEditor IF ::UserFunctionIsValid() - // Keep calling user function until it returns ME_DEFAULT - DO WHILE ( nUdfReturn := ::xDo( ME_INIT ) ) != ME_DEFAULT - // At this time there is no input from user of MemoEdit() only handling - // of values returned by ::xUserFunction, so I pass NIL as the key code. - IF ! ::HandleUserKey( , nUdfReturn ) - EXIT - ENDIF + DO WHILE .T. + SWITCH nUdfReturn := ::xDo( ME_INIT ) + // Tested with CL52 that only these 3 actions are processed and + // then ME_INIT call repeated + CASE K_INS + CASE ME_TOGGLEWRAP + CASE ME_TOGGLESCROLL + // At this time there is no input from user of MemoEdit() only handling + // of values returned by ::xUserFunction, so I pass NIL as the key code. + ::HandleUserKey( , nUdfReturn ) + LOOP + ENDSWITCH + EXIT ENDDO ENDIF diff --git a/src/rtl/mlcfunc.c b/src/rtl/mlcfunc.c index d987ca7c75..36c8f3635e 100644 --- a/src/rtl/mlcfunc.c +++ b/src/rtl/mlcfunc.c @@ -304,12 +304,17 @@ static HB_SIZE hb_mlGetLine( PHB_MLC_INFO pMLC ) /* MemoLine( , [ =79 ], * [ =1 ], * [ =4 ], [ =.T. ], - * [ | ] ) -> + * [ | ], + * [ =.T. ] ) -> + * + * NOTE: is undocumented parameter and will be removed and + * replaced by other solution in the future. */ HB_FUNC( MEMOLINE ) { HB_MLC_INFO MLC; HB_ISIZ nLine = hb_parnsdef( 3, 1 ); + HB_BOOL fPad = hb_parldef( 7, 1 ); char * szLine = NULL; HB_SIZE nIndex, nLen = 0, nSize, nCol; @@ -380,7 +385,7 @@ HB_FUNC( MEMOLINE ) } } } - if( nCol < MLC.nLineLength ) + if( nCol < MLC.nLineLength && fPad ) { nCol = MLC.nLineLength - nCol; if( nCol > nSize - nLen ) diff --git a/src/rtl/replic.c b/src/rtl/replic.c index e8bed934bf..01c8da287d 100644 --- a/src/rtl/replic.c +++ b/src/rtl/replic.c @@ -54,17 +54,20 @@ HB_FUNC( REPLICATE ) { - const char * szText = hb_parc( 1 ); + PHB_ITEM pItem = hb_param( 1, HB_IT_STRING ); - if( szText && HB_ISNUM( 2 ) ) + if( pItem && HB_ISNUM( 2 ) ) { - HB_SIZE nLen = hb_parclen( 1 ); + HB_SIZE nLen = hb_itemGetCLen( pItem ); HB_ISIZ nTimes = hb_parns( 2 ); if( nLen > 0 && nTimes > 0 ) { - if( ( double ) nLen * nTimes < HB_SIZE_MAX ) + if( nTimes == 1 ) + hb_itemReturn( pItem ); + else if( ( double ) nLen * nTimes < HB_SIZE_MAX ) { + const char * szText = hb_itemGetCPtr( pItem ); HB_SIZE nSize = nLen * nTimes; char * szResult, * szPtr; diff --git a/src/rtl/teditor.prg b/src/rtl/teditor.prg index 17ff050f6f..dd5339451d 100644 --- a/src/rtl/teditor.prg +++ b/src/rtl/teditor.prg @@ -1072,7 +1072,7 @@ STATIC FUNCTION Text2Array( cString, nWordWrapCol, nTabWidth ) IF nWordWrapCol != NIL .AND. Len( cLine ) > nWordWrapCol nLines := MLCount( cLine, nWordWrapCol, nTabWidth ) FOR nLine := 1 TO nLines - AAdd( aArray, HBTextLine():New( MemoLine( cLine, nWordWrapCol, nLine, nTabWidth ), ; + AAdd( aArray, HBTextLine():New( MemoLine( cLine, nWordWrapCol, nLine, nTabWidth,,, .T. ), ; nLine < nLines ) ) NEXT ELSE