mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-16 09:59:23 +02:00
SynEdit: Improved Syncro-Edit (see note on issue #14813)
git-svn-id: trunk@25247 -
This commit is contained in:
parent
2fb19534f3
commit
9b27609bab
@ -385,7 +385,6 @@ type
|
|||||||
|
|
||||||
FPaintLock: Integer;
|
FPaintLock: Integer;
|
||||||
FPaintLockOwnerCnt: Integer;
|
FPaintLockOwnerCnt: Integer;
|
||||||
FStoredCaredAutoAdjust: Boolean;
|
|
||||||
fReadOnly: Boolean;
|
fReadOnly: Boolean;
|
||||||
fRightEdge: Integer;
|
fRightEdge: Integer;
|
||||||
fRightEdgeColor: TColor;
|
fRightEdgeColor: TColor;
|
||||||
@ -607,10 +606,10 @@ type
|
|||||||
function GetCaretObj: TSynEditCaret; override;
|
function GetCaretObj: TSynEditCaret; override;
|
||||||
procedure IncPaintLock;
|
procedure IncPaintLock;
|
||||||
procedure DecPaintLock;
|
procedure DecPaintLock;
|
||||||
procedure DoIncPaintLock;
|
procedure DoIncPaintLock(Sender: TObject);
|
||||||
procedure DoDecPaintLock;
|
procedure DoDecPaintLock(Sender: TObject);
|
||||||
procedure DoIncForeignPaintLock;
|
procedure DoIncForeignPaintLock(Sender: TObject);
|
||||||
procedure DoDecForeignPaintLock;
|
procedure DoDecForeignPaintLock(Sender: TObject);
|
||||||
procedure DestroyWnd; override;
|
procedure DestroyWnd; override;
|
||||||
procedure DragOver(Source: TObject; X, Y: Integer;
|
procedure DragOver(Source: TObject; X, Y: Integer;
|
||||||
State: TDragState; var Accept: Boolean); override;
|
State: TDragState; var Accept: Boolean); override;
|
||||||
@ -1559,6 +1558,10 @@ begin
|
|||||||
AddNotifyHandler(senrCleared, {$IFDEF FPC}@{$ENDIF}ListCleared);
|
AddNotifyHandler(senrCleared, {$IFDEF FPC}@{$ENDIF}ListCleared);
|
||||||
AddNotifyHandler(senrUndoRedoAdded, {$IFDEF FPC}@{$ENDIF}Self.UndoRedoAdded);
|
AddNotifyHandler(senrUndoRedoAdded, {$IFDEF FPC}@{$ENDIF}Self.UndoRedoAdded);
|
||||||
AddNotifyHandler(senrModifiedChanged, {$IFDEF FPC}@{$ENDIF}ModifiedChanged);
|
AddNotifyHandler(senrModifiedChanged, {$IFDEF FPC}@{$ENDIF}ModifiedChanged);
|
||||||
|
AddNotifyHandler(senrIncPaintLock, {$IFDEF FPC}@{$ENDIF}DoIncPaintLock);
|
||||||
|
AddNotifyHandler(senrDecPaintLock, {$IFDEF FPC}@{$ENDIF}DoDecPaintLock);
|
||||||
|
AddNotifyHandler(senrIncOwnedPaintLock, {$IFDEF FPC}@{$ENDIF}DoIncForeignPaintLock);
|
||||||
|
AddNotifyHandler(senrDecOwnedPaintLock, {$IFDEF FPC}@{$ENDIF}DoDecForeignPaintLock);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
FUndoList := TSynEditStringList(fLines).UndoList;
|
FUndoList := TSynEditStringList(fLines).UndoList;
|
||||||
@ -1729,49 +1732,46 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomSynEdit.IncPaintLock;
|
procedure TCustomSynEdit.IncPaintLock;
|
||||||
var
|
|
||||||
i: Integer;
|
|
||||||
begin
|
begin
|
||||||
if (PaintLockOwner = nil) then begin
|
if (PaintLockOwner = nil) then begin
|
||||||
PaintLockOwner := Self;
|
PaintLockOwner := Self;
|
||||||
for i := 0 to TSynEditStringList(FLines).AttachedSynEditCount - 1 do
|
FLines.SendNotification(senrIncOwnedPaintLock, Self); // DoIncForeignPaintLock
|
||||||
if TSynEditStringList(FLines).AttachedSynEdits[i] <> Self then
|
|
||||||
TCustomSynEdit(TSynEditStringList(FLines).AttachedSynEdits[i]).DoIncForeignPaintLock;
|
|
||||||
end;
|
end;
|
||||||
inc(FPaintLockOwnerCnt);
|
inc(FPaintLockOwnerCnt);
|
||||||
for i := 0 to TSynEditStringList(FLines).AttachedSynEditCount - 1 do
|
if FPaintLockOwnerCnt = 1 then begin
|
||||||
TCustomSynEdit(TSynEditStringList(FLines).AttachedSynEdits[i]).DoIncPaintLock;
|
FLines.SendNotification(senrIncPaintLock, Self); // DoIncPaintLock
|
||||||
|
FLines.SendNotification(senrAfterIncPaintLock, Self);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomSynEdit.DecPaintLock;
|
procedure TCustomSynEdit.DecPaintLock;
|
||||||
var
|
|
||||||
i: Integer;
|
|
||||||
begin
|
begin
|
||||||
for i := 0 to TSynEditStringList(FLines).AttachedSynEditCount - 1 do
|
if FPaintLockOwnerCnt = 1 then begin
|
||||||
TCustomSynEdit(TSynEditStringList(FLines).AttachedSynEdits[i]).DoDecPaintLock;
|
FLines.SendNotification(senrBeforeDecPaintLock, Self);
|
||||||
|
FLines.SendNotification(senrDecPaintLock, Self); // DoDecPaintLock
|
||||||
|
end;
|
||||||
dec(FPaintLockOwnerCnt);
|
dec(FPaintLockOwnerCnt);
|
||||||
if (PaintLockOwner = Self) and (FPaintLockOwnerCnt = 0) then begin
|
if (PaintLockOwner = Self) and (FPaintLockOwnerCnt = 0) then begin
|
||||||
for i := 0 to TSynEditStringList(FLines).AttachedSynEditCount - 1 do
|
FLines.SendNotification(senrDecOwnedPaintLock, Self); // DoDecForeignPaintLock
|
||||||
if TSynEditStringList(FLines).AttachedSynEdits[i] <> Self then
|
|
||||||
TCustomSynEdit(TSynEditStringList(FLines).AttachedSynEdits[i]).DoDecForeignPaintLock;
|
|
||||||
PaintLockOwner := nil;
|
PaintLockOwner := nil;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomSynEdit.DoIncForeignPaintLock;
|
procedure TCustomSynEdit.DoIncForeignPaintLock(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
FStoredCaredAutoAdjust := FCaret.AutoMoveOnEdit;
|
if Sender = Self then exit;
|
||||||
FCaret.AutoMoveOnEdit := True;
|
FCaret.IncAutoMoveOnEdit;
|
||||||
FBlockSelection.IncPersistentLock;
|
FBlockSelection.IncPersistentLock;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomSynEdit.DoDecForeignPaintLock;
|
procedure TCustomSynEdit.DoDecForeignPaintLock(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
|
if Sender = Self then exit;
|
||||||
FBlockSelection.DecPersistentLock;
|
FBlockSelection.DecPersistentLock;
|
||||||
FCaret.AutoMoveOnEdit := FStoredCaredAutoAdjust;
|
FCaret.DecAutoMoveOnEdit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomSynEdit.DoIncPaintLock;
|
procedure TCustomSynEdit.DoIncPaintLock(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
if FPaintLock = 0 then begin
|
if FPaintLock = 0 then begin
|
||||||
FOldTopLine := FTopLine;
|
FOldTopLine := FTopLine;
|
||||||
@ -1783,7 +1783,7 @@ begin
|
|||||||
FCaret.Lock;
|
FCaret.Lock;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomSynEdit.DoDecPaintLock;
|
procedure TCustomSynEdit.DoDecPaintLock(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
if (FPaintLock=1) and HandleAllocated then begin
|
if (FPaintLock=1) and HandleAllocated then begin
|
||||||
ScanRanges;
|
ScanRanges;
|
||||||
@ -2737,7 +2737,7 @@ begin
|
|||||||
// changes to line / column in one go
|
// changes to line / column in one go
|
||||||
if sfIsDragging in fStateFlags then
|
if sfIsDragging in fStateFlags then
|
||||||
FBlockSelection.IncPersistentLock;
|
FBlockSelection.IncPersistentLock;
|
||||||
DoIncPaintLock; // No editing is taking place
|
DoIncPaintLock(Self); // No editing is taking place
|
||||||
try
|
try
|
||||||
GetCursorPos(CurMousePos);
|
GetCursorPos(CurMousePos);
|
||||||
CurMousePos:=ScreenToClient(CurMousePos);
|
CurMousePos:=ScreenToClient(CurMousePos);
|
||||||
@ -2792,7 +2792,7 @@ begin
|
|||||||
SetBlockEnd(PhysicalToLogicalPos(CaretXY));
|
SetBlockEnd(PhysicalToLogicalPos(CaretXY));
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
DoDecPaintLock;
|
DoDecPaintLock(Self);
|
||||||
if sfIsDragging in fStateFlags then
|
if sfIsDragging in fStateFlags then
|
||||||
FBlockSelection.DecPersistentLock;
|
FBlockSelection.DecPersistentLock;
|
||||||
end;
|
end;
|
||||||
@ -3876,7 +3876,7 @@ procedure TCustomSynEdit.SelectAll;
|
|||||||
var
|
var
|
||||||
LastPt: TPoint;
|
LastPt: TPoint;
|
||||||
begin
|
begin
|
||||||
DoIncPaintLock; // No editing is taking place
|
DoIncPaintLock(Self); // No editing is taking place
|
||||||
LastPt := Point(1, FTheLinesView.Count);
|
LastPt := Point(1, FTheLinesView.Count);
|
||||||
if LastPt.y > 0 then
|
if LastPt.y > 0 then
|
||||||
Inc(LastPt.x, Length(FTheLinesView[LastPt.y - 1]))
|
Inc(LastPt.x, Length(FTheLinesView[LastPt.y - 1]))
|
||||||
@ -3884,7 +3884,7 @@ begin
|
|||||||
LastPt.y := 1;
|
LastPt.y := 1;
|
||||||
SetCaretAndSelection(LogicalToPhysicalPos(LastPt), Point(1, 1), LastPt);
|
SetCaretAndSelection(LogicalToPhysicalPos(LastPt), Point(1, 1), LastPt);
|
||||||
FBlockSelection.ActiveSelectionMode := smNormal;
|
FBlockSelection.ActiveSelectionMode := smNormal;
|
||||||
DoDecPaintLock;
|
DoDecPaintLock(Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomSynEdit.SetHighlightSearch(const ASearch : String; AOptions : TSynSearchOptions);
|
procedure TCustomSynEdit.SetHighlightSearch(const ASearch : String; AOptions : TSynSearchOptions);
|
||||||
@ -4726,13 +4726,13 @@ begin
|
|||||||
if Value.X < 0 then
|
if Value.X < 0 then
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
DoIncPaintLock; // No editing is taking place
|
DoIncPaintLock(Self); // No editing is taking place
|
||||||
FBlockSelection.StartLineBytePos := Value;
|
FBlockSelection.StartLineBytePos := Value;
|
||||||
Value.X := WordBreaker.NextWordEnd(TempString, Value.X);
|
Value.X := WordBreaker.NextWordEnd(TempString, Value.X);
|
||||||
FBlockSelection.EndLineBytePos := Value;
|
FBlockSelection.EndLineBytePos := Value;
|
||||||
FBlockSelection.ActiveSelectionMode := smNormal;
|
FBlockSelection.ActiveSelectionMode := smNormal;
|
||||||
FCaret.LineBytePos := Value;
|
FCaret.LineBytePos := Value;
|
||||||
DoDecPaintLock;
|
DoDecPaintLock(Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomSynEdit.SetLineBlock(Value: TPoint; WithLeadSpaces: Boolean = True);
|
procedure TCustomSynEdit.SetLineBlock(Value: TPoint; WithLeadSpaces: Boolean = True);
|
||||||
@ -4740,7 +4740,7 @@ var
|
|||||||
ALine: string;
|
ALine: string;
|
||||||
x, x2: Integer;
|
x, x2: Integer;
|
||||||
begin
|
begin
|
||||||
DoIncPaintLock; // No editing is taking place
|
DoIncPaintLock(Self); // No editing is taking place
|
||||||
FBlockSelection.StartLineBytePos := Point(1,MinMax(Value.y, 1, FTheLinesView.Count));
|
FBlockSelection.StartLineBytePos := Point(1,MinMax(Value.y, 1, FTheLinesView.Count));
|
||||||
FBlockSelection.EndLineBytePos := Point(1,MinMax(Value.y+1, 1, FTheLinesView.Count));
|
FBlockSelection.EndLineBytePos := Point(1,MinMax(Value.y+1, 1, FTheLinesView.Count));
|
||||||
if (FBlockSelection.StartLinePos >= 1)
|
if (FBlockSelection.StartLinePos >= 1)
|
||||||
@ -4760,7 +4760,7 @@ begin
|
|||||||
FBlockSelection.ActiveSelectionMode := smNormal;
|
FBlockSelection.ActiveSelectionMode := smNormal;
|
||||||
CaretXY := FTheLinesView.LogicalToPhysicalPos(FBlockSelection.EndLineBytePos);
|
CaretXY := FTheLinesView.LogicalToPhysicalPos(FBlockSelection.EndLineBytePos);
|
||||||
//DebugLn(' FFF2 ',Value.X,',',Value.Y,' BlockBegin=',BlockBegin.X,',',BlockBegin.Y,' BlockEnd=',BlockEnd.X,',',BlockEnd.Y);
|
//DebugLn(' FFF2 ',Value.X,',',Value.Y,' BlockBegin=',BlockBegin.X,',',BlockBegin.Y,' BlockEnd=',BlockEnd.X,',',BlockEnd.Y);
|
||||||
DoDecPaintLock;
|
DoDecPaintLock(Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomSynEdit.SetParagraphBlock(Value: TPoint);
|
procedure TCustomSynEdit.SetParagraphBlock(Value: TPoint);
|
||||||
@ -4768,7 +4768,7 @@ var
|
|||||||
ParagraphStartLine, ParagraphEndLine, ParagraphEndX: integer;
|
ParagraphStartLine, ParagraphEndLine, ParagraphEndX: integer;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
DoIncPaintLock; // No editing is taking place
|
DoIncPaintLock(Self); // No editing is taking place
|
||||||
ParagraphStartLine := MinMax(Value.y, 1, FTheLinesView.Count);
|
ParagraphStartLine := MinMax(Value.y, 1, FTheLinesView.Count);
|
||||||
ParagraphEndLine := MinMax(Value.y+1, 1, FTheLinesView.Count);
|
ParagraphEndLine := MinMax(Value.y+1, 1, FTheLinesView.Count);
|
||||||
ParagraphEndX := 1;
|
ParagraphEndX := 1;
|
||||||
@ -4789,7 +4789,7 @@ begin
|
|||||||
FBlockSelection.ActiveSelectionMode := smNormal;
|
FBlockSelection.ActiveSelectionMode := smNormal;
|
||||||
CaretXY := FBlockSelection.EndLineBytePos;
|
CaretXY := FBlockSelection.EndLineBytePos;
|
||||||
//DebugLn(' FFF3 ',Value.X,',',Value.Y,' BlockBegin=',BlockBegin.X,',',BlockBegin.Y,' BlockEnd=',BlockEnd.X,',',BlockEnd.Y);
|
//DebugLn(' FFF3 ',Value.X,',',Value.Y,' BlockBegin=',BlockBegin.X,',',BlockBegin.Y,' BlockEnd=',BlockEnd.X,',',BlockEnd.Y);
|
||||||
DoDecPaintLock;
|
DoDecPaintLock(Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomSynEdit.GetCanUndo: Boolean;
|
function TCustomSynEdit.GetCanUndo: Boolean;
|
||||||
@ -5152,7 +5152,7 @@ begin
|
|||||||
BeginUndoBlock;
|
BeginUndoBlock;
|
||||||
try
|
try
|
||||||
if aCaretMode = scamAdjust then
|
if aCaretMode = scamAdjust then
|
||||||
FCaret.AutoMoveOnEdit := True;
|
FCaret.IncAutoMoveOnEdit;
|
||||||
FInternalBlockSelection.SelectionMode := smNormal;
|
FInternalBlockSelection.SelectionMode := smNormal;
|
||||||
FInternalBlockSelection.StartLineBytePos := aStartPoint;
|
FInternalBlockSelection.StartLineBytePos := aStartPoint;
|
||||||
FInternalBlockSelection.EndLineBytePos := aEndPoint;
|
FInternalBlockSelection.EndLineBytePos := aEndPoint;
|
||||||
@ -5163,7 +5163,7 @@ begin
|
|||||||
FCaret.LineBytePos := FInternalBlockSelection.StartLineBytePos;
|
FCaret.LineBytePos := FInternalBlockSelection.StartLineBytePos;
|
||||||
finally
|
finally
|
||||||
if aCaretMode = scamAdjust then
|
if aCaretMode = scamAdjust then
|
||||||
FCaret.AutoMoveOnEdit := False;
|
FCaret.DecAutoMoveOnEdit;
|
||||||
EndUndoBlock;
|
EndUndoBlock;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -5200,11 +5200,11 @@ begin
|
|||||||
then begin
|
then begin
|
||||||
NewCaret:=Point(fBookMarks[BookMark].Column, fBookMarks[BookMark].Line);
|
NewCaret:=Point(fBookMarks[BookMark].Column, fBookMarks[BookMark].Line);
|
||||||
LogCaret:=PhysicalToLogicalPos(NewCaret);
|
LogCaret:=PhysicalToLogicalPos(NewCaret);
|
||||||
DoIncPaintLock; // No editing is taking place
|
DoIncPaintLock(Self); // No editing is taking place
|
||||||
FCaret.LineCharPos := NewCaret;
|
FCaret.LineCharPos := NewCaret;
|
||||||
SetBlockEnd(LogCaret);
|
SetBlockEnd(LogCaret);
|
||||||
SetBlockBegin(LogCaret);
|
SetBlockBegin(LogCaret);
|
||||||
DoDecPaintLock;
|
DoDecPaintLock(Self);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -5606,7 +5606,7 @@ begin
|
|||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
exclude(fStateFlags, sfEnsureCursorPos);
|
exclude(fStateFlags, sfEnsureCursorPos);
|
||||||
DoIncPaintLock; // No editing is taking place
|
DoIncPaintLock(Self); // No editing is taking place
|
||||||
try
|
try
|
||||||
// Make sure X is visible
|
// Make sure X is visible
|
||||||
//DebugLn('[TCustomSynEdit.EnsureCursorPosVisible] A CaretX=',CaretX,' LeftChar=',LeftChar,' CharsInWindow=',CharsInWindow,' ClientWidth=',ClientWidth);
|
//DebugLn('[TCustomSynEdit.EnsureCursorPosVisible] A CaretX=',CaretX,' LeftChar=',LeftChar,' CharsInWindow=',CharsInWindow,' ClientWidth=',ClientWidth);
|
||||||
@ -5651,7 +5651,7 @@ begin
|
|||||||
else
|
else
|
||||||
TopLine := TopLine; //mh 2000-10-19
|
TopLine := TopLine; //mh 2000-10-19
|
||||||
finally
|
finally
|
||||||
DoDecPaintLock;
|
DoDecPaintLock(Self);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -7167,7 +7167,7 @@ begin
|
|||||||
NewCaret.Y := FFoldedLinesView.TextPosAddLines(NewCaret.Y, +1);
|
NewCaret.Y := FFoldedLinesView.TextPosAddLines(NewCaret.Y, +1);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
DoIncPaintLock; // No editing is taking place
|
DoIncPaintLock(Self); // No editing is taking place
|
||||||
FCaret.IncForcePastEOL;
|
FCaret.IncForcePastEOL;
|
||||||
if DX > 0 then
|
if DX > 0 then
|
||||||
FCaret.IncForceAdjustToNextChar;
|
FCaret.IncForceAdjustToNextChar;
|
||||||
@ -7175,7 +7175,7 @@ begin
|
|||||||
FCaret.DecForcePastEOL;
|
FCaret.DecForcePastEOL;
|
||||||
if DX > 0 then
|
if DX > 0 then
|
||||||
FCaret.DecForceAdjustToNextChar;
|
FCaret.DecForceAdjustToNextChar;
|
||||||
DoDecPaintLock;
|
DoDecPaintLock(Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomSynEdit.MoveCaretVert(DY: integer);
|
procedure TCustomSynEdit.MoveCaretVert(DY: integer);
|
||||||
@ -7187,9 +7187,9 @@ begin
|
|||||||
OldCaret:=CaretXY;
|
OldCaret:=CaretXY;
|
||||||
NewCaret:=OldCaret;
|
NewCaret:=OldCaret;
|
||||||
NewCaret.Y:=FFoldedLinesView.TextPosAddLines(NewCaret.Y, DY);
|
NewCaret.Y:=FFoldedLinesView.TextPosAddLines(NewCaret.Y, DY);
|
||||||
DoIncPaintLock; // No editing is taking place
|
DoIncPaintLock(Self); // No editing is taking place
|
||||||
FCaret.LinePos := NewCaret.Y;
|
FCaret.LinePos := NewCaret.Y;
|
||||||
DoDecPaintLock;
|
DoDecPaintLock(Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomSynEdit.SetCaretAndSelection(const ptCaret, ptBefore,
|
procedure TCustomSynEdit.SetCaretAndSelection(const ptCaret, ptBefore,
|
||||||
@ -7197,14 +7197,14 @@ procedure TCustomSynEdit.SetCaretAndSelection(const ptCaret, ptBefore,
|
|||||||
// caret is physical (screen)
|
// caret is physical (screen)
|
||||||
// Before, After is logical (byte)
|
// Before, After is logical (byte)
|
||||||
begin
|
begin
|
||||||
DoIncPaintLock; // No editing is taking place
|
DoIncPaintLock(Self); // No editing is taking place
|
||||||
CaretXY := ptCaret;
|
CaretXY := ptCaret;
|
||||||
SetBlockBegin(ptBefore);
|
SetBlockBegin(ptBefore);
|
||||||
SetBlockEnd(ptAfter);
|
SetBlockEnd(ptAfter);
|
||||||
if Mode <> smCurrent then
|
if Mode <> smCurrent then
|
||||||
FBlockSelection.ActiveSelectionMode := Mode;
|
FBlockSelection.ActiveSelectionMode := Mode;
|
||||||
AquirePrimarySelection;
|
AquirePrimarySelection;
|
||||||
DoDecPaintLock;
|
DoDecPaintLock(Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomSynEdit.RecalcCharExtent;
|
procedure TCustomSynEdit.RecalcCharExtent;
|
||||||
|
@ -167,7 +167,7 @@ type
|
|||||||
TSynEditCaret = class(TSynEditPointBase)
|
TSynEditCaret = class(TSynEditPointBase)
|
||||||
private
|
private
|
||||||
FAllowPastEOL: Boolean;
|
FAllowPastEOL: Boolean;
|
||||||
FAutoMoveOnEdit: Boolean;
|
FAutoMoveOnEdit: Integer;
|
||||||
FForcePastEOL: Integer;
|
FForcePastEOL: Integer;
|
||||||
FForceAdjustToNextChar: Integer;
|
FForceAdjustToNextChar: Integer;
|
||||||
FKeepCaretX: Boolean;
|
FKeepCaretX: Boolean;
|
||||||
@ -215,6 +215,8 @@ type
|
|||||||
procedure DecForcePastEOL;
|
procedure DecForcePastEOL;
|
||||||
procedure IncForceAdjustToNextChar;
|
procedure IncForceAdjustToNextChar;
|
||||||
procedure DecForceAdjustToNextChar;
|
procedure DecForceAdjustToNextChar;
|
||||||
|
procedure IncAutoMoveOnEdit;
|
||||||
|
procedure DecAutoMoveOnEdit;
|
||||||
procedure ChangeOnTouch;
|
procedure ChangeOnTouch;
|
||||||
function IsAtLineChar(aPoint: TPoint): Boolean;
|
function IsAtLineChar(aPoint: TPoint): Boolean;
|
||||||
function IsAtLineByte(aPoint: TPoint): Boolean;
|
function IsAtLineByte(aPoint: TPoint): Boolean;
|
||||||
@ -239,7 +241,6 @@ type
|
|||||||
property AllowPastEOL: Boolean read FAllowPastEOL write SetAllowPastEOL;
|
property AllowPastEOL: Boolean read FAllowPastEOL write SetAllowPastEOL;
|
||||||
property KeepCaretX: Boolean read FKeepCaretX write SetKeepCaretX;
|
property KeepCaretX: Boolean read FKeepCaretX write SetKeepCaretX;
|
||||||
property MaxLeftChar: PInteger write FMaxLeftChar;
|
property MaxLeftChar: PInteger write FMaxLeftChar;
|
||||||
property AutoMoveOnEdit: Boolean read FAutoMoveOnEdit write FAutoMoveOnEdit;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
@ -315,6 +316,7 @@ begin
|
|||||||
fCharPos:= 1;
|
fCharPos:= 1;
|
||||||
FAllowPastEOL := True;
|
FAllowPastEOL := True;
|
||||||
FForcePastEOL := 0;
|
FForcePastEOL := 0;
|
||||||
|
FAutoMoveOnEdit := 0;
|
||||||
if FLines <> nil then
|
if FLines <> nil then
|
||||||
FLines.AddEditHandler(@DoLinesEdited);
|
FLines.AddEditHandler(@DoLinesEdited);
|
||||||
end;
|
end;
|
||||||
@ -360,6 +362,16 @@ begin
|
|||||||
Dec(FForceAdjustToNextChar);
|
Dec(FForceAdjustToNextChar);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TSynEditCaret.IncAutoMoveOnEdit;
|
||||||
|
begin
|
||||||
|
inc(FAutoMoveOnEdit);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSynEditCaret.DecAutoMoveOnEdit;
|
||||||
|
begin
|
||||||
|
dec(FAutoMoveOnEdit);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TSynEditCaret.ChangeOnTouch;
|
procedure TSynEditCaret.ChangeOnTouch;
|
||||||
begin
|
begin
|
||||||
FChangeOnTouch := True;
|
FChangeOnTouch := True;
|
||||||
@ -619,7 +631,7 @@ procedure TSynEditCaret.DoLinesEdited(Sender: TSynEditStrings; aLinePos, aBytePo
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if FAutoMoveOnEdit then begin
|
if FAutoMoveOnEdit > 0 then begin
|
||||||
IncForcePastEOL;
|
IncForcePastEOL;
|
||||||
LineBytePos := AdjustPoint(LineBytePos);
|
LineBytePos := AdjustPoint(LineBytePos);
|
||||||
DecForcePastEOL;
|
DecForcePastEOL;
|
||||||
|
@ -47,7 +47,14 @@ type
|
|||||||
senrBeginUpdate, senrEndUpdate,
|
senrBeginUpdate, senrEndUpdate,
|
||||||
senrCleared,
|
senrCleared,
|
||||||
senrUndoRedoAdded,
|
senrUndoRedoAdded,
|
||||||
senrModifiedChanged // The modified flag was changed
|
senrModifiedChanged, // The modified flag was changed
|
||||||
|
// Paintlocks are managed by SynEdit, but need distribution to shared edits
|
||||||
|
senrIncOwnedPaintLock, // Inform other SynEdits (ForeignPaintLock)
|
||||||
|
senrDecOwnedPaintLock,
|
||||||
|
senrIncPaintLock, // Actual PaintLock
|
||||||
|
senrDecPaintLock,
|
||||||
|
senrAfterIncPaintLock, // For plugins, etc...
|
||||||
|
senrBeforeDecPaintLock
|
||||||
);
|
);
|
||||||
|
|
||||||
TPhysicalCharWidths = Array of Shortint;
|
TPhysicalCharWidths = Array of Shortint;
|
||||||
@ -148,10 +155,6 @@ type
|
|||||||
function GetIsUndoing: Boolean; virtual; abstract;
|
function GetIsUndoing: Boolean; virtual; abstract;
|
||||||
procedure SetIsRedoing(const AValue: Boolean); virtual; abstract;
|
procedure SetIsRedoing(const AValue: Boolean); virtual; abstract;
|
||||||
function GetIsRedoing: Boolean; virtual; abstract;
|
function GetIsRedoing: Boolean; virtual; abstract;
|
||||||
procedure SendNotification(AReason: TSynEditNotifyReason;
|
|
||||||
ASender: TSynEditStrings; aIndex, aCount: Integer;
|
|
||||||
aBytePos: Integer = -1; aLen: Integer = 0;
|
|
||||||
aTxt: String = ''); virtual; abstract;
|
|
||||||
procedure IgnoreSendNotification(AReason: TSynEditNotifyReason;
|
procedure IgnoreSendNotification(AReason: TSynEditNotifyReason;
|
||||||
ReEnable: Boolean); virtual; abstract;
|
ReEnable: Boolean); virtual; abstract;
|
||||||
public
|
public
|
||||||
@ -181,6 +184,12 @@ type
|
|||||||
procedure AddEditHandler(AHandler: TStringListLineEditEvent);
|
procedure AddEditHandler(AHandler: TStringListLineEditEvent);
|
||||||
procedure RemoveEditHandler(AHandler: TStringListLineEditEvent);
|
procedure RemoveEditHandler(AHandler: TStringListLineEditEvent);
|
||||||
procedure SendHighlightChanged(aIndex, aCount: Integer); override;
|
procedure SendHighlightChanged(aIndex, aCount: Integer); override;
|
||||||
|
procedure SendNotification(AReason: TSynEditNotifyReason;
|
||||||
|
ASender: TSynEditStrings; aIndex, aCount: Integer;
|
||||||
|
aBytePos: Integer = -1; aLen: Integer = 0;
|
||||||
|
aTxt: String = ''); virtual; abstract;
|
||||||
|
procedure SendNotification(AReason: TSynEditNotifyReason;
|
||||||
|
ASender: TObject); virtual; abstract;
|
||||||
public
|
public
|
||||||
function GetPhysicalCharWidths(Index: Integer): TPhysicalCharWidths;
|
function GetPhysicalCharWidths(Index: Integer): TPhysicalCharWidths;
|
||||||
function GetPhysicalCharWidths(const Line: String; Index: Integer): TPhysicalCharWidths; virtual; abstract;
|
function GetPhysicalCharWidths(const Line: String; Index: Integer): TPhysicalCharWidths; virtual; abstract;
|
||||||
@ -230,10 +239,6 @@ type
|
|||||||
function GetExpandedString(Index: integer): string; override;
|
function GetExpandedString(Index: integer): string; override;
|
||||||
function GetLengthOfLongestLine: integer; override;
|
function GetLengthOfLongestLine: integer; override;
|
||||||
|
|
||||||
procedure SendNotification(AReason: TSynEditNotifyReason;
|
|
||||||
ASender: TSynEditStrings; aIndex, aCount: Integer;
|
|
||||||
aBytePos: Integer = -1; aLen: Integer = 0;
|
|
||||||
aTxt: String = ''); override;
|
|
||||||
procedure IgnoreSendNotification(AReason: TSynEditNotifyReason;
|
procedure IgnoreSendNotification(AReason: TSynEditNotifyReason;
|
||||||
IncIgnore: Boolean); override;
|
IncIgnore: Boolean); override;
|
||||||
function GetUndoList: TSynEditUndoList; override;
|
function GetUndoList: TSynEditUndoList; override;
|
||||||
@ -273,6 +278,12 @@ type
|
|||||||
AHandler: TMethod); override;
|
AHandler: TMethod); override;
|
||||||
procedure RemoveGenericHandler(AReason: TSynEditNotifyReason;
|
procedure RemoveGenericHandler(AReason: TSynEditNotifyReason;
|
||||||
AHandler: TMethod); override;
|
AHandler: TMethod); override;
|
||||||
|
procedure SendNotification(AReason: TSynEditNotifyReason;
|
||||||
|
ASender: TSynEditStrings; aIndex, aCount: Integer;
|
||||||
|
aBytePos: Integer = -1; aLen: Integer = 0;
|
||||||
|
aTxt: String = ''); override;
|
||||||
|
procedure SendNotification(AReason: TSynEditNotifyReason;
|
||||||
|
ASender: TObject); override;
|
||||||
|
|
||||||
function GetPhysicalCharWidths(const Line: String; Index: Integer): TPhysicalCharWidths; override;
|
function GetPhysicalCharWidths(const Line: String; Index: Integer): TPhysicalCharWidths; override;
|
||||||
property NextLines: TSynEditStrings read fSynStrings write fSynStrings;
|
property NextLines: TSynEditStrings read fSynStrings write fSynStrings;
|
||||||
@ -810,6 +821,12 @@ begin
|
|||||||
fSynStrings.SendNotification(AReason, ASender, aIndex, aCount, aBytePos, aLen, aTxt);
|
fSynStrings.SendNotification(AReason, ASender, aIndex, aCount, aBytePos, aLen, aTxt);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TSynEditStringsLinked.SendNotification(AReason: TSynEditNotifyReason;
|
||||||
|
ASender: TObject);
|
||||||
|
begin
|
||||||
|
fSynStrings.SendNotification(AReason, ASender);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TSynEditStringsLinked.IgnoreSendNotification(AReason: TSynEditNotifyReason;
|
procedure TSynEditStringsLinked.IgnoreSendNotification(AReason: TSynEditNotifyReason;
|
||||||
IncIgnore: Boolean);
|
IncIgnore: Boolean);
|
||||||
begin
|
begin
|
||||||
@ -1215,6 +1232,7 @@ end;
|
|||||||
|
|
||||||
function TSynEditStorageMem.GetItemPointer(Index: Integer): Pointer;
|
function TSynEditStorageMem.GetItemPointer(Index: Integer): Pointer;
|
||||||
begin
|
begin
|
||||||
|
//if (Index >= FCount) or (FCount > FCapacity) then raise Exception.Create('Bad Index');
|
||||||
Result := Pointer(FMem + Index * ItemSize);
|
Result := Pointer(FMem + Index * ItemSize);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -157,9 +157,6 @@ type
|
|||||||
procedure SetIsRedoing(const AValue: Boolean); override;
|
procedure SetIsRedoing(const AValue: Boolean); override;
|
||||||
function GetIsRedoing: Boolean; override;
|
function GetIsRedoing: Boolean; override;
|
||||||
procedure UndoRedoAdded(Sender: TObject);
|
procedure UndoRedoAdded(Sender: TObject);
|
||||||
procedure SendNotification(AReason: TSynEditNotifyReason;
|
|
||||||
ASender: TSynEditStrings; aIndex, aCount: Integer;
|
|
||||||
aBytePos: Integer = -1; aLen: Integer = 0; aTxt: String = ''); override;
|
|
||||||
procedure IgnoreSendNotification(AReason: TSynEditNotifyReason;
|
procedure IgnoreSendNotification(AReason: TSynEditNotifyReason;
|
||||||
IncIgnore: Boolean); override;
|
IncIgnore: Boolean); override;
|
||||||
|
|
||||||
@ -199,6 +196,11 @@ type
|
|||||||
AHandler: TMethod); override;
|
AHandler: TMethod); override;
|
||||||
procedure RemoveGenericHandler(AReason: TSynEditNotifyReason;
|
procedure RemoveGenericHandler(AReason: TSynEditNotifyReason;
|
||||||
AHandler: TMethod); override;
|
AHandler: TMethod); override;
|
||||||
|
procedure SendNotification(AReason: TSynEditNotifyReason;
|
||||||
|
ASender: TSynEditStrings; aIndex, aCount: Integer;
|
||||||
|
aBytePos: Integer = -1; aLen: Integer = 0; aTxt: String = ''); override;
|
||||||
|
procedure SendNotification(AReason: TSynEditNotifyReason;
|
||||||
|
ASender: TObject); override;
|
||||||
function GetPhysicalCharWidths(const Line: String; Index: Integer): TPhysicalCharWidths; override;
|
function GetPhysicalCharWidths(const Line: String; Index: Integer): TPhysicalCharWidths; override;
|
||||||
// For Textbuffersharing
|
// For Textbuffersharing
|
||||||
procedure AttachSynEdit(AEdit: TSynEditBase);
|
procedure AttachSynEdit(AEdit: TSynEditBase);
|
||||||
@ -422,15 +424,15 @@ begin
|
|||||||
FIsRedoing := False;
|
FIsRedoing := False;
|
||||||
FModified := False;
|
FModified := False;
|
||||||
|
|
||||||
FNotifyLists[senrLineCount] := TLineRangeNotificationList.Create;
|
for r := low(TSynEditNotifyReason) to high(TSynEditNotifyReason)
|
||||||
FNotifyLists[senrLineChange] := TLineRangeNotificationList.Create;
|
do case r of
|
||||||
FNotifyLists[senrHighlightChanged] := TLineRangeNotificationList.Create;
|
senrLineCount, senrLineChange, senrHighlightChanged:
|
||||||
FNotifyLists[senrEditAction] := TLineEditNotificationList.Create;
|
FNotifyLists[r] := TLineRangeNotificationList.Create;
|
||||||
FNotifyLists[senrBeginUpdate] := TSynMethodList.Create;
|
senrEditAction:
|
||||||
FNotifyLists[senrEndUpdate] := TSynMethodList.Create;
|
FNotifyLists[r] := TLineEditNotificationList.Create;
|
||||||
FNotifyLists[senrCleared] := TSynMethodList.Create;
|
else
|
||||||
FNotifyLists[senrUndoRedoAdded] := TSynMethodList.Create;
|
FNotifyLists[r] := TSynMethodList.Create;
|
||||||
FNotifyLists[senrModifiedChanged] := TSynMethodList.Create;
|
end;
|
||||||
|
|
||||||
for r := low(TSynEditNotifyReason) to high(TSynEditNotifyReason) do
|
for r := low(TSynEditNotifyReason) to high(TSynEditNotifyReason) do
|
||||||
FIgnoreSendNotification[r] := 0;
|
FIgnoreSendNotification[r] := 0;
|
||||||
@ -1082,11 +1084,19 @@ begin
|
|||||||
.CallRangeNotifyEvents(ASender, aIndex, aCount);
|
.CallRangeNotifyEvents(ASender, aIndex, aCount);
|
||||||
senrEditAction:
|
senrEditAction:
|
||||||
// aindex is mis-named (linepos) for edit action
|
// aindex is mis-named (linepos) for edit action
|
||||||
TLineEditNotificationList(FNotifyLists[senrEditAction])
|
TLineEditNotificationList(FNotifyLists[AReason])
|
||||||
.CallRangeNotifyEvents(ASender, aIndex, aBytePos, aLen, aCount, aTxt);
|
.CallRangeNotifyEvents(ASender, aIndex, aBytePos, aLen, aCount, aTxt);
|
||||||
|
else
|
||||||
|
raise Exception.Create('Invalid');
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TSynEditStringList.SendNotification(AReason: TSynEditNotifyReason;
|
||||||
|
ASender: TObject);
|
||||||
|
begin
|
||||||
|
FNotifyLists[AReason].CallNotifyEvents(ASender);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TSynEditStringList.IgnoreSendNotification(AReason: TSynEditNotifyReason;
|
procedure TSynEditStringList.IgnoreSendNotification(AReason: TSynEditNotifyReason;
|
||||||
IncIgnore: Boolean);
|
IncIgnore: Boolean);
|
||||||
begin
|
begin
|
||||||
|
@ -215,7 +215,7 @@ type
|
|||||||
procedure DoSelectionChanged(Sender: TObject);
|
procedure DoSelectionChanged(Sender: TObject);
|
||||||
procedure DoScanSelection(Data: PtrInt);
|
procedure DoScanSelection(Data: PtrInt);
|
||||||
procedure DoOnDeactivate; override;
|
procedure DoOnDeactivate; override;
|
||||||
procedure DoBeforeEdit(aX, aY: Integer; aUndoRedo: Boolean); override;
|
procedure DoBeforeEdit(aX, aY, aCount, aLineBrkCnt: Integer; aUndoRedo: Boolean); override;
|
||||||
|
|
||||||
function MaybeHandleMouseAction(var AnInfo: TSynEditMouseActionInfo;
|
function MaybeHandleMouseAction(var AnInfo: TSynEditMouseActionInfo;
|
||||||
HandleActionProc: TSynEditMouseActionHandler): Boolean;
|
HandleActionProc: TSynEditMouseActionHandler): Boolean;
|
||||||
@ -1212,7 +1212,7 @@ begin
|
|||||||
inherited DoOnDeactivate;
|
inherited DoOnDeactivate;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSynPluginSyncroEdit.DoBeforeEdit(aX, aY: Integer; aUndoRedo: Boolean);
|
procedure TSynPluginSyncroEdit.DoBeforeEdit(aX, aY, aCount, aLineBrkCnt: Integer; aUndoRedo: Boolean);
|
||||||
begin
|
begin
|
||||||
if (FMode = spseSelecting) then begin
|
if (FMode = spseSelecting) then begin
|
||||||
FWordIndex.Clear;
|
FWordIndex.Clear;
|
||||||
@ -1220,7 +1220,7 @@ begin
|
|||||||
FMode := spseInvalid;
|
FMode := spseInvalid;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
inherited DoBeforeEdit(aX, aY, aUndoRedo);
|
inherited DoBeforeEdit(aX, aY, aCount, aLineBrkCnt, aUndoRedo);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TSynPluginSyncroEdit.MaybeHandleMouseAction(var AnInfo: TSynEditMouseActionInfo;
|
function TSynPluginSyncroEdit.MaybeHandleMouseAction(var AnInfo: TSynEditMouseActionInfo;
|
||||||
|
@ -26,9 +26,9 @@ unit SynPluginSyncronizedEditBase;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, math, Graphics,
|
Classes, SysUtils, math, Graphics, LCLProc,
|
||||||
SynEditMiscClasses, SynEdit, SynEditMarkup, SynEditMiscProcs, SynEditTextBase,
|
SynEditMiscClasses, SynEdit, SynEditMarkup, SynEditMiscProcs, SynEditTextBase,
|
||||||
SynEditTextTrimmer;
|
SynEditTextTrimmer, SynEditKeyCmds;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
@ -134,6 +134,30 @@ type
|
|||||||
property CellGroupForArea: Integer read FCellIdForArea write FCellIdForArea;
|
property CellGroupForArea: Integer read FCellIdForArea write FCellIdForArea;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TSynPluginSyncronizedEditChangeAction }
|
||||||
|
|
||||||
|
TSynPluginSyncronizedEditChangeAction = record
|
||||||
|
CellIndex: Integer;
|
||||||
|
cLinePos, cBytePos, Count, LineBrkCount: Integer;
|
||||||
|
Text: String;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ TSynPluginSyncronizedEditChangeList }
|
||||||
|
|
||||||
|
TSynPluginSyncronizedEditChangeList = class
|
||||||
|
private
|
||||||
|
FList: array of TSynPluginSyncronizedEditChangeAction;
|
||||||
|
FCount: Integer;
|
||||||
|
function GetItems(Index: Integer): TSynPluginSyncronizedEditChangeAction;
|
||||||
|
public
|
||||||
|
procedure Clear;
|
||||||
|
procedure Add(aCellIndex, aLinePos, aBytePos, aCount, aLineBrkCnt: Integer;
|
||||||
|
aText: String);
|
||||||
|
property Count: Integer read FCount;
|
||||||
|
property Items[Index: Integer]: TSynPluginSyncronizedEditChangeAction
|
||||||
|
read GetItems; default;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TSynPluginSyncronizedEditBase }
|
{ TSynPluginSyncronizedEditBase }
|
||||||
|
|
||||||
TSynPluginSyncronizedEditBase = class(TSynEditPlugin)
|
TSynPluginSyncronizedEditBase = class(TSynEditPlugin)
|
||||||
@ -141,10 +165,13 @@ type
|
|||||||
FActive: Boolean;
|
FActive: Boolean;
|
||||||
FCells: TSynPluginSyncronizedEditList;
|
FCells: TSynPluginSyncronizedEditList;
|
||||||
FCurrentCell: Integer;
|
FCurrentCell: Integer;
|
||||||
|
FChangeList: TSynPluginSyncronizedEditChangeList;
|
||||||
FAreaMarkupEnabled: Boolean;
|
FAreaMarkupEnabled: Boolean;
|
||||||
FMarkupEnabled: Boolean;
|
FMarkupEnabled: Boolean;
|
||||||
FEnabled: Boolean;
|
FEnabled: Boolean;
|
||||||
FEditing: Boolean;
|
FEditing: Boolean;
|
||||||
|
FPaintLock: Integer;
|
||||||
|
FOwnPaintLock: Integer;
|
||||||
|
|
||||||
fMarkupInfo: TSynSelectedColor;
|
fMarkupInfo: TSynSelectedColor;
|
||||||
fMarkupInfoSync: TSynSelectedColor;
|
fMarkupInfoSync: TSynSelectedColor;
|
||||||
@ -167,11 +194,16 @@ type
|
|||||||
procedure SetEditor(const AValue: TCustomSynEdit); override;
|
procedure SetEditor(const AValue: TCustomSynEdit); override;
|
||||||
procedure DoLinesEdited(Sender: TSynEditStrings; aLinePos, aBytePos, aCount,
|
procedure DoLinesEdited(Sender: TSynEditStrings; aLinePos, aBytePos, aCount,
|
||||||
aLineBrkCnt: Integer; aText: String);
|
aLineBrkCnt: Integer; aText: String);
|
||||||
procedure DoBeforeEdit(aX, aY: Integer; aUndoRedo: Boolean); virtual;
|
procedure ApplyChangeList;
|
||||||
|
procedure DoBeforeEdit(aX, aY, aCount, aLineBrkCnt: Integer; aUndoRedo: Boolean); virtual;
|
||||||
procedure DoAfterEdit(aX, aY: Integer; aUndoRedo: Boolean); virtual;
|
procedure DoAfterEdit(aX, aY: Integer; aUndoRedo: Boolean); virtual;
|
||||||
|
procedure DoPaintLockStarted; virtual;
|
||||||
|
procedure DoPaintLockEnded; virtual;
|
||||||
procedure DoClear; virtual;
|
procedure DoClear; virtual;
|
||||||
procedure DoOnActivate; virtual;
|
procedure DoOnActivate; virtual;
|
||||||
procedure DoOnDeactivate; virtual;
|
procedure DoOnDeactivate; virtual;
|
||||||
|
procedure DoIncPaintLock(Sender: TObject);
|
||||||
|
procedure DoDecPaintLock(Sender: TObject);
|
||||||
property CurrentCell: Integer read FCurrentCell write SetCurrentCell;
|
property CurrentCell: Integer read FCurrentCell write SetCurrentCell;
|
||||||
property Cells: TSynPluginSyncronizedEditList read FCells;
|
property Cells: TSynPluginSyncronizedEditList read FCells;
|
||||||
property Markup: TSynPluginSyncronizedEditMarkup read FMarkup;
|
property Markup: TSynPluginSyncronizedEditMarkup read FMarkup;
|
||||||
@ -207,15 +239,17 @@ type
|
|||||||
FUndoRealCount, FRedoRealCount: Integer;
|
FUndoRealCount, FRedoRealCount: Integer;
|
||||||
FRedoList: TSynEditUndoList;
|
FRedoList: TSynEditUndoList;
|
||||||
FUndoList: TSynEditUndoList;
|
FUndoList: TSynEditUndoList;
|
||||||
|
FExternalEditLock: Integer;
|
||||||
protected
|
protected
|
||||||
procedure SetUndoStart; // Handle undo/redo stuff
|
procedure SetUndoStart; // Handle undo/redo stuff
|
||||||
procedure SetEditor(const AValue: TCustomSynEdit); override;
|
procedure SetEditor(const AValue: TCustomSynEdit); override;
|
||||||
procedure DoOnActivate; override;
|
procedure DoOnActivate; override;
|
||||||
procedure DoOnDeactivate; override;
|
procedure DoOnDeactivate; override;
|
||||||
procedure DoBeforeEdit(aX, aY: Integer; aUndoRedo: Boolean); override;
|
procedure DoBeforeEdit(aX, aY, aCount, aLineBrkCnt: Integer; aUndoRedo: Boolean); override;
|
||||||
procedure DoAfterEdit(aX, aY: Integer; aUndoRedo: Boolean); override;
|
procedure DoAfterEdit(aX, aY: Integer; aUndoRedo: Boolean); override;
|
||||||
|
procedure DoPaintLockStarted; override;
|
||||||
|
procedure DoPaintLockEnded; override;
|
||||||
procedure UpdateCurrentCell;
|
procedure UpdateCurrentCell;
|
||||||
procedure UpdateCurrentCell(aLogX, aLogY: Integer);
|
|
||||||
procedure DoCaretChanged(Sender: TObject);
|
procedure DoCaretChanged(Sender: TObject);
|
||||||
property LastCell: Integer read FLastCell;
|
property LastCell: Integer read FLastCell;
|
||||||
protected
|
protected
|
||||||
@ -225,8 +259,10 @@ type
|
|||||||
procedure CellCaretHome;
|
procedure CellCaretHome;
|
||||||
procedure CellCaretEnd;
|
procedure CellCaretEnd;
|
||||||
public
|
public
|
||||||
//constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
//destructor Destroy; override;
|
//destructor Destroy; override;
|
||||||
|
procedure IncExternalEditLock;
|
||||||
|
procedure DecExternalEditLock;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
@ -605,6 +641,34 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TSynPluginSyncronizedEditChangeList }
|
||||||
|
|
||||||
|
function TSynPluginSyncronizedEditChangeList.GetItems(Index: Integer): TSynPluginSyncronizedEditChangeAction;
|
||||||
|
begin
|
||||||
|
Result := FList[Index];
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSynPluginSyncronizedEditChangeList.Clear;
|
||||||
|
begin
|
||||||
|
FList := nil;
|
||||||
|
FCount := 0;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSynPluginSyncronizedEditChangeList.Add(aCellIndex, aLinePos, aBytePos,
|
||||||
|
aCount, aLineBrkCnt: Integer; aText: String);
|
||||||
|
begin
|
||||||
|
if length(FList) <= FCount then
|
||||||
|
SetLength(FList, FCount + 4);
|
||||||
|
|
||||||
|
FList[FCount].CellIndex := aCellIndex;
|
||||||
|
FList[FCount].cLinePos := aLinePos;
|
||||||
|
FList[FCount].cBytePos := aBytePos;
|
||||||
|
FList[FCount].Count := aCount;
|
||||||
|
FList[FCount].LineBrkCount := aLineBrkCnt;
|
||||||
|
FList[FCount].Text := aText;
|
||||||
|
inc(FCount);
|
||||||
|
end;
|
||||||
|
|
||||||
{ TSynPluginSyncronizedEditBase }
|
{ TSynPluginSyncronizedEditBase }
|
||||||
|
|
||||||
constructor TSynPluginSyncronizedEditBase.Create(AOwner: TComponent);
|
constructor TSynPluginSyncronizedEditBase.Create(AOwner: TComponent);
|
||||||
@ -636,6 +700,7 @@ begin
|
|||||||
|
|
||||||
FCells := TSynPluginSyncronizedEditList.Create;
|
FCells := TSynPluginSyncronizedEditList.Create;
|
||||||
CurrentCell := -1;
|
CurrentCell := -1;
|
||||||
|
FChangeList := TSynPluginSyncronizedEditChangeList.Create;
|
||||||
AreaMarkupEnabled := False;
|
AreaMarkupEnabled := False;
|
||||||
MarkupEnabled := True;
|
MarkupEnabled := True;
|
||||||
inherited Create(AOwner);
|
inherited Create(AOwner);
|
||||||
@ -654,6 +719,7 @@ begin
|
|||||||
FreeAndNil(fMarkupInfoSync);
|
FreeAndNil(fMarkupInfoSync);
|
||||||
FreeAndNil(fMarkupInfoCurrent);
|
FreeAndNil(fMarkupInfoCurrent);
|
||||||
FreeAndNil(fMarkupInfoArea);
|
FreeAndNil(fMarkupInfoArea);
|
||||||
|
FreeAndNil(FChangeList);
|
||||||
inherited;
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -671,6 +737,8 @@ begin
|
|||||||
Active := False;
|
Active := False;
|
||||||
if Editor <> nil then begin
|
if Editor <> nil then begin
|
||||||
ViewedTextBuffer.RemoveEditHandler(@DoLinesEdited);
|
ViewedTextBuffer.RemoveEditHandler(@DoLinesEdited);
|
||||||
|
ViewedTextBuffer.RemoveNotifyHandler(senrAfterIncPaintLock, @DoIncPaintLock);
|
||||||
|
ViewedTextBuffer.RemoveNotifyHandler(senrBeforeDecPaintLock, @DoDecPaintLock);
|
||||||
if FMarkup <> nil then begin
|
if FMarkup <> nil then begin
|
||||||
TSynEditMarkupManager(MarkupMgr).RemoveMarkUp(FMarkup);
|
TSynEditMarkupManager(MarkupMgr).RemoveMarkUp(FMarkup);
|
||||||
FreeAndNil(FMarkup);
|
FreeAndNil(FMarkup);
|
||||||
@ -693,6 +761,8 @@ begin
|
|||||||
TSynEditMarkupManager(MarkupMgr).AddMarkUp(FMarkupArea, True);
|
TSynEditMarkupManager(MarkupMgr).AddMarkUp(FMarkupArea, True);
|
||||||
MarkupChanged(nil);
|
MarkupChanged(nil);
|
||||||
ViewedTextBuffer.AddEditHandler(@DoLinesEdited);
|
ViewedTextBuffer.AddEditHandler(@DoLinesEdited);
|
||||||
|
ViewedTextBuffer.AddNotifyHandler(senrAfterIncPaintLock, @DoIncPaintLock);
|
||||||
|
ViewedTextBuffer.AddNotifyHandler(senrBeforeDecPaintLock, @DoDecPaintLock);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -812,17 +882,15 @@ var
|
|||||||
var
|
var
|
||||||
i, a: Integer;
|
i, a: Integer;
|
||||||
CurCell: TSynPluginSyncronizedEditCell;
|
CurCell: TSynPluginSyncronizedEditCell;
|
||||||
Y2, X2: Integer;
|
|
||||||
chg: Boolean;
|
chg: Boolean;
|
||||||
edit: Boolean;
|
edit: Boolean;
|
||||||
CaretPos: TPoint;
|
|
||||||
CellAtPos: Integer;
|
CellAtPos: Integer;
|
||||||
begin
|
begin
|
||||||
if not Active then exit;
|
if not Active then exit;
|
||||||
Pos := Point(aBytePos, aLinePos);
|
Pos := Point(aBytePos, aLinePos);
|
||||||
Pos2 := Pos;
|
Pos2 := Pos;
|
||||||
if not FEditing then
|
if not FEditing then
|
||||||
DoBeforeEdit(Pos.x, Pos.y, IsUndoing or IsRedoing);
|
DoBeforeEdit(Pos.x, Pos.y, aCount, aLineBrkCnt, IsUndoing or IsRedoing);
|
||||||
CellAtPos := Cells.IndexOf(Pos.x, Pos.y, True);
|
CellAtPos := Cells.IndexOf(Pos.x, Pos.y, True);
|
||||||
|
|
||||||
// Todo: need do add undo info (start/stop flag),
|
// Todo: need do add undo info (start/stop flag),
|
||||||
@ -846,85 +914,85 @@ begin
|
|||||||
(CompareCarets(Pos, FCells[CellAtPos].LogStart) <= 0) and
|
(CompareCarets(Pos, FCells[CellAtPos].LogStart) <= 0) and
|
||||||
(CompareCarets(Pos, FCells[CellAtPos].LogEnd) >= 0)
|
(CompareCarets(Pos, FCells[CellAtPos].LogEnd) >= 0)
|
||||||
then begin
|
then begin
|
||||||
ViewedTextBuffer.BeginUpdate;
|
CurCell := FCells[CellAtPos];
|
||||||
try
|
Pos.Y := Pos.Y - CurCell.LogStart.y;
|
||||||
FEditing := True;
|
|
||||||
CaretPos := CaretObj.LineBytePos;
|
|
||||||
CurCell := FCells[CellAtPos];
|
|
||||||
a := CurCell.Group;
|
|
||||||
Pos.Y := Pos.Y - CurCell.LogStart.y;
|
|
||||||
if Pos.y = 0
|
|
||||||
then Pos.X := Pos.X - CurCell.LogStart.x
|
|
||||||
else dec(Pos.x);
|
|
||||||
for i := 0 to FCells.Count - 1 do begin
|
|
||||||
if FCells[i].LogStart.Y = FCells[i].LogEnd.Y
|
|
||||||
then x2 := FCells[i].LogStart.X + Pos.X
|
|
||||||
else x2 := 1 + Pos.X;
|
|
||||||
if (i <> CellAtPos) and (FCells[i].Group = a) and
|
|
||||||
( (FCells[i].LogStart.Y + Pos.Y < FCells[i].LogEnd.Y) or
|
|
||||||
( (FCells[i].LogStart.Y + Pos.Y = FCells[i].LogEnd.Y) and
|
|
||||||
(x2 <= FCells[i].LogEnd.X) )
|
|
||||||
)
|
|
||||||
then begin
|
|
||||||
Y2 := FCells[i].LogStart.Y + Pos.Y;
|
|
||||||
X2 := Pos.X;
|
|
||||||
if Pos.Y = 0
|
|
||||||
then X2 := X2 + FCells[i].LogStart.X
|
|
||||||
else inc(X2);
|
|
||||||
if aLineBrkCnt = -1 then begin
|
|
||||||
ViewedTextBuffer.EditLineJoin(Y2);
|
|
||||||
if (CaretPos.y > Y2) then begin
|
|
||||||
dec(CaretPos.y);
|
|
||||||
if (CaretPos.y = Y2) then
|
|
||||||
inc(CaretPos.x, X2 - 1);
|
|
||||||
end;
|
|
||||||
end
|
|
||||||
else if aLineBrkCnt < -1 then begin
|
|
||||||
ViewedTextBuffer.EditLinesDelete(Y2, -aLineBrkCnt);
|
|
||||||
if (CaretPos.y > Y2) then
|
|
||||||
inc(CaretPos.y, aLineBrkCnt);
|
|
||||||
end
|
|
||||||
else if aLineBrkCnt = 1 then begin
|
|
||||||
ViewedTextBuffer.EditLineBreak(X2, Y2);
|
|
||||||
if (CaretPos.y > Y2) then
|
|
||||||
inc(CaretPos.y);
|
|
||||||
if (CaretPos.y = Y2) and (CaretPos.x > X2) then begin
|
|
||||||
inc(CaretPos.y);
|
|
||||||
dec(CaretPos.x, X2 - 1);
|
|
||||||
end;
|
|
||||||
end
|
|
||||||
else if aLineBrkCnt > 1 then begin
|
|
||||||
ViewedTextBuffer.EditLinesInsert(Y2, aLineBrkCnt);
|
|
||||||
if (CaretPos.y > Y2) then
|
|
||||||
inc(CaretPos.y, aLineBrkCnt);
|
|
||||||
end
|
|
||||||
else if aCount < 0 then begin
|
|
||||||
ViewedTextBuffer.EditDelete(X2, Y2, -aCount);
|
|
||||||
if (CaretPos.y = Y2) and (CaretPos.X > X2) then
|
|
||||||
inc(CaretPos.X, aCount);
|
|
||||||
end
|
|
||||||
else if aCount > 0 then begin
|
|
||||||
ViewedTextBuffer.EditInsert(X2, Y2, aText);
|
|
||||||
if (CaretPos.y = Y2) and (CaretPos.X > X2) then
|
|
||||||
inc(CaretPos.X, aCount);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end
|
|
||||||
finally
|
|
||||||
ViewedTextBuffer.EndUpdate;
|
|
||||||
end;
|
|
||||||
CaretObj.LineBytePos := CaretPos;
|
|
||||||
FEditing := False;
|
|
||||||
if Pos.y = 0 then
|
if Pos.y = 0 then
|
||||||
pos2.x := pos.x + CurCell.LogStart.x;
|
Pos.X := Pos.X - CurCell.LogStart.x
|
||||||
Pos2.y := Pos.y + CurCell.LogStart.y;
|
else
|
||||||
|
dec(Pos.x);
|
||||||
|
FChangeList.Add(CellAtPos, Pos.Y, Pos.X, aCount, aLineBrkCnt, aText);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if not FEditing then
|
if not FEditing then
|
||||||
DoAfterEdit(Pos2.x, Pos2.y, IsUndoing or IsRedoing);
|
DoAfterEdit(Pos2.x, Pos2.y, IsUndoing or IsRedoing);
|
||||||
|
if (not FEditing) and (FPaintLock = 0) then
|
||||||
|
DoPaintLockEnded;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSynPluginSyncronizedEditBase.DoBeforeEdit(aX, aY: Integer; aUndoRedo: Boolean);
|
procedure TSynPluginSyncronizedEditBase.ApplyChangeList;
|
||||||
|
var
|
||||||
|
Action: TSynPluginSyncronizedEditChangeAction;
|
||||||
|
a, i: Integer;
|
||||||
|
Group, Y2, X2: Integer;
|
||||||
|
Cell: TSynPluginSyncronizedEditCell;
|
||||||
|
begin
|
||||||
|
if FChangeList.Count = 0 then
|
||||||
|
exit;
|
||||||
|
FEditing := True;
|
||||||
|
ViewedTextBuffer.BeginUpdate;
|
||||||
|
CaretObj.IncAutoMoveOnEdit;
|
||||||
|
try
|
||||||
|
for a := 0 to FChangeList.Count - 1 do begin
|
||||||
|
Action := FChangeList[a];
|
||||||
|
Group := FCells[Action.CellIndex].Group;
|
||||||
|
for i := 0 to FCells.Count - 1 do begin
|
||||||
|
Cell := FCells[i];
|
||||||
|
if (i = Action.CellIndex) or (Cell.Group <> Group) then
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if Cell.LogStart.Y = Cell.LogEnd.Y then
|
||||||
|
X2 := Cell.LogStart.X + Action.cBytePos
|
||||||
|
else
|
||||||
|
X2 := 1 + Action.cBytePos;
|
||||||
|
if (Cell.LogStart.Y + Action.cLinePos < Cell.LogEnd.Y) or
|
||||||
|
( (Cell.LogStart.Y + Action.cLinePos = Cell.LogEnd.Y) and
|
||||||
|
(X2 <= Cell.LogEnd.X) )
|
||||||
|
then begin
|
||||||
|
Y2 := Cell.LogStart.Y + Action.cLinePos;
|
||||||
|
if Action.cLinePos = 0 then
|
||||||
|
X2 := Cell.LogStart.X + Action.cBytePos
|
||||||
|
else
|
||||||
|
X2 := 1 + Action.cBytePos;
|
||||||
|
|
||||||
|
if Action.LineBrkCount = -1 then
|
||||||
|
ViewedTextBuffer.EditLineJoin(Y2)
|
||||||
|
else
|
||||||
|
if Action.LineBrkCount < -1 then
|
||||||
|
ViewedTextBuffer.EditLinesDelete(Y2, -Action.LineBrkCount)
|
||||||
|
else
|
||||||
|
if Action.LineBrkCount = 1 then
|
||||||
|
ViewedTextBuffer.EditLineBreak(X2, Y2)
|
||||||
|
else
|
||||||
|
if Action.LineBrkCount > 1 then
|
||||||
|
ViewedTextBuffer.EditLinesInsert(Y2, Action.LineBrkCount)
|
||||||
|
else
|
||||||
|
if Action.Count < 0 then
|
||||||
|
ViewedTextBuffer.EditDelete(X2, Y2, -Action.Count)
|
||||||
|
else
|
||||||
|
if Action.Count > 0 then
|
||||||
|
ViewedTextBuffer.EditInsert(X2, Y2, Action.Text);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
FEditing := False;
|
||||||
|
CaretObj.DecAutoMoveOnEdit;
|
||||||
|
ViewedTextBuffer.EndUpdate;
|
||||||
|
end;
|
||||||
|
FChangeList.Clear;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSynPluginSyncronizedEditBase.DoBeforeEdit(aX, aY, aCount, aLineBrkCnt: Integer; aUndoRedo: Boolean);
|
||||||
begin
|
begin
|
||||||
(* Do Nothing *);
|
(* Do Nothing *);
|
||||||
end;
|
end;
|
||||||
@ -934,6 +1002,16 @@ begin
|
|||||||
(* Do Nothing *);
|
(* Do Nothing *);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TSynPluginSyncronizedEditBase.DoPaintLockStarted;
|
||||||
|
begin
|
||||||
|
(* Do Nothing *);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSynPluginSyncronizedEditBase.DoPaintLockEnded;
|
||||||
|
begin
|
||||||
|
(* Do Nothing *);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TSynPluginSyncronizedEditBase.DoClear;
|
procedure TSynPluginSyncronizedEditBase.DoClear;
|
||||||
begin
|
begin
|
||||||
(* Do Nothing *);
|
(* Do Nothing *);
|
||||||
@ -951,6 +1029,24 @@ begin
|
|||||||
FOnDeactivate(self);
|
FOnDeactivate(self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TSynPluginSyncronizedEditBase.DoIncPaintLock(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if FPaintLock = 0 then
|
||||||
|
DoPaintLockStarted;
|
||||||
|
inc(FPaintLock);
|
||||||
|
if Sender = Editor then
|
||||||
|
inc(FOwnPaintLock);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSynPluginSyncronizedEditBase.DoDecPaintLock(Sender: TObject);
|
||||||
|
begin
|
||||||
|
dec(FPaintLock);
|
||||||
|
if Sender = Editor then
|
||||||
|
dec(FOwnPaintLock);
|
||||||
|
if FPaintLock = 0 then
|
||||||
|
DoPaintLockEnded;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TSynPluginSyncronizedEditCell }
|
{ TSynPluginSyncronizedEditCell }
|
||||||
|
|
||||||
procedure TSynPluginSyncronizedEditCell.Assign(Src: TSynPluginSyncronizedEditCell);
|
procedure TSynPluginSyncronizedEditCell.Assign(Src: TSynPluginSyncronizedEditCell);
|
||||||
@ -1018,7 +1114,10 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSynPluginCustomSyncroEdit.DoBeforeEdit(aX, aY: Integer; aUndoRedo: Boolean);
|
procedure TSynPluginCustomSyncroEdit.DoBeforeEdit(aX, aY, aCount, aLineBrkCnt: Integer;
|
||||||
|
aUndoRedo: Boolean);
|
||||||
|
var
|
||||||
|
c1, c2: Integer;
|
||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
if IsUndoing and (FUndoRealCount >= 0) and (FUndoList.RealCount < FUndoRealCount)
|
if IsUndoing and (FUndoRealCount >= 0) and (FUndoList.RealCount < FUndoRealCount)
|
||||||
@ -1036,10 +1135,30 @@ begin
|
|||||||
- User edit outside a cell (both locations will be outside the cell => deactivate
|
- User edit outside a cell (both locations will be outside the cell => deactivate
|
||||||
TODO: Hook SynEdits Lock, and check Caret before locking only
|
TODO: Hook SynEdits Lock, and check Caret before locking only
|
||||||
*)
|
*)
|
||||||
UpdateCurrentCell(aX, aY);
|
c1 := Cells.IndexOf(aX, aY, True);
|
||||||
if CurrentCell < 0 then
|
if aLineBrkCnt < 0 then
|
||||||
UpdateCurrentCell;
|
c2 := Cells.IndexOf(1, aY-aLineBrkCnt, True)
|
||||||
if CurrentCell < 0 then begin
|
else if aCount < 0 then
|
||||||
|
c2 := Cells.IndexOf(aX - aCount, aY, True)
|
||||||
|
else
|
||||||
|
c2 := c1;
|
||||||
|
debugln(['----- c1=',c1,' c2=',c2,' ay=',ay,' ax=',ax,' aLineBrkCnt=',aLineBrkCnt,' aCount=',aCount,' FExternalEditLock=',FExternalEditLock,' FPaintLock=', FPaintLock,' FOwnPaintLock=',FOwnPaintLock]);
|
||||||
|
// allow edit outside cell? (only if not partly cell / part cell updates are not allowed at all)
|
||||||
|
// Todo, could be just on the edge of a cell !
|
||||||
|
if (c1 = c2) and (FExternalEditLock > 0) then begin
|
||||||
|
debugln(['exit for external']);
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
// shared editor, outside cells
|
||||||
|
if (FPaintLock > 0) and (FOwnPaintLock = 0) then begin
|
||||||
|
if (c1 < 0) and (c2 < 0) then
|
||||||
|
exit;
|
||||||
|
c1 := -1; // shared Eitor in cell => deactivate
|
||||||
|
debugln(['deactivate for shared']);
|
||||||
|
end;
|
||||||
|
|
||||||
|
if (CurrentCell < 0) or (c1 < 0) or (c2 <> c1) then begin
|
||||||
|
debugln(['deactivate']);
|
||||||
Clear;
|
Clear;
|
||||||
Active := False;
|
Active := False;
|
||||||
end;
|
end;
|
||||||
@ -1048,19 +1167,28 @@ end;
|
|||||||
procedure TSynPluginCustomSyncroEdit.DoAfterEdit(aX, aY: Integer; aUndoRedo: Boolean);
|
procedure TSynPluginCustomSyncroEdit.DoAfterEdit(aX, aY: Integer; aUndoRedo: Boolean);
|
||||||
begin
|
begin
|
||||||
inherited DoAfterEdit(aX, aY, aUndoRedo);
|
inherited DoAfterEdit(aX, aY, aUndoRedo);
|
||||||
|
if FPaintLock = 0 then
|
||||||
|
UpdateCurrentCell;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSynPluginCustomSyncroEdit.DoPaintLockStarted;
|
||||||
|
begin
|
||||||
|
inherited DoPaintLockStarted;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSynPluginCustomSyncroEdit.DoPaintLockEnded;
|
||||||
|
begin
|
||||||
|
inherited DoPaintLockEnded;
|
||||||
|
ApplyChangeList;
|
||||||
UpdateCurrentCell;
|
UpdateCurrentCell;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSynPluginCustomSyncroEdit.UpdateCurrentCell;
|
procedure TSynPluginCustomSyncroEdit.UpdateCurrentCell;
|
||||||
begin
|
|
||||||
UpdateCurrentCell(CaretObj.BytePos, CaretObj.LinePos);
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TSynPluginCustomSyncroEdit.UpdateCurrentCell(aLogX, aLogY: Integer);
|
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
i := Cells.IndexOf(aLogX, aLogY, True);
|
debugln(['update current cell pl=',FPaintLock]);
|
||||||
|
i := Cells.IndexOf(CaretObj.BytePos, CaretObj.LinePos, True);
|
||||||
if (i <> CurrentCell) and (CurrentCell >= 0) then
|
if (i <> CurrentCell) and (CurrentCell >= 0) then
|
||||||
FLastCell := CurrentCell;
|
FLastCell := CurrentCell;
|
||||||
CurrentCell := i;
|
CurrentCell := i;
|
||||||
@ -1185,5 +1313,22 @@ begin
|
|||||||
Editor.BlockBegin := Cells[CurrentCell].LogEnd;
|
Editor.BlockBegin := Cells[CurrentCell].LogEnd;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
constructor TSynPluginCustomSyncroEdit.Create(AOwner: TComponent);
|
||||||
|
begin
|
||||||
|
FPaintLock := 0;
|
||||||
|
FExternalEditLock := 0;
|
||||||
|
inherited Create(AOwner);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSynPluginCustomSyncroEdit.IncExternalEditLock;
|
||||||
|
begin
|
||||||
|
inc(FExternalEditLock);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSynPluginCustomSyncroEdit.DecExternalEditLock;
|
||||||
|
begin
|
||||||
|
dec(FExternalEditLock);
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -2093,34 +2093,41 @@ begin
|
|||||||
if SrcLogEntry<>nil then begin
|
if SrcLogEntry<>nil then begin
|
||||||
SynEditor.BeginUpdate;
|
SynEditor.BeginUpdate;
|
||||||
SynEditor.BeginUndoBlock;
|
SynEditor.BeginUndoBlock;
|
||||||
case SrcLogEntry.Operation of
|
SynEditor.TemplateEdit.IncExternalEditLock;
|
||||||
sleoInsert:
|
SynEditor.SyncroEdit.IncExternalEditLock;
|
||||||
begin
|
try
|
||||||
Sender.AbsoluteToLineCol(SrcLogEntry.Position,StartPos.Y,StartPos.X);
|
case SrcLogEntry.Operation of
|
||||||
if StartPos.Y>=1 then
|
sleoInsert:
|
||||||
SynEditor.TextBetweenPointsEx[StartPos, StartPos, scamAdjust] := SrcLogEntry.Txt;
|
begin
|
||||||
end;
|
Sender.AbsoluteToLineCol(SrcLogEntry.Position,StartPos.Y,StartPos.X);
|
||||||
sleoDelete:
|
if StartPos.Y>=1 then
|
||||||
begin
|
SynEditor.TextBetweenPointsEx[StartPos, StartPos, scamAdjust] := SrcLogEntry.Txt;
|
||||||
Sender.AbsoluteToLineCol(SrcLogEntry.Position,StartPos.Y,StartPos.X);
|
end;
|
||||||
Sender.AbsoluteToLineCol(SrcLogEntry.Position+SrcLogEntry.Len,
|
sleoDelete:
|
||||||
EndPos.Y,EndPos.X);
|
begin
|
||||||
if (StartPos.Y>=1) and (EndPos.Y>=1) then
|
Sender.AbsoluteToLineCol(SrcLogEntry.Position,StartPos.Y,StartPos.X);
|
||||||
SynEditor.TextBetweenPointsEx[StartPos, EndPos, scamAdjust] := '';
|
Sender.AbsoluteToLineCol(SrcLogEntry.Position+SrcLogEntry.Len,
|
||||||
end;
|
EndPos.Y,EndPos.X);
|
||||||
sleoMove:
|
if (StartPos.Y>=1) and (EndPos.Y>=1) then
|
||||||
begin
|
SynEditor.TextBetweenPointsEx[StartPos, EndPos, scamAdjust] := '';
|
||||||
Sender.AbsoluteToLineCol(SrcLogEntry.Position,StartPos.Y,StartPos.X);
|
end;
|
||||||
Sender.AbsoluteToLineCol(SrcLogEntry.Position+SrcLogEntry.Len,
|
sleoMove:
|
||||||
EndPos.Y,EndPos.X);
|
begin
|
||||||
Sender.AbsoluteToLineCol(SrcLogEntry.MoveTo,MoveToPos.Y,MoveToPos.X);
|
Sender.AbsoluteToLineCol(SrcLogEntry.Position,StartPos.Y,StartPos.X);
|
||||||
if (StartPos.Y>=1) and (EndPos.Y>=1) and (MoveToPos.Y>=1) then
|
Sender.AbsoluteToLineCol(SrcLogEntry.Position+SrcLogEntry.Len,
|
||||||
MoveTxt(StartPos, EndPos, MoveToPos,
|
EndPos.Y,EndPos.X);
|
||||||
SrcLogEntry.Position<SrcLogEntry.MoveTo);
|
Sender.AbsoluteToLineCol(SrcLogEntry.MoveTo,MoveToPos.Y,MoveToPos.X);
|
||||||
end;
|
if (StartPos.Y>=1) and (EndPos.Y>=1) and (MoveToPos.Y>=1) then
|
||||||
|
MoveTxt(StartPos, EndPos, MoveToPos,
|
||||||
|
SrcLogEntry.Position<SrcLogEntry.MoveTo);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
SynEditor.SyncroEdit.DecExternalEditLock;
|
||||||
|
SynEditor.TemplateEdit.DecExternalEditLock;
|
||||||
|
SynEditor.EndUndoBlock;
|
||||||
|
SynEditor.EndUpdate;
|
||||||
end;
|
end;
|
||||||
SynEditor.EndUndoBlock;
|
|
||||||
SynEditor.EndUpdate;
|
|
||||||
end else begin
|
end else begin
|
||||||
{$IFDEF VerboseSrcEditBufClean}
|
{$IFDEF VerboseSrcEditBufClean}
|
||||||
debugln(['TSourceEditor.OnCodeBufferChanged clean up ',TCodeBuffer(Sender).FileName,' ',Sender=CodeBuffer,' ',Filename]);
|
debugln(['TSourceEditor.OnCodeBufferChanged clean up ',TCodeBuffer(Sender).FileName,' ',Sender=CodeBuffer,' ',Filename]);
|
||||||
@ -2219,10 +2226,13 @@ begin
|
|||||||
//DebugLn(['TSourceEditor.UpdateCodeBuffer ',FCodeBuffer.FileName]);
|
//DebugLn(['TSourceEditor.UpdateCodeBuffer ',FCodeBuffer.FileName]);
|
||||||
IncreaseIgnoreCodeBufferLock;
|
IncreaseIgnoreCodeBufferLock;
|
||||||
SynEditor.BeginUpdate;
|
SynEditor.BeginUpdate;
|
||||||
FCodeBuffer.Assign(SynEditor.Lines);
|
try
|
||||||
FEditorStampCommitedToCodetools:=(SynEditor.Lines as TSynEditLines).TextChangeStamp;
|
FCodeBuffer.Assign(SynEditor.Lines);
|
||||||
SynEditor.EndUpdate;
|
FEditorStampCommitedToCodetools:=(SynEditor.Lines as TSynEditLines).TextChangeStamp;
|
||||||
DecreaseIgnoreCodeBufferLock;
|
finally
|
||||||
|
SynEditor.EndUpdate;
|
||||||
|
DecreaseIgnoreCodeBufferLock;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
constructor TSourceEditorSharedValues.Create;
|
constructor TSourceEditorSharedValues.Create;
|
||||||
@ -3738,8 +3748,6 @@ var
|
|||||||
NewName: string;
|
NewName: string;
|
||||||
i: integer;
|
i: integer;
|
||||||
bmp: TCustomBitmap;
|
bmp: TCustomBitmap;
|
||||||
TemplateEdit: TSynPluginTemplateEdit;
|
|
||||||
SyncroEdit: TSynPluginSyncroEdit;
|
|
||||||
Begin
|
Begin
|
||||||
{$IFDEF IDE_DEBUG}
|
{$IFDEF IDE_DEBUG}
|
||||||
writeln('TSourceEditor.CreateEditor A ');
|
writeln('TSourceEditor.CreateEditor A ');
|
||||||
@ -3786,15 +3794,14 @@ Begin
|
|||||||
end;
|
end;
|
||||||
Manager.CodeTemplateModul.AddEditor(FEditor);
|
Manager.CodeTemplateModul.AddEditor(FEditor);
|
||||||
Manager.NewEditorCreated(self);
|
Manager.NewEditorCreated(self);
|
||||||
TemplateEdit:=TSynPluginTemplateEdit.Create(FEditor);
|
FEditor.TemplateEdit.OnActivate := @EditorActivateSyncro;
|
||||||
TemplateEdit.OnActivate := @EditorActivateSyncro;
|
FEditor.TemplateEdit.OnDeactivate := @EditorDeactivateSyncro;
|
||||||
TemplateEdit.OnDeactivate := @EditorDeactivateSyncro;
|
|
||||||
SyncroEdit := TSynPluginSyncroEdit.Create(FEditor);
|
|
||||||
bmp := CreateBitmapFromLazarusResource('tsynsyncroedit');
|
bmp := CreateBitmapFromLazarusResource('tsynsyncroedit');
|
||||||
SyncroEdit.GutterGlyph.Assign(bmp);
|
FEditor.SyncroEdit.GutterGlyph.Assign(bmp);
|
||||||
bmp.Free;
|
bmp.Free;
|
||||||
SyncroEdit.OnActivate := @EditorActivateSyncro;
|
FEditor.SyncroEdit.OnActivate := @EditorActivateSyncro;
|
||||||
SyncroEdit.OnDeactivate := @EditorDeactivateSyncro;
|
FEditor.SyncroEdit.OnDeactivate := @EditorDeactivateSyncro;
|
||||||
|
|
||||||
RefreshEditorSettings;
|
RefreshEditorSettings;
|
||||||
FEditor.EndUpdate;
|
FEditor.EndUpdate;
|
||||||
end else begin
|
end else begin
|
||||||
|
@ -39,7 +39,8 @@ interface
|
|||||||
uses
|
uses
|
||||||
Classes, SysUtils, LCLProc, Graphics, SynEdit, SynEditMiscClasses, SynGutter,
|
Classes, SysUtils, LCLProc, Graphics, SynEdit, SynEditMiscClasses, SynGutter,
|
||||||
SynGutterLineNumber, SynGutterCodeFolding, SynGutterMarks, SynGutterChanges,
|
SynGutterLineNumber, SynGutterCodeFolding, SynGutterMarks, SynGutterChanges,
|
||||||
SynEditTextBuffer, SynEditFoldedView, SynTextDrawer, SynEditTextBase;
|
SynEditTextBuffer, SynEditFoldedView, SynTextDrawer, SynEditTextBase,
|
||||||
|
SynPluginTemplateEdit, SynPluginSyncroEdit;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
@ -49,15 +50,20 @@ type
|
|||||||
|
|
||||||
TIDESynEditor = class(TSynEdit)
|
TIDESynEditor = class(TSynEdit)
|
||||||
private
|
private
|
||||||
|
FSyncroEdit: TSynPluginSyncroEdit;
|
||||||
|
FTemplateEdit: TSynPluginTemplateEdit;
|
||||||
function GetIDEGutterMarks: TIDESynGutterMarks;
|
function GetIDEGutterMarks: TIDESynGutterMarks;
|
||||||
protected
|
protected
|
||||||
function CreateGutter(AOwner : TSynEditBase; AFoldedLinesView: TSynEditFoldedView;
|
function CreateGutter(AOwner : TSynEditBase; AFoldedLinesView: TSynEditFoldedView;
|
||||||
ATextDrawer: TheTextDrawer): TSynGutter; override;
|
ATextDrawer: TheTextDrawer): TSynGutter; override;
|
||||||
public
|
public
|
||||||
|
constructor Create(AOwner: TComponent); override;
|
||||||
function TextIndexToViewPos(aTextIndex : Integer) : Integer;
|
function TextIndexToViewPos(aTextIndex : Integer) : Integer;
|
||||||
property IDEGutterMarks: TIDESynGutterMarks read GetIDEGutterMarks;
|
property IDEGutterMarks: TIDESynGutterMarks read GetIDEGutterMarks;
|
||||||
property TopView;
|
property TopView;
|
||||||
property TextBuffer;
|
property TextBuffer;
|
||||||
|
property TemplateEdit: TSynPluginTemplateEdit read FTemplateEdit;
|
||||||
|
property SyncroEdit: TSynPluginSyncroEdit read FSyncroEdit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TIDESynGutter }
|
{ TIDESynGutter }
|
||||||
@ -120,6 +126,13 @@ begin
|
|||||||
Result := TIDESynGutter.Create(AOwner, AFoldedLinesView, ATextDrawer);
|
Result := TIDESynGutter.Create(AOwner, AFoldedLinesView, ATextDrawer);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
constructor TIDESynEditor.Create(AOwner: TComponent);
|
||||||
|
begin
|
||||||
|
inherited Create(AOwner);
|
||||||
|
FTemplateEdit:=TSynPluginTemplateEdit.Create(Self);
|
||||||
|
FSyncroEdit := TSynPluginSyncroEdit.Create(Self);
|
||||||
|
end;
|
||||||
|
|
||||||
function TIDESynEditor.TextIndexToViewPos(aTextIndex: Integer): Integer;
|
function TIDESynEditor.TextIndexToViewPos(aTextIndex: Integer): Integer;
|
||||||
begin
|
begin
|
||||||
Result := TextView.TextIndexToViewPos(aTextIndex - 1);
|
Result := TextView.TextIndexToViewPos(aTextIndex - 1);
|
||||||
|
Loading…
Reference in New Issue
Block a user