2015-02-13 17:08 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
* src/rtl/mlcfunc.c
! fixed MPosToLC() results for position in last line which have to
be moved after analyzing rest of line due to word wrapping.
* src/rtl/teditor.prg
* rewritten whole internal code critical for basic functionality.
+ resolved the problem with keycode conflicts for GTs which
support extended keycodes.
+ added support missing MemoEdit() editor functionality.
; Number of bugs and mistakes was to big to try to update it.
New code is smaller and simpler. I tried to keep compatibility
with previous version and added to new version most of "helper"
methods which are not used in MemoEdit() at all anyhow I cannot
guaranty that all existing code using TEditor will work without
modifications, i.e. I had to remove :SetPos() and all logic bound
with it because it was to hard for my brain to understand this
idea and/or functionality.
If someone needs strict compatibility with previous version then
he should add to his source code copy of old code.
Current code should addressed most of MemoEdit() problems with
text formatting and editing reported in the past though probably
not all. I have no spare time for precise tests of Cl*pper's
MemoEdit().
* src/rtl/memoedit.prg
* overload :InsertState() method to show <insert> SCOREBOARD message
* changed "Abort Edit? (Y/N)" message position to be Clipper compatible
* removed redundant keycode comparison
* do not ::SetPos HBEditor method - this method has been removed
This commit is contained in:
@@ -10,6 +10,37 @@
|
||||
* Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment
|
||||
*/
|
||||
|
||||
2015-02-13 17:08 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
|
||||
* src/rtl/mlcfunc.c
|
||||
! fixed MPosToLC() results for position in last line which have to
|
||||
be moved after analyzing rest of line due to word wrapping.
|
||||
|
||||
* src/rtl/teditor.prg
|
||||
* rewritten whole internal code critical for basic functionality.
|
||||
+ resolved the problem with keycode conflicts for GTs which
|
||||
support extended keycodes.
|
||||
+ added support missing MemoEdit() editor functionality.
|
||||
; Number of bugs and mistakes was to big to try to update it.
|
||||
New code is smaller and simpler. I tried to keep compatibility
|
||||
with previous version and added to new version most of "helper"
|
||||
methods which are not used in MemoEdit() at all anyhow I cannot
|
||||
guaranty that all existing code using TEditor will work without
|
||||
modifications, i.e. I had to remove :SetPos() and all logic bound
|
||||
with it because it was to hard for my brain to understand this
|
||||
idea and/or functionality.
|
||||
If someone needs strict compatibility with previous version then
|
||||
he should add to his source code copy of old code.
|
||||
Current code should addressed most of MemoEdit() problems with
|
||||
text formatting and editing reported in the past though probably
|
||||
not all. I have no spare time for precise tests of Cl*pper's
|
||||
MemoEdit().
|
||||
|
||||
* src/rtl/memoedit.prg
|
||||
* overload :InsertState() method to show <insert> SCOREBOARD message
|
||||
* changed "Abort Edit? (Y/N)" message position to be Clipper compatible
|
||||
* removed redundant keycode comparison
|
||||
* do not ::SetPos HBEditor method - this method has been removed
|
||||
|
||||
2015-02-11 19:59 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
|
||||
* ChangeLog.txt
|
||||
! typo in issue number
|
||||
|
||||
@@ -69,6 +69,7 @@ CREATE CLASS HBMemoEditor INHERIT HBEditor
|
||||
METHOD xDo( nStatus ) // Calls xUserFunction saving and restoring cursor position and shape
|
||||
|
||||
METHOD MoveCursor( nKey ) // Redefined to properly managed CTRL-W
|
||||
METHOD InsertState( lInsState ) // Redefined for _SET_SCOREBOARD messages
|
||||
|
||||
PROTECTED:
|
||||
|
||||
@@ -170,16 +171,16 @@ METHOD KeyboardHook( nKey ) CLASS HBMemoEditor
|
||||
ELSEIF nKey == K_ESC
|
||||
|
||||
IF ::lDirty .AND. Set( _SET_SCOREBOARD )
|
||||
cBackScr := SaveScreen( 0, MaxCol() - 18, 0, MaxCol() )
|
||||
cBackScr := SaveScreen( 0, MaxCol() - 19, 0, MaxCol() )
|
||||
|
||||
nRow := Row()
|
||||
nCol := Col()
|
||||
hb_DispOutAt( 0, MaxCol() - 18, "Abort Edit? (Y/N)" )
|
||||
SetPos( 0, MaxCol() - 1 )
|
||||
hb_DispOutAt( 0, MaxCol() - 19, "Abort Edit? (Y/N)" )
|
||||
SetPos( 0, MaxCol() - 2 )
|
||||
|
||||
nYesNoKey := Inkey( 0 )
|
||||
|
||||
RestScreen( 0, MaxCol() - 18, 0, MaxCol(), cBackScr )
|
||||
RestScreen( 0, MaxCol() - 19, 0, MaxCol(), cBackScr )
|
||||
SetPos( nRow, nCol )
|
||||
|
||||
IF Upper( hb_keyChar( nYesNoKey ) ) == "Y"
|
||||
@@ -282,16 +283,14 @@ METHOD xDo( nStatus ) CLASS HBMemoEditor
|
||||
|
||||
LOCAL xResult := Do( ::xUserFunction, nStatus, ::nRow, ::nCol - 1 )
|
||||
|
||||
::SetPos( nOldRow, nOldCol )
|
||||
SetPos( nOldRow, nOldCol )
|
||||
SetCursor( nOldCur )
|
||||
|
||||
RETURN hb_defaultValue( xResult, ME_DEFAULT )
|
||||
|
||||
METHOD MoveCursor( nKey ) CLASS HBMemoEditor
|
||||
|
||||
IF nKey == K_CTRL_END .OR. ;
|
||||
nKey == K_CTRL_W
|
||||
|
||||
IF nKey == K_CTRL_W
|
||||
::lSaved := .T.
|
||||
::lExitEdit := .T.
|
||||
ELSE
|
||||
@@ -300,6 +299,18 @@ METHOD MoveCursor( nKey ) CLASS HBMemoEditor
|
||||
|
||||
RETURN .F.
|
||||
|
||||
METHOD InsertState( lInsState ) CLASS HBMemoEditor
|
||||
|
||||
IF HB_ISLOGICAL( lInsState ) .AND. ::lEditAllow
|
||||
Set( _SET_INSERT, lInsState )
|
||||
SetCursor( iif( lInsState, SC_INSERT, SC_NORMAL ) )
|
||||
IF SET( _SET_SCOREBOARD )
|
||||
hb_dispOutAt( 0, MaxCol() - 19, iif( lInsState, "<insert>", " " ) )
|
||||
ENDIF
|
||||
ENDIF
|
||||
|
||||
RETURN Self
|
||||
|
||||
/* ------------------------------------------ */
|
||||
|
||||
FUNCTION MemoEdit( ;
|
||||
@@ -346,7 +357,8 @@ FUNCTION MemoEdit( ;
|
||||
/* Contrary to what the NG says, any logical value will make it pass
|
||||
through without any editing. */
|
||||
IF ! HB_ISLOGICAL( xUserFunction )
|
||||
nOldCursor := SetCursor( iif( Set( _SET_INSERT ), SC_INSERT, SC_NORMAL ) )
|
||||
nOldCursor := SetCursor()
|
||||
oEd:InsertState( Set( _SET_INSERT ) )
|
||||
oEd:Edit()
|
||||
IF oEd:Changed() .AND. oEd:Saved()
|
||||
cString := oEd:GetText( .T. )
|
||||
|
||||
@@ -66,6 +66,7 @@ typedef struct
|
||||
HB_SIZE nLineLength;
|
||||
HB_SIZE nTabSize;
|
||||
HB_BOOL fWordWrap;
|
||||
HB_BOOL fPos;
|
||||
int iEOLs;
|
||||
PHB_EOL_INFO pEOLs;
|
||||
PHB_CODEPAGE cdp;
|
||||
@@ -73,9 +74,7 @@ typedef struct
|
||||
HB_SIZE nOffset;
|
||||
HB_SIZE nMaxCol;
|
||||
HB_SIZE nMaxPos;
|
||||
HB_SIZE nLine;
|
||||
HB_SIZE nCol;
|
||||
HB_SIZE nEOL;
|
||||
|
||||
HB_EOL_INFO EOL_buffer[ HB_EOL_BUFFER_SIZE ];
|
||||
}
|
||||
@@ -154,8 +153,8 @@ static HB_BOOL hb_mlInit( PHB_MLC_INFO pMLC, int iParAdd )
|
||||
pMLC->pszString = hb_parc( 1 );
|
||||
if( pMLC->pszString && nSize > 0 )
|
||||
{
|
||||
pMLC->nOffset = pMLC->nMaxCol = pMLC->nMaxPos = pMLC->nLine =
|
||||
pMLC->nCol = pMLC->nEOL = 0;
|
||||
pMLC->nOffset = pMLC->nMaxCol = pMLC->nMaxPos = pMLC->nCol = 0;
|
||||
pMLC->fPos = HB_FALSE;
|
||||
|
||||
pMLC->nLineLength = nSize;
|
||||
pMLC->nLen = hb_parclen( 1 );
|
||||
@@ -209,17 +208,15 @@ static int hb_mlEol( PHB_MLC_INFO pMLC )
|
||||
|
||||
static HB_SIZE hb_mlGetLine( PHB_MLC_INFO pMLC )
|
||||
{
|
||||
HB_SIZE nBlankCol = 0, nBlankPos = 0, nLastPos;
|
||||
HB_SIZE nBlankCol = 0, nBlankPos = 0, nLastCol = 0, nLastPos;
|
||||
int i;
|
||||
|
||||
pMLC->nCol = pMLC->nEOL = 0;
|
||||
pMLC->nCol = 0;
|
||||
|
||||
if( pMLC->nOffset >= pMLC->nLen ||
|
||||
( pMLC->nMaxPos > 0 && pMLC->nOffset >= pMLC->nMaxPos ) )
|
||||
if( pMLC->nOffset >= pMLC->nLen )
|
||||
return HB_FALSE;
|
||||
|
||||
while( pMLC->nOffset < pMLC->nLen &&
|
||||
( pMLC->nMaxPos == 0 || pMLC->nOffset < pMLC->nMaxPos ) )
|
||||
while( pMLC->nOffset < pMLC->nLen )
|
||||
{
|
||||
HB_WCHAR ch;
|
||||
|
||||
@@ -239,9 +236,8 @@ static HB_SIZE hb_mlGetLine( PHB_MLC_INFO pMLC )
|
||||
i = hb_mlEol( pMLC );
|
||||
if( i >= 0 )
|
||||
{
|
||||
pMLC->nEOL = pMLC->pEOLs[ i ].nLen;
|
||||
if( pMLC->nMaxCol == 0 )
|
||||
pMLC->nOffset += pMLC->nEOL;
|
||||
pMLC->nOffset += pMLC->pEOLs[ i ].nLen;
|
||||
break;
|
||||
}
|
||||
else if( ! pMLC->fWordWrap && pMLC->nCol >= pMLC->nLineLength )
|
||||
@@ -256,12 +252,8 @@ static HB_SIZE hb_mlGetLine( PHB_MLC_INFO pMLC )
|
||||
else
|
||||
ch = pMLC->pszString[ pMLC->nOffset++ ];
|
||||
|
||||
if( ch == ' ' || ch == HB_CHAR_HT )
|
||||
{
|
||||
nBlankCol = pMLC->nCol;
|
||||
nBlankPos = pMLC->nOffset;
|
||||
}
|
||||
|
||||
if( pMLC->nOffset <= pMLC->nMaxPos )
|
||||
nLastCol = pMLC->nCol;
|
||||
pMLC->nCol += ch == HB_CHAR_HT ?
|
||||
pMLC->nTabSize - ( pMLC->nCol % pMLC->nTabSize ) : 1;
|
||||
|
||||
@@ -275,27 +267,31 @@ static HB_SIZE hb_mlGetLine( PHB_MLC_INFO pMLC )
|
||||
{
|
||||
if( pMLC->fWordWrap )
|
||||
{
|
||||
if( nBlankCol != 0 )
|
||||
if( pMLC->fPos && ( ch == ' ' || ch == HB_CHAR_HT ) )
|
||||
break;
|
||||
else if( nBlankCol != 0 )
|
||||
{
|
||||
if( pMLC->nMaxPos )
|
||||
pMLC->nCol = nBlankCol + 1;
|
||||
else
|
||||
pMLC->nCol = nBlankCol;
|
||||
pMLC->nCol = nBlankCol;
|
||||
pMLC->nOffset = nBlankPos;
|
||||
}
|
||||
else
|
||||
pMLC->nOffset = nLastPos;
|
||||
}
|
||||
else if( pMLC->nCol > pMLC->nLineLength )
|
||||
else
|
||||
pMLC->nOffset = nLastPos;
|
||||
break;
|
||||
}
|
||||
if( ch == ' ' || ch == HB_CHAR_HT )
|
||||
{
|
||||
nBlankCol = pMLC->nCol;
|
||||
nBlankPos = pMLC->nOffset;
|
||||
}
|
||||
}
|
||||
|
||||
if( pMLC->nCol > pMLC->nLineLength )
|
||||
if( pMLC->nMaxPos && pMLC->nCol > nLastCol )
|
||||
pMLC->nCol = nLastCol;
|
||||
else if( pMLC->nCol > pMLC->nLineLength )
|
||||
pMLC->nCol = pMLC->nLineLength;
|
||||
else if( pMLC->nMaxPos && pMLC->nCol )
|
||||
pMLC->nCol--;
|
||||
|
||||
return HB_TRUE;
|
||||
}
|
||||
@@ -440,6 +436,8 @@ HB_FUNC( MLPOS )
|
||||
{
|
||||
if( hb_mlInit( &MLC, 1 ) )
|
||||
{
|
||||
MLC.fPos = HB_TRUE;
|
||||
|
||||
while( --nLine && hb_mlGetLine( &MLC ) )
|
||||
;
|
||||
nOffset = MLC.nOffset;
|
||||
@@ -471,6 +469,8 @@ HB_FUNC( MLCTOPOS )
|
||||
{
|
||||
if( MLC.nLineLength > 4 )
|
||||
{
|
||||
MLC.fPos = HB_TRUE;
|
||||
|
||||
while( --nLine && hb_mlGetLine( &MLC ) )
|
||||
;
|
||||
if( nCol && nLine == 0 )
|
||||
@@ -512,12 +512,16 @@ HB_FUNC( MPOSTOLC )
|
||||
nPos += nRest;
|
||||
}
|
||||
MLC.nMaxPos = nPos;
|
||||
if( MLC.nMaxPos <= MLC.nLen )
|
||||
if( MLC.nMaxPos <= MLC.nLen + 1 )
|
||||
{
|
||||
while( hb_mlGetLine( &MLC ) )
|
||||
for( ;; )
|
||||
{
|
||||
HB_SIZE nOffset = MLC.nOffset;
|
||||
hb_mlGetLine( &MLC );
|
||||
nCol = MLC.nCol;
|
||||
++nLine;
|
||||
if( MLC.nOffset == nOffset || MLC.nOffset >= MLC.nMaxPos )
|
||||
break;
|
||||
}
|
||||
}
|
||||
hb_mlExit( &MLC );
|
||||
|
||||
1156
src/rtl/teditor.prg
1156
src/rtl/teditor.prg
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user