mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-19 04:09:30 +02:00
SynEdit: Starting Multi-View SynEdit
git-svn-id: trunk@22679 -
This commit is contained in:
parent
ce4c2a4762
commit
69f53e8c35
@ -374,6 +374,11 @@ type
|
||||
FTheLinesView: TSynEditStrings;
|
||||
FLines: TSynEditStrings; // The real (un-mapped) line-buffer
|
||||
FStrings: TStrings; // External TStrings based interface to the Textbuffer
|
||||
{$IFDEF SynDualView}
|
||||
FTopLinesView: TSynEditStrings; // The linesview that holds the real line-buffer/FLines
|
||||
|
||||
FSharedViewSynEdit: TCustomSynEdit;
|
||||
{$ENDIF}
|
||||
|
||||
fExtraCharSpacing: integer;
|
||||
fLinesInWindow: Integer;// MG: fully visible lines in window
|
||||
@ -424,7 +429,7 @@ type
|
||||
fTSearch: TSynEditSearch;
|
||||
fHookedCommandHandlers: TList;
|
||||
FHookedKeyTranslationList: TSynHookedKeyTranslationList;
|
||||
fPlugins: TList;
|
||||
FPlugins: TList;
|
||||
fScrollTimer: TTimer;
|
||||
fScrollDeltaX, fScrollDeltaY: Integer;
|
||||
FInMouseClickEvent: Boolean;
|
||||
@ -517,7 +522,7 @@ type
|
||||
procedure MoveCaretVert(DY: integer);
|
||||
procedure PrimarySelectionRequest(const RequestedFormatID: TClipboardFormat;
|
||||
Data: TStream);
|
||||
function ScanFrom(var Index: integer; AtLeastTilIndex: integer = -1): integer;
|
||||
function ScanFrom(var Index: integer; AtLeastTilIndex: integer = -1): integer; // Todo: move to line, currently scans twice or more, if SharedView is active
|
||||
procedure DoBlockSelectionChanged(Sender: TObject);
|
||||
procedure SetBlockBegin(Value: TPoint);
|
||||
procedure SetBlockEnd(Value: TPoint);
|
||||
@ -567,6 +572,11 @@ type
|
||||
procedure UnlockUndo;
|
||||
procedure UpdateCaret;
|
||||
procedure UpdateScrollBars;
|
||||
{$IFDEF SynDualView}
|
||||
function GetSharedViewEdit: TCustomSynEdit;
|
||||
procedure SetSharedViewEdit(const AValue: TCustomSynEdit);
|
||||
procedure RemoveHandlers(ALines: TSynEditStrings = nil);
|
||||
{$ENDIF}
|
||||
protected
|
||||
procedure CreateHandle; override;
|
||||
procedure CreateParams(var Params: TCreateParams); override;
|
||||
@ -871,6 +881,9 @@ type
|
||||
procedure Invalidate; override;
|
||||
property ChangeStamp: int64 read fChangeStamp;
|
||||
{$ENDIF}
|
||||
{$IFDEF SynDualView}
|
||||
property SharedViewEdit: TCustomSynEdit read GetSharedViewEdit write SetSharedViewEdit;
|
||||
{$ENDIF}
|
||||
public
|
||||
property OnKeyDown;
|
||||
property OnKeyPress;
|
||||
@ -1486,9 +1499,10 @@ begin
|
||||
SetAncestor(True); // temp until tframe does this
|
||||
SetInline(True);
|
||||
|
||||
fBeautifier := SynDefaultBeautifier;
|
||||
FBeautifier := SynDefaultBeautifier;
|
||||
|
||||
FLines := TSynEditStringList.Create;
|
||||
|
||||
fLines := TSynEditStringList.Create;
|
||||
FCaret := TSynEditCaret.Create;
|
||||
FCaret.MaxLeftChar := @FMaxLeftChar;
|
||||
FCaret.AddChangeHandler({$IFDEF FPC}@{$ENDIF}CaretChanged);
|
||||
@ -1509,6 +1523,9 @@ begin
|
||||
// Pointer to the First/Lowest View
|
||||
// TODO: this should be Folded...
|
||||
FTheLinesView := FTabbedLinesView;
|
||||
{$IFDEF SynDualView}
|
||||
FTopLinesView := FTrimmedLinesView;
|
||||
{$ENDIF}
|
||||
// External Accessor
|
||||
FStrings := TSynEditLines.Create(FLines, {$IFDEF FPC}@{$ENDIF}MarkTextAsSaved);
|
||||
|
||||
@ -1770,6 +1787,10 @@ begin
|
||||
TSynEditPlugin(fPlugins[i]).Editor := nil;
|
||||
FreeAndNil(fPlugins);
|
||||
end;
|
||||
{$IFDEF SynDualView}
|
||||
RemoveHandlers;
|
||||
{$ENDIF}
|
||||
|
||||
FreeAndNil(FHookedKeyTranslationList);
|
||||
fHookedCommandHandlers:=nil;
|
||||
fPlugins:=nil;
|
||||
@ -1795,7 +1816,9 @@ begin
|
||||
FreeAndNil(FTabbedLinesView);
|
||||
FreeAndNil(FTrimmedLinesView); // has reference to caret
|
||||
FreeAndNil(FDoubleWidthChrLinesView);
|
||||
FreeAndNil(fLines);
|
||||
TSynEditStringList(FLines).DecRefCount;
|
||||
if TSynEditStringList(FLines).RefCount = 0 then
|
||||
FreeAndNil(fLines);
|
||||
FreeAndNil(fCaret);
|
||||
FreeAndNil(fInternalCaret);
|
||||
inherited Destroy;
|
||||
@ -4940,6 +4963,104 @@ begin
|
||||
FMouseSelActions.Assign(AValue);
|
||||
end;
|
||||
|
||||
{$IFDEF SynDualView}
|
||||
function TCustomSynEdit.GetSharedViewEdit: TCustomSynEdit;
|
||||
begin
|
||||
Result := FSharedViewSynEdit;
|
||||
end;
|
||||
|
||||
procedure TCustomSynEdit.SetSharedViewEdit(const AValue: TCustomSynEdit);
|
||||
var
|
||||
OldLines: TSynEditStringList;
|
||||
LView: TSynEditStrings;
|
||||
i: Integer;
|
||||
Plugins: TList;
|
||||
begin
|
||||
if AValue = FSharedViewSynEdit then exit;
|
||||
FSharedViewSynEdit := AValue;
|
||||
|
||||
// TODO: all plugins SetEditor = nil => release all flines
|
||||
Plugins := TList.Create; // remmeber them
|
||||
for i := 0 to FPlugins.Count - 1 do begin
|
||||
Plugins.Add(FPlugins[i]);
|
||||
TSynEditPlugin(FPlugins[i]).Editor := nil;
|
||||
end;
|
||||
|
||||
OldLines := TSynEditStringList(FLines);
|
||||
if AValue = nil then begin
|
||||
FLines := TSynEditStringList.Create;
|
||||
end else begin
|
||||
FLines := AValue.FLines;
|
||||
TSynEditStringList(FLines).IncRefCount;
|
||||
end;
|
||||
TSynEditStringsLinked(FTopLinesView).NextLines := FLines;
|
||||
|
||||
// Todo: copy events (have a list of all event owners)
|
||||
TSynEditStringList(FLines).CopyHanlders(OldLines, self);
|
||||
LView := FTheLinesView;
|
||||
while (LView is TSynEditStringsLinked) and (LView <> FLines) do begin
|
||||
TSynEditStringList(FLines).CopyHanlders(OldLines, LView);
|
||||
LView := TSynEditStringsLinked(LView).NextLines;
|
||||
end;
|
||||
TSynEditStringList(FLines).CopyHanlders(OldLines, FFoldedLinesView);
|
||||
TSynEditStringList(FLines).CopyHanlders(OldLines, FMarkList);
|
||||
TSynEditStringList(FLines).CopyHanlders(OldLines, FCaret);
|
||||
TSynEditStringList(FLines).CopyHanlders(OldLines, FInternalCaret);
|
||||
TSynEditStringList(FLines).CopyHanlders(OldLines, FBlockSelection);
|
||||
TSynEditStringList(FLines).CopyHanlders(OldLines, FInternalBlockSelection);
|
||||
TSynEditStringList(FLines).CopyHanlders(OldLines, fMarkupManager);
|
||||
for i := 0 to fMarkupManager.Count - 1 do
|
||||
TSynEditStringList(FLines).CopyHanlders(OldLines, fMarkupManager.Markup[i]);
|
||||
|
||||
FUndoList := TSynEditStringList(fLines).UndoList;
|
||||
FRedoList := TSynEditStringList(fLines).RedoList;
|
||||
|
||||
FreeAndNil(FStrings);
|
||||
FStrings := TSynEditLines.Create(FLines, {$IFDEF FPC}@{$ENDIF}MarkTextAsSaved);
|
||||
|
||||
// TOdo: highlighter
|
||||
|
||||
for i := 0 to Plugins.Count - 1 do begin
|
||||
FPlugins.Add(FPlugins[i]);
|
||||
end;
|
||||
Plugins.Free;
|
||||
|
||||
// Todo: rescan / redraw /re....
|
||||
|
||||
OldLines.DecRefCount;
|
||||
if OldLines.RefCount = 0 then
|
||||
OldLines.Free
|
||||
else
|
||||
RemoveHandlers(OldLines);
|
||||
end;
|
||||
|
||||
procedure TCustomSynEdit.RemoveHandlers(ALines: TSynEditStrings = nil);
|
||||
var
|
||||
LView: TSynEditStrings;
|
||||
i: Integer;
|
||||
begin
|
||||
if not assigned(ALines) then
|
||||
ALines := FLines;
|
||||
|
||||
// Todo: aggregated objects, should be responsible themself
|
||||
TSynEditStringList(ALines).RemoveHanlders(self);
|
||||
LView := FTheLinesView;
|
||||
while (LView is TSynEditStringsLinked) and (LView <> ALines) do begin
|
||||
TSynEditStringList(ALines).RemoveHanlders(LView);
|
||||
LView := TSynEditStringsLinked(LView).NextLines;
|
||||
end;
|
||||
TSynEditStringList(ALines).RemoveHanlders(FFoldedLinesView);
|
||||
TSynEditStringList(ALines).RemoveHanlders(FMarkList);
|
||||
TSynEditStringList(ALines).RemoveHanlders(FCaret);
|
||||
TSynEditStringList(ALines).RemoveHanlders(FInternalCaret);
|
||||
TSynEditStringList(ALines).RemoveHanlders(FBlockSelection);
|
||||
TSynEditStringList(ALines).RemoveHanlders(FInternalBlockSelection);
|
||||
TSynEditStringList(ALines).RemoveHanlders(fMarkupManager);
|
||||
for i := 0 to fMarkupManager.Count - 1 do
|
||||
TSynEditStringList(ALines).RemoveHanlders(fMarkupManager.Markup[i]);
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
procedure TCustomSynEdit.SetTextBetweenPoints(aStartPoint, aEndPoint: TPoint;
|
||||
const AValue: String);
|
||||
begin
|
||||
@ -5249,10 +5370,8 @@ begin
|
||||
inherited Notification(AComponent, Operation);
|
||||
if Operation = opRemove then begin
|
||||
if AComponent = fHighlighter then begin
|
||||
fHighlighter.DetachFromLines(FLines);
|
||||
fHighlighter := nil;
|
||||
if assigned(FLines.Ranges) then
|
||||
FLines.Ranges.Free;
|
||||
FLines.Ranges := nil;
|
||||
fMarkupHighCaret.Highlighter := nil;
|
||||
fMarkupWordGroup.Highlighter := nil;
|
||||
FFoldedLinesView.Highlighter := nil;
|
||||
|
@ -61,12 +61,17 @@ type
|
||||
|
||||
TSynHighlighterRangeList = class(TSynEditStorageMem)
|
||||
private
|
||||
FRefCount: Integer;
|
||||
function GetRange(Index: Integer): Pointer;
|
||||
procedure SetRange(Index: Integer; const AValue: Pointer);
|
||||
protected
|
||||
function ItemSize: Integer; override;
|
||||
public
|
||||
constructor Create;
|
||||
procedure IncRefCount;
|
||||
procedure DecRefCount;
|
||||
property Range[Index: Integer]: Pointer read GetRange write SetRange; default;
|
||||
property RefCount: Integer read FRefCount;
|
||||
end;
|
||||
|
||||
{ TSynHighlighterAttributes }
|
||||
@ -1260,20 +1265,32 @@ begin
|
||||
if AValue = FCurrentLines then
|
||||
exit;
|
||||
FCurrentLines := AValue;
|
||||
FCurrentRanges := TSynHighlighterRangeList(AValue.Ranges);
|
||||
FCurrentRanges := TSynHighlighterRangeList(AValue.Ranges[ClassType]);
|
||||
end;
|
||||
|
||||
procedure TSynCustomHighlighter.AttachToLines(Lines: TSynEditStrings);
|
||||
var
|
||||
r: TSynHighlighterRangeList;
|
||||
begin
|
||||
Lines.Ranges := CreateRangeList;
|
||||
r := TSynHighlighterRangeList(Lines.Ranges[ClassType]);
|
||||
if assigned(r) then
|
||||
r.IncRefCount
|
||||
else
|
||||
Lines.Ranges[ClassType] := CreateRangeList;
|
||||
FCurrentLines := nil;
|
||||
end;
|
||||
|
||||
procedure TSynCustomHighlighter.DetachFromLines(Lines: TSynEditStrings);
|
||||
var
|
||||
r: TSynHighlighterRangeList;
|
||||
begin
|
||||
if assigned(Lines.Ranges) then
|
||||
Lines.Ranges.Free;
|
||||
Lines.Ranges := nil;
|
||||
r := TSynHighlighterRangeList(Lines.Ranges[ClassType]);
|
||||
if not assigned(r) then exit;
|
||||
r.DecRefCount;
|
||||
if r.RefCount = 0 then begin
|
||||
r.Free;
|
||||
Lines.Ranges[ClassType] := nil;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSynCustomHighlighter.SetDrawDividerLevel(const AValue: Integer);
|
||||
@ -1315,6 +1332,22 @@ begin
|
||||
Result := SizeOf(Pointer);
|
||||
end;
|
||||
|
||||
constructor TSynHighlighterRangeList.Create;
|
||||
begin
|
||||
Inherited;
|
||||
FRefCount := 1;
|
||||
end;
|
||||
|
||||
procedure TSynHighlighterRangeList.IncRefCount;
|
||||
begin
|
||||
inc(FRefCount);
|
||||
end;
|
||||
|
||||
procedure TSynHighlighterRangeList.DecRefCount;
|
||||
begin
|
||||
dec(FRefCount);
|
||||
end;
|
||||
|
||||
{ TSynDividerDrawConfig }
|
||||
|
||||
function TSynDividerDrawConfig.GetNestColor: TColor;
|
||||
|
@ -348,6 +348,7 @@ type
|
||||
public
|
||||
function CountByObject(const AnObject: TObject): integer;
|
||||
procedure DeleteByObject(const AnObject: TObject; Index: integer);
|
||||
procedure AddCopyFrom(AList: TSynMethodList; AOwner: TObject = nil);
|
||||
public
|
||||
property ItemsByObject[AnObject: TObject; Index: integer]: TMethod
|
||||
read GetObjectItems write SetObjectItems; default;
|
||||
@ -1111,7 +1112,7 @@ begin
|
||||
i := 0;
|
||||
c := Count;
|
||||
while i < c do begin
|
||||
if TObject(Items[AnIndex].Data)=AnObject then begin
|
||||
if TObject(Items[i].Data)=AnObject then begin
|
||||
if AnIndex = 0 then exit(i);
|
||||
dec(AnIndex);
|
||||
end;
|
||||
@ -1148,5 +1149,18 @@ begin
|
||||
Delete(IndexToObjectIndex(AnObject, Index));
|
||||
end;
|
||||
|
||||
procedure TSynMethodList.AddCopyFrom(AList: TSynMethodList; AOwner: TObject = nil);
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
if AOwner = nil then begin
|
||||
for i := 0 to AList.Count - 1 do
|
||||
Add(AList.Items[i], True);
|
||||
end else begin
|
||||
for i := 0 to AList.CountByObject(AOwner) - 1 do
|
||||
Add(AList.ItemsByObject[AOwner, i], True);
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
@ -919,14 +919,17 @@ procedure TSynEditSelection.DoLinesEdited(Sender: TSynEditStrings; aLinePos, aBy
|
||||
|
||||
begin
|
||||
if FIsSettingText then exit;
|
||||
if FPersistent or (FPersistentLock > 0) then begin
|
||||
if FActiveSelectionMode <> smColumn then begin
|
||||
if FPersistent or (FPersistentLock > 0) or
|
||||
((FCaret <> nil) and (not FCaret.Locked))
|
||||
then begin
|
||||
if FActiveSelectionMode <> smColumn then begin // TODO: adjust ypos, height in smColumn mode
|
||||
AdjustStartLineBytePos(AdjustPoint(StartLineBytePos));
|
||||
EndLineBytePos := AdjustPoint(EndLineBytePos);
|
||||
end;
|
||||
end
|
||||
else
|
||||
if (FCaret <> nil) then
|
||||
else // Change the Selection, if change was made by owning SynEdit (Caret.Locked)
|
||||
// (InternalSelection has no Caret)
|
||||
if (FCaret <> nil) and (FCaret.Locked) then
|
||||
StartLineBytePos := FCaret.LineBytePos;
|
||||
end;
|
||||
|
||||
|
@ -85,8 +85,8 @@ type
|
||||
FIsUtf8: Boolean;
|
||||
function GetIsUtf8 : Boolean; virtual;
|
||||
procedure SetIsUtf8(const AValue : Boolean); virtual;
|
||||
function GetRange: TSynEditStorageMem; virtual; abstract;
|
||||
procedure PutRange(ARange: TSynEditStorageMem); virtual; abstract;
|
||||
function GetRange(Index: TClass): TSynEditStorageMem; virtual; abstract;
|
||||
procedure PutRange(Index: TClass; const ARange: TSynEditStorageMem); virtual; abstract;
|
||||
function GetAttribute(const Owner: TClass; const Index: Integer): Pointer; virtual; abstract;
|
||||
procedure SetAttribute(const Owner: TClass; const Index: Integer; const AValue: Pointer); virtual; abstract;
|
||||
|
||||
@ -163,7 +163,7 @@ type
|
||||
property ExpandedStrings[Index: integer]: string read GetExpandedString;
|
||||
property LengthOfLongestLine: integer read GetLengthOfLongestLine;
|
||||
property IsUtf8: Boolean read GetIsUtf8 write SetIsUtf8;
|
||||
property Ranges: TSynEditStorageMem read GetRange write PutRange;
|
||||
property Ranges[Index: TClass]: TSynEditStorageMem read GetRange write PutRange;
|
||||
property TextChangeStamp: int64 read FTextChangeStamp;
|
||||
end;
|
||||
|
||||
@ -176,8 +176,8 @@ type
|
||||
function GetIsUtf8 : Boolean; override;
|
||||
procedure SetIsUtf8(const AValue : Boolean); override;
|
||||
|
||||
function GetRange: TSynEditStorageMem; override;
|
||||
procedure PutRange(ARange: TSynEditStorageMem); override;
|
||||
function GetRange(Index: TClass): TSynEditStorageMem; override;
|
||||
procedure PutRange(Index: TClass; const ARange: TSynEditStorageMem); override;
|
||||
|
||||
function GetAttribute(const Owner: TClass; const Index: Integer): Pointer; override;
|
||||
procedure SetAttribute(const Owner: TClass; const Index: Integer; const AValue: Pointer); override;
|
||||
@ -230,7 +230,7 @@ type
|
||||
AHandler: TMethod); override;
|
||||
|
||||
function GetPhysicalCharWidths(const Line: String; Index: Integer): TPhysicalCharWidths; override;
|
||||
property NextLines: TSynEditStrings read fSynStrings;
|
||||
property NextLines: TSynEditStrings read fSynStrings write fSynStrings;
|
||||
public
|
||||
// LogX, LogY are 1-based
|
||||
procedure EditInsert(LogX, LogY: Integer; AText: String); override;
|
||||
@ -593,14 +593,14 @@ begin
|
||||
end;
|
||||
|
||||
//Ranges
|
||||
function TSynEditStringsLinked.GetRange: TSynEditStorageMem;
|
||||
function TSynEditStringsLinked.GetRange(Index: TClass): TSynEditStorageMem;
|
||||
begin
|
||||
Result:= fSynStrings.Ranges;
|
||||
Result:= fSynStrings.Ranges[Index];
|
||||
end;
|
||||
|
||||
procedure TSynEditStringsLinked.PutRange(ARange: TSynEditStorageMem);
|
||||
procedure TSynEditStringsLinked.PutRange(Index: TClass; const ARange: TSynEditStorageMem);
|
||||
begin
|
||||
fSynStrings.Ranges := ARange;
|
||||
fSynStrings.Ranges[Index] := ARange;
|
||||
end;
|
||||
|
||||
function TSynEditStringsLinked.GetAttribute(const Owner: TClass; const Index: Integer): Pointer;
|
||||
|
@ -84,18 +84,24 @@ type
|
||||
|
||||
{ TSynEditStringMemory }
|
||||
|
||||
TSynEditStringRangeEntry = record
|
||||
Index: TClass;
|
||||
Data: TSynEditStorageMem;
|
||||
end;
|
||||
|
||||
TSynEditStringMemory = class(TSynEditStorageMem)
|
||||
private
|
||||
FAttributeSize: Integer;
|
||||
FRangeList: TSynEditStorageMem;
|
||||
FRangeList: Array of TSynEditStringRangeEntry;
|
||||
function GetAttribute(Index: Integer; Pos: Integer; Size: Word): Pointer;
|
||||
function GetAttributeSize: Integer;
|
||||
function GetObject(Index: Integer): TObject;
|
||||
function GetRange(Index: TClass): TSynEditStorageMem;
|
||||
function GetString(Index: Integer): String;
|
||||
procedure SetAttribute(Index: Integer; Pos: Integer; Size: Word; const AValue: Pointer);
|
||||
procedure SetAttributeSize(const AValue: Integer);
|
||||
procedure SetObject(Index: Integer; const AValue: TObject);
|
||||
procedure SetRangeList(const AValue: TSynEditStorageMem);
|
||||
procedure SetRange(Index: TClass; const AValue: TSynEditStorageMem);
|
||||
procedure SetString(Index: Integer; const AValue: String);
|
||||
protected
|
||||
procedure SetCount(const AValue: Integer); override;
|
||||
@ -111,7 +117,7 @@ type
|
||||
read GetAttribute write SetAttribute;
|
||||
property AttributeSize: Integer read GetAttributeSize write SetAttributeSize;
|
||||
|
||||
property RangeList: TSynEditStorageMem read FRangeList write SetRangeList;
|
||||
property RangeList[Index: TClass]: TSynEditStorageMem read GetRange write SetRange;
|
||||
end;
|
||||
|
||||
{ TSynEditStringList }
|
||||
@ -124,6 +130,7 @@ type
|
||||
FLineRangeNotificationList: TLineRangeNotificationList; // LineCount
|
||||
FLineChangeNotificationList: TLineRangeNotificationList; // ContentChange (not called on add...)
|
||||
FLineEditNotificationList: TLineEditNotificationList;
|
||||
FRefCount: integer;
|
||||
FUndoRedoAddedNotificationList: TSynMethodList;
|
||||
FOnChangeList: TSynMethodList;
|
||||
FOnChangingList: TSynMethodList;
|
||||
@ -160,8 +167,8 @@ type
|
||||
procedure IgnoreSendNotification(AReason: TSynEditNotifyReason;
|
||||
IncIgnore: Boolean); override;
|
||||
|
||||
function GetRange: TSynEditStorageMem; override;
|
||||
procedure PutRange(ARange: TSynEditStorageMem); override;
|
||||
function GetRange(Index: TClass): TSynEditStorageMem; override;
|
||||
procedure PutRange(Index: TClass; const ARange: TSynEditStorageMem); override;
|
||||
function GetAttribute(const Owner: TClass; const Index: Integer): Pointer; override;
|
||||
procedure SetAttribute(const Owner: TClass; const Index: Integer; const AValue: Pointer); override;
|
||||
function Get(Index: integer): string; override;
|
||||
@ -197,6 +204,13 @@ type
|
||||
AHandler: TMethod); override;
|
||||
procedure RemoveGenericHandler(AReason: TSynEditNotifyReason;
|
||||
AHandler: TMethod); override;
|
||||
{$IFDEF SynDualView}
|
||||
procedure CopyHanlders(OtherLines: TSynEditStringList; AOwner: TObject = nil);
|
||||
procedure RemoveHanlders(AOwner: TObject);
|
||||
{$ENDIF}
|
||||
procedure IncRefCount;
|
||||
procedure DecRefCount;
|
||||
property RefCount: integer read FRefCount;
|
||||
function GetPhysicalCharWidths(const Line: String; Index: Integer): TPhysicalCharWidths; override;
|
||||
public
|
||||
property DosFileFormat: boolean read fDosFileFormat write fDosFileFormat;
|
||||
@ -399,6 +413,7 @@ var
|
||||
r: TSynEditNotifyReason;
|
||||
begin
|
||||
fList := TSynEditStringMemory.Create;
|
||||
FRefCount := 1;
|
||||
|
||||
FUndoList := TSynEditUndoList.Create;
|
||||
fUndoList.OnAddedUndo := {$IFDEF FPC}@{$ENDIF}UndoRedoAdded;
|
||||
@ -671,9 +686,9 @@ begin
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
function TSynEditStringList.GetRange: TSynEditStorageMem;
|
||||
function TSynEditStringList.GetRange(Index: TClass): TSynEditStorageMem;
|
||||
begin
|
||||
Result := FList.RangeList;
|
||||
Result := FList.RangeList[Index];
|
||||
end;
|
||||
|
||||
procedure TSynEditStringList.Grow;
|
||||
@ -778,9 +793,9 @@ begin
|
||||
EndUpdate;
|
||||
end;
|
||||
|
||||
procedure TSynEditStringList.PutRange(ARange: TSynEditStorageMem);
|
||||
procedure TSynEditStringList.PutRange(Index: TClass; const ARange: TSynEditStorageMem);
|
||||
begin
|
||||
FList.RangeList := ARange;
|
||||
FList.RangeList[Index] := ARange;
|
||||
end;
|
||||
|
||||
function TSynEditStringList.GetAttribute(const Owner: TClass; const Index: Integer): Pointer;
|
||||
@ -912,6 +927,40 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
{$IFDEF SynDualView}
|
||||
procedure TSynEditStringList.CopyHanlders(OtherLines: TSynEditStringList; AOwner: TObject = nil);
|
||||
begin
|
||||
FLineRangeNotificationList.AddCopyFrom(OtherLines.FLineRangeNotificationList, AOwner);
|
||||
FLineChangeNotificationList.AddCopyFrom(OtherLines.FLineChangeNotificationList, AOwner);
|
||||
FLineEditNotificationList.AddCopyFrom(OtherLines.FLineEditNotificationList, AOwner);
|
||||
FUndoRedoAddedNotificationList.AddCopyFrom(OtherLines.FUndoRedoAddedNotificationList, AOwner);
|
||||
FOnChangeList.AddCopyFrom(OtherLines.FOnChangeList, AOwner);
|
||||
FOnChangingList.AddCopyFrom(OtherLines.FOnChangingList, AOwner);
|
||||
FOnClearedList.AddCopyFrom(OtherLines.FOnClearedList, AOwner);
|
||||
end;
|
||||
|
||||
procedure TSynEditStringList.RemoveHanlders(AOwner: TObject);
|
||||
begin
|
||||
FLineRangeNotificationList.RemoveAllMethodsOfObject(AOwner);
|
||||
FLineChangeNotificationList.RemoveAllMethodsOfObject(AOwner);
|
||||
FLineEditNotificationList.RemoveAllMethodsOfObject(AOwner);
|
||||
FUndoRedoAddedNotificationList.RemoveAllMethodsOfObject(AOwner);
|
||||
FOnChangeList.RemoveAllMethodsOfObject(AOwner);
|
||||
FOnChangingList.RemoveAllMethodsOfObject(AOwner);
|
||||
FOnClearedList.RemoveAllMethodsOfObject(AOwner);
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
procedure TSynEditStringList.IncRefCount;
|
||||
begin
|
||||
inc(FRefCount);
|
||||
end;
|
||||
|
||||
procedure TSynEditStringList.DecRefCount;
|
||||
begin
|
||||
dec(FRefCount);
|
||||
end;
|
||||
|
||||
procedure TSynEditStringList.SetCapacity(NewCapacity: integer);
|
||||
begin
|
||||
fList.SetCapacity(NewCapacity);
|
||||
@ -1075,8 +1124,8 @@ begin
|
||||
for i:=ATo+Alen-Len to ATo+ALen -1 do Strings[i]:='';
|
||||
end;
|
||||
inherited Move(AFrom, ATo, ALen);
|
||||
if assigned(FRangeList) then
|
||||
FRangeList.Move(AFrom, ATo, ALen);
|
||||
for i := 0 to length(FRangeList) - 1 do
|
||||
FRangeList[i].Data.Move(AFrom, ATo, ALen);
|
||||
end;
|
||||
|
||||
procedure TSynEditStringMemory.SetCount(const AValue: Integer);
|
||||
@ -1086,8 +1135,8 @@ begin
|
||||
If Count = AValue then exit;
|
||||
for i:= AValue to Count-1 do Strings[i]:='';
|
||||
inherited SetCount(AValue);
|
||||
if assigned(FRangeList) then
|
||||
FRangeList.Count := AValue;
|
||||
for i := 0 to length(FRangeList) - 1 do
|
||||
FRangeList[i].Data.Count := AValue;
|
||||
end;
|
||||
|
||||
function TSynEditStringMemory.GetAttributeSize: Integer;
|
||||
@ -1122,10 +1171,12 @@ begin
|
||||
end;
|
||||
|
||||
procedure TSynEditStringMemory.SetCapacity(const AValue: Integer);
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
inherited SetCapacity(AValue);
|
||||
if assigned(FRangeList) then
|
||||
FRangeList.Capacity := AValue;
|
||||
for i := 0 to length(FRangeList) - 1 do
|
||||
FRangeList[i].Data.Capacity := AValue;
|
||||
end;
|
||||
|
||||
function TSynEditStringMemory.GetObject(Index: Integer): TObject;
|
||||
@ -1133,17 +1184,47 @@ begin
|
||||
Result := (PObject(Mem + Index * FAttributeSize + SizeOf(String)))^;
|
||||
end;
|
||||
|
||||
function TSynEditStringMemory.GetRange(Index: TClass): TSynEditStorageMem;
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
for i := 0 to length(FRangeList) - 1 do
|
||||
if FRangeList[i].Index = Index then
|
||||
exit(FRangeList[i].Data);
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
procedure TSynEditStringMemory.SetObject(Index: Integer; const AValue: TObject);
|
||||
begin
|
||||
(PObject(Mem + Index * FAttributeSize + SizeOf(String)))^ := AValue;
|
||||
end;
|
||||
|
||||
procedure TSynEditStringMemory.SetRangeList(const AValue: TSynEditStorageMem);
|
||||
procedure TSynEditStringMemory.SetRange(Index: TClass; const AValue: TSynEditStorageMem);
|
||||
var
|
||||
i, j: Integer;
|
||||
begin
|
||||
FRangeList := AValue;
|
||||
if FRangeList <> nil then begin
|
||||
FRangeList.Capacity := Capacity;
|
||||
FRangeList.Count := Count;
|
||||
i := length(FRangeList) - 1;
|
||||
while (i >= 0) and (FRangeList[i].Index <> Index) do
|
||||
dec(i);
|
||||
|
||||
if i < 0 then begin
|
||||
i := length(FRangeList);
|
||||
SetLength(FRangeList, i + 1);
|
||||
FRangeList[i].Index := Index;
|
||||
end
|
||||
else
|
||||
if AValue <> nil then
|
||||
DebugLn(['TSynEditStringMemory.SetRange - Overwriting old range at index=', i, ' index=', dbgs(Index)]);
|
||||
|
||||
FRangeList[i].Data := AValue;
|
||||
|
||||
if AValue <> nil then begin
|
||||
AValue.Capacity := Capacity;
|
||||
AValue.Count := Count;
|
||||
end else begin
|
||||
for j := i to length(FRangeList) - 2 do
|
||||
FRangeList[j] := FRangeList[j+1];
|
||||
SetLength(FRangeList, length(FRangeList) - 1);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -1929,6 +1929,9 @@ resourcestring
|
||||
uemProcedureJump = 'Procedure Jump';
|
||||
uemClosePage = '&Close Page';
|
||||
uemCloseOtherPages = 'Close All &Other Pages';
|
||||
{$IFDEF SynDualView}
|
||||
uemOpenAnotherView = 'Open in another View';
|
||||
{$ENDIF}
|
||||
uemCut = 'Cut';
|
||||
uemCopy = 'Copy';
|
||||
uemPaste = 'Paste';
|
||||
|
@ -153,6 +153,9 @@ type
|
||||
FOnKeyDown: TKeyEvent;
|
||||
|
||||
FSourceNoteBook: TSourceNotebook;
|
||||
{$IFDEF SynDualView}
|
||||
FOtherViewList: TList;
|
||||
{$ENDIF}
|
||||
|
||||
procedure EditorMouseMoved(Sender: TObject; Shift: TShiftState; X,Y:Integer);
|
||||
procedure EditorMouseDown(Sender: TObject; Button: TMouseButton;
|
||||
@ -229,6 +232,9 @@ type
|
||||
procedure SetReadOnly(const NewValue: boolean); override;
|
||||
|
||||
property Visible: Boolean read FVisible write SetVisible default False;
|
||||
{$IFDEF SynDualView}
|
||||
property OtherViewList: Tlist read FOtherViewList;
|
||||
{$ENDIF}
|
||||
public
|
||||
constructor Create(AOwner: TComponent; AParent: TWinControl);
|
||||
destructor Destroy; override;
|
||||
@ -520,6 +526,10 @@ type
|
||||
procedure SrcPopUpMenuPopup(Sender: TObject);
|
||||
procedure ToggleLineNumbersClicked(Sender: TObject);
|
||||
procedure InsertCharacter(const C: TUTF8Char);
|
||||
{$IFDEF SynDualView}
|
||||
procedure OnOtherFormClosed(Sender: TObject; var CloseAction: TCloseAction);
|
||||
procedure SrcEditMenuAnotherViewClicked(Sender: TObject);
|
||||
{$ENDIF}
|
||||
public
|
||||
procedure BookMarkNextClicked(Sender: TObject);
|
||||
procedure BookMarkPrevClicked(Sender: TObject);
|
||||
@ -945,6 +955,9 @@ var
|
||||
SrcEditMenuShowLineNumbers: TIDEMenuCommand;
|
||||
SrcEditMenuShowUnitInfo: TIDEMenuCommand;
|
||||
SrcEditMenuEditorProperties: TIDEMenuCommand;
|
||||
{$IFDEF SynDualView}
|
||||
SrcEditMenuAnotherView: TIDEMenuCommand;
|
||||
{$ENDIF}
|
||||
|
||||
|
||||
procedure RegisterStandardSourceEditorMenuItems;
|
||||
@ -1137,6 +1150,11 @@ begin
|
||||
{$IFNDEF EnableIDEDocking}
|
||||
SrcEditMenuDocking.Visible:=false;
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF SynDualView}
|
||||
SrcEditMenuAnotherView := RegisterIDEMenuCommand(SrcEditMenuSectionFirstStatic,
|
||||
'Open in another View', uemOpenAnotherView);
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
{ TSourceEditor }
|
||||
@ -1153,6 +1171,9 @@ Begin
|
||||
else
|
||||
FSourceNoteBook:=nil;
|
||||
|
||||
{$IFDEF SynDualView}
|
||||
FOtherViewList := TList.Create;
|
||||
{$ENDIF}
|
||||
FSyntaxHighlighterType:=lshNone;
|
||||
FErrorLine:=-1;
|
||||
FErrorColumn:=-1;
|
||||
@ -1185,6 +1206,9 @@ begin
|
||||
// free the synedit control after processing the events
|
||||
Application.ReleaseComponent(FEditor);
|
||||
end;
|
||||
{$IFDEF SynDualView}
|
||||
FreeAndNil(FOtherViewList);
|
||||
{$ENDIF}
|
||||
FEditor:=nil;
|
||||
CodeBuffer := nil;
|
||||
if (DebugBoss <> nil) and (DebugBoss.LineInfo <> nil) then
|
||||
@ -2474,11 +2498,25 @@ begin
|
||||
end;
|
||||
|
||||
Function TSourceEditor.RefreshEditorSettings: Boolean;
|
||||
{$IFDEF SynDualView}
|
||||
var
|
||||
s: TComponent;
|
||||
i: Integer;
|
||||
{$ENDIF}
|
||||
Begin
|
||||
Result:=true;
|
||||
SetSyntaxHighlighterType(fSyntaxHighlighterType);
|
||||
EditorOpts.GetSynEditSettings(FEditor);
|
||||
SourceNotebook.UpdateActiveEditColors(FEditor);
|
||||
{$IFDEF SynDualView}
|
||||
for i := 0 to FOtherViewList.Count - 1 do begin
|
||||
s := TForm(FOtherViewList[i]).FindComponent('s');
|
||||
if s <> nil then begin
|
||||
EditorOpts.GetSynEditSettings(TSynEdit(s));
|
||||
TSynEdit(s).Highlighter := Highlighters[fSyntaxHighlighterType]
|
||||
end;
|
||||
end;
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
Procedure TSourceEditor.ccAddMessage(Texts: String);
|
||||
@ -3426,7 +3464,16 @@ end;
|
||||
|
||||
procedure TSourceEditor.UnbindEditor;
|
||||
// disconnect all events
|
||||
{$IFDEF SynDualView}
|
||||
var
|
||||
i: Integer;
|
||||
{$ENDIF}
|
||||
begin
|
||||
{$IFDEF SynDualView}
|
||||
for i := 0 to FOtherViewList.Count - 1 do
|
||||
TForm(FOtherViewList[i]).Free;
|
||||
FOtherViewList.Clear;
|
||||
{$ENDIF}
|
||||
with EditorComponent do begin
|
||||
OnStatusChange := nil;
|
||||
OnProcessCommand := nil;
|
||||
@ -4753,6 +4800,9 @@ begin
|
||||
SrcEditMenuShowLineNumbers.OnClick:=@ToggleLineNumbersClicked;
|
||||
SrcEditMenuShowUnitInfo.OnClick:=@ShowUnitInfo;
|
||||
SrcEditMenuEditorProperties.OnClick:=@EditorPropertiesClicked;
|
||||
{$IFDEF SynDualView}
|
||||
SrcEditMenuAnotherView.OnClick := @SrcEditMenuAnotherViewClicked;
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
function TSourceNotebook.GetNotebookPages: TStrings;
|
||||
@ -6473,6 +6523,49 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
{$IFDEF SynDualView}
|
||||
procedure TSourceNotebook.OnOtherFormClosed(Sender: TObject; var CloseAction: TCloseAction);
|
||||
var
|
||||
ASrcEdit: TSourceEditor;
|
||||
s: TSynEdit;
|
||||
begin
|
||||
s := TSynEdit(TForm(Sender).FindComponent('s'));
|
||||
ASrcEdit := FindSourceEditorWithEditorComponent(s.SharedViewEdit);
|
||||
ASrcEdit.OtherViewList.Remove(Sender);
|
||||
CloseAction := caFree;
|
||||
end;
|
||||
|
||||
procedure TSourceNotebook.SrcEditMenuAnotherViewClicked(Sender: TObject);
|
||||
var
|
||||
ASrcEdit: TSourceEditor;
|
||||
f: TForm;
|
||||
s: TSynEdit;
|
||||
SyncroEdit: TSynPluginSyncroEdit;
|
||||
bmp: TCustomBitmap;
|
||||
begin
|
||||
ASrcEdit:=GetActiveSE;
|
||||
if ASrcEdit=nil then exit;
|
||||
f := TForm.Create(Application);
|
||||
f.OnClose := @OnOtherFormClosed;
|
||||
f.Caption := ASrcEdit.FileName;
|
||||
|
||||
s := TSynEdit.Create(f);
|
||||
s.name := 's';
|
||||
s.Parent := f;
|
||||
s.Align := alClient;
|
||||
s.SharedViewEdit := ASrcEdit.EditorComponent;
|
||||
s.Highlighter := ASrcEdit.EditorComponent.Highlighter;
|
||||
SyncroEdit := TSynPluginSyncroEdit.Create(s);
|
||||
bmp := CreateBitmapFromLazarusResource('tsynsyncroedit');
|
||||
SyncroEdit.GutterGlyph.Assign(bmp);
|
||||
bmp.Free;
|
||||
EditorOpts.GetSynEditSettings(s);
|
||||
|
||||
f.show;
|
||||
ASrcEdit.OtherViewList.Add(f);
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
procedure TSourceNotebook.InitFindDialog;
|
||||
var c: TFindDlgComponent;
|
||||
begin
|
||||
|
Loading…
Reference in New Issue
Block a user