From 27a85b3e3b15d9285822861531b66e3dd368b831 Mon Sep 17 00:00:00 2001 From: martin Date: Mon, 27 Jul 2009 16:42:25 +0000 Subject: [PATCH] SynEdit, fixed clearing non persistent block, if caret moves to other end of block git-svn-id: trunk@20979 - --- components/synedit/synedit.pp | 14 +++++++++----- components/synedit/syneditpointclasses.pas | 20 ++++++++++++++------ 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/components/synedit/synedit.pp b/components/synedit/synedit.pp index 7792db203a..b17b5a9abd 100644 --- a/components/synedit/synedit.pp +++ b/components/synedit/synedit.pp @@ -3979,7 +3979,7 @@ end; procedure TCustomSynEdit.SetTopLine(Value: Integer); var Delta: Integer; - OldTopView: LongInt; + OldTopView: Integer; begin if fPaintLock > 0 then begin // defer scrolling, to minimize any possible flicker @@ -5481,16 +5481,20 @@ begin ecLeft, ecSelLeft, ecColSelLeft: begin if (eoCaretSkipsSelection in Options2) and (Command=ecLeft) - and SelAvail and FCaret.IsAtLineByte(FBlockSelection.LastLineBytePos) then - FCaret.LineBytePos := FBlockSelection.FirstLineBytePos + and SelAvail and FCaret.IsAtLineByte(FBlockSelection.LastLineBytePos) then begin + FBlockSelection.IgnoreNextCaretMove; + FCaret.LineBytePos := FBlockSelection.FirstLineBytePos; + end else MoveCaretHorz(-1); end; ecRight, ecSelRight, ecColSelRight: begin if (eoCaretSkipsSelection in Options2) and (Command=ecRight) - and SelAvail and FCaret.IsAtLineByte(FBlockSelection.FirstLineBytePos) then - FCaret.LineBytePos := FBlockSelection.LastLineBytePos + and SelAvail and FCaret.IsAtLineByte(FBlockSelection.FirstLineBytePos) then begin + FBlockSelection.IgnoreNextCaretMove; + FCaret.LineBytePos := FBlockSelection.LastLineBytePos; + end else MoveCaretHorz(1); end; diff --git a/components/synedit/syneditpointclasses.pas b/components/synedit/syneditpointclasses.pas index 8a12562e97..c9fbd2a79e 100644 --- a/components/synedit/syneditpointclasses.pas +++ b/components/synedit/syneditpointclasses.pas @@ -88,6 +88,7 @@ type FEndBytePos: Integer; // 1 based FPersistent: Boolean; FPersistentLock: Integer; + FIgnoreNextCaretMove: Boolean; (* On any modification, remember the position of the caret. If it gets moved from there to either end of the block, this should be ignored This happens, if Block and caret are adjusted directly @@ -124,6 +125,7 @@ type function SelCanContinue(ACaret: TSynEditCaret): Boolean; function IsBackwardSel: Boolean; // SelStart < SelEnd ? procedure SortSelectionPoints; + procedure IgnoreNextCaretMove; procedure IncPersistentLock; procedure DecPersistentLock; procedure Clear; @@ -734,7 +736,14 @@ begin end; procedure TSynEditSelection.DoCaretChanged(Sender: TObject); +var + Ignore: Boolean; begin + Ignore := FIgnoreNextCaretMove; + FIgnoreNextCaretMove := False; + if Ignore then + exit; + if (FCaret.IsAtLineByte(StartLineBytePos) or FCaret.IsAtLineByte(EndLineBytePos)) and FCaret.WasAtLineChar(FLastCarePos) @@ -757,15 +766,9 @@ begin exit; end; - if FPersistent or (FPersistentLock > 0) then exit; - if FCaret.IsAtLineByte(StartLineBytePos) or - FCaret.IsAtLineByte(EndLineBytePos) - then - exit; - StartLineBytePos := FCaret.LineBytePos; end; @@ -1315,6 +1318,11 @@ begin end; end; +procedure TSynEditSelection.IgnoreNextCaretMove; +begin + FIgnoreNextCaretMove := True; +end; + procedure TSynEditSelection.IncPersistentLock; begin inc(FPersistentLock)