From 403decab1318d984319f4d9beb3f02986dc75e9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Czerpak?= Date: Wed, 11 Feb 2015 18:48:48 +0100 Subject: [PATCH] 2015-02-11 18:48 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * src/rtl/mlcfunc.c * modified unpadded MemoLine() mode to return last blank character in the line * src/rtl/teditor.prg ! fixed typo in MemoLine() parameters + added lSoftCR parameter to GetText() - when it's true returned text contains SoftCRs * src/rtl/memoedit.prg ! return text with SoftCRs - Cl*pper compatible ; Above modifications fix initial and result text formatting in MemoEdit() (#33) --- ChangeLog.txt | 20 ++++++++++++++++++-- src/rtl/memoedit.prg | 2 +- src/rtl/mlcfunc.c | 6 +++++- src/rtl/teditor.prg | 10 ++++++---- 4 files changed, 30 insertions(+), 8 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index d17949ac3e..cbcd78f349 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -10,6 +10,22 @@ * Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment */ +2015-02-11 18:48 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) + * src/rtl/mlcfunc.c + * modified unpadded MemoLine() mode to return last blank + character in the line + + * src/rtl/teditor.prg + ! fixed typo in MemoLine() parameters + + added lSoftCR parameter to GetText() - when it's true returned + text contains SoftCRs + + * src/rtl/memoedit.prg + ! return text with SoftCRs - Cl*pper compatible + + ; Above modifications fix initial and result text formatting + in MemoEdit() (#33) + 2015-02-11 13:10 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * package/harbour-wce.spec.in * package/harbour-win.spec.in @@ -17,7 +33,7 @@ * changed deprecated BuildPrereq tag to BuildRequires ! remove optionally created libtiff - ; above modifications close issue #38 + ; above modifications close issue #38 2015-02-11 12:31 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * src/codepage/l_fr.h @@ -40,7 +56,7 @@ + added new French codepage "FR850" with all French characters and accented equal collation rules. - ; above modifications close issue #88 + ; above modifications close issue #88 2015-02-11 09:49 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * src/rdd/dbf1.c diff --git a/src/rtl/memoedit.prg b/src/rtl/memoedit.prg index 6868112446..5789c15506 100644 --- a/src/rtl/memoedit.prg +++ b/src/rtl/memoedit.prg @@ -349,7 +349,7 @@ FUNCTION MemoEdit( ; nOldCursor := SetCursor( iif( Set( _SET_INSERT ), SC_INSERT, SC_NORMAL ) ) oEd:Edit() IF oEd:Changed() .AND. oEd:Saved() - cString := oEd:GetText() + cString := oEd:GetText( .T. ) ENDIF SetCursor( nOldCursor ) ENDIF diff --git a/src/rtl/mlcfunc.c b/src/rtl/mlcfunc.c index 36c8f3635e..ca4b332378 100644 --- a/src/rtl/mlcfunc.c +++ b/src/rtl/mlcfunc.c @@ -385,11 +385,15 @@ HB_FUNC( MEMOLINE ) } } } - if( nCol < MLC.nLineLength && fPad ) + if( nCol < MLC.nLineLength ) { nCol = MLC.nLineLength - nCol; if( nCol > nSize - nLen ) nCol = nSize - nLen; + if( ! fPad && nCol > 0 ) + nCol = nIndex < MLC.nLen && + ( MLC.pszString[ nIndex ] == ' ' || + MLC.pszString[ nIndex ] == HB_CHAR_HT ) ? 1 : 0; memset( szLine + nLen, ' ', nCol ); nLen += nCol; } diff --git a/src/rtl/teditor.prg b/src/rtl/teditor.prg index 03ee067048..081d9a66c5 100644 --- a/src/rtl/teditor.prg +++ b/src/rtl/teditor.prg @@ -77,7 +77,7 @@ CREATE CLASS HBEditor METHOD GotoLine( nRow ) // Put line nRow at cursor position METHOD LineCount() // Returns number of lines in text. - METHOD GetText() // Returns aText as a string (for MemoEdit()) + METHOD GetText( lSoftCR ) // Returns aText as a string (for MemoEdit()) METHOD display() // Redraw a window METHOD RefreshLine() // Redraw a line @@ -281,13 +281,15 @@ METHOD LineLen( nRow ) CLASS HBEditor RETURN iif( nRow >= 1 .AND. nRow <= Len( ::aText ), Len( ::aText[ nRow ]:cText ), 0 ) // Converts an array of text lines to a String -METHOD GetText() CLASS HBEditor +METHOD GetText( lSoftCR ) CLASS HBEditor LOCAL cString := "" LOCAL cEOL := hb_eol() + LOCAL cSoftCR IF ::lWordWrap - AEval( ::aText, {| cItem | cString += cItem:cText + iif( cItem:lSoftCR, "", cEOL ) },, ::naTextLen - 1 ) + cSoftCR := iif( hb_defaultValue( lSoftCR, .F. ), Chr( 141 ) + Chr( 10 ), "" ) + AEval( ::aText, {| cItem | cString += cItem:cText + iif( cItem:lSoftCR, cSoftCR, cEOL ) },, ::naTextLen - 1 ) ELSE AEval( ::aText, {| cItem | cString += cItem:cText + cEOL },, ::naTextLen - 1 ) ENDIF @@ -1072,7 +1074,7 @@ STATIC FUNCTION Text2Array( cString, nWordWrapCol, nTabWidth ) IF nWordWrapCol != NIL .AND. Len( cLine ) > nWordWrapCol nLines := MLCount( cLine, nWordWrapCol + 1, nTabWidth ) FOR nLine := 1 TO nLines - AAdd( aArray, HBTextLine():New( MemoLine( cLine, nWordWrapCol + 1, nLine, nTabWidth,,, .T. ), ; + AAdd( aArray, HBTextLine():New( MemoLine( cLine, nWordWrapCol + 1, nLine, nTabWidth,,, .F. ), ; nLine < nLines ) ) NEXT ELSE