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( <cStr>, 1 )
This commit is contained in:
Przemysław Czerpak
2014-12-31 01:45:42 +01:00
parent 1913612f5b
commit 786b91612b
5 changed files with 44 additions and 14 deletions

View File

@@ -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( <cStr>, 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.

View File

@@ -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

View File

@@ -304,12 +304,17 @@ static HB_SIZE hb_mlGetLine( PHB_MLC_INFO pMLC )
/* MemoLine( <cString>, [ <nLineLength>=79 ],
* [ <nLineNumber>=1 ],
* [ <nTabSize>=4 ], [ <lWrap>=.T. ],
* [ <cEOL>|<acEOLs> ] ) -> <cLine>
* [ <cEOL>|<acEOLs> ],
* [ <lPad>=.T. ] ) -> <cLine>
*
* NOTE: <lPad> 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 )

View File

@@ -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;

View File

@@ -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