mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-01 15:20:29 +02:00
SynEdit, SourceEditor: refactored Syncro-edit detection
git-svn-id: trunk@22787 -
This commit is contained in:
parent
a94da35a04
commit
e1c8b64e3f
@ -150,6 +150,8 @@ type
|
|||||||
fMarkupInfoSync: TSynSelectedColor;
|
fMarkupInfoSync: TSynSelectedColor;
|
||||||
fMarkupInfoCurrent: TSynSelectedColor;
|
fMarkupInfoCurrent: TSynSelectedColor;
|
||||||
fMarkupInfoArea: TSynSelectedColor;
|
fMarkupInfoArea: TSynSelectedColor;
|
||||||
|
FOnActivate: TNotifyEvent;
|
||||||
|
FOnDeactivate: TNotifyEvent;
|
||||||
|
|
||||||
function GetActive: Boolean;
|
function GetActive: Boolean;
|
||||||
procedure SetActive(const AValue: Boolean);
|
procedure SetActive(const AValue: Boolean);
|
||||||
@ -187,6 +189,8 @@ type
|
|||||||
property MarkupInfoCurrent: TSynSelectedColor read FMarkupInfoCurrent;
|
property MarkupInfoCurrent: TSynSelectedColor read FMarkupInfoCurrent;
|
||||||
property MarkupInfoSync: TSynSelectedColor read FMarkupInfoSync;
|
property MarkupInfoSync: TSynSelectedColor read FMarkupInfoSync;
|
||||||
property MarkupInfoArea: TSynSelectedColor read FMarkupInfoArea;
|
property MarkupInfoArea: TSynSelectedColor read FMarkupInfoArea;
|
||||||
|
property OnActivate: TNotifyEvent read FOnActivate write FOnActivate;
|
||||||
|
property OnDeactivate: TNotifyEvent read FOnDeactivate write FOnDeactivate;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
(* TSynPluginCustomSyncroEdit implements:
|
(* TSynPluginCustomSyncroEdit implements:
|
||||||
@ -937,12 +941,14 @@ end;
|
|||||||
|
|
||||||
procedure TSynPluginSyncronizedEditBase.DoOnActivate;
|
procedure TSynPluginSyncronizedEditBase.DoOnActivate;
|
||||||
begin
|
begin
|
||||||
(* Do Nothing *);
|
if assigned(FOnActivate) then
|
||||||
|
FOnActivate(self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSynPluginSyncronizedEditBase.DoOnDeactivate;
|
procedure TSynPluginSyncronizedEditBase.DoOnDeactivate;
|
||||||
begin
|
begin
|
||||||
(* Do Nothing *);
|
if assigned(FOnDeactivate) then
|
||||||
|
FOnDeactivate(self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TSynPluginSyncronizedEditCell }
|
{ TSynPluginSyncronizedEditCell }
|
||||||
@ -984,6 +990,7 @@ procedure TSynPluginCustomSyncroEdit.DoOnActivate;
|
|||||||
var
|
var
|
||||||
b: TSynEditStrings;
|
b: TSynEditStrings;
|
||||||
begin
|
begin
|
||||||
|
inherited;
|
||||||
b := ViewedTextBuffer;
|
b := ViewedTextBuffer;
|
||||||
while b <> nil do begin
|
while b <> nil do begin
|
||||||
if b is TSynEditStringTrimmingList then TSynEditStringTrimmingList(b).Lock;
|
if b is TSynEditStringTrimmingList then TSynEditStringTrimmingList(b).Lock;
|
||||||
@ -998,6 +1005,7 @@ procedure TSynPluginCustomSyncroEdit.DoOnDeactivate;
|
|||||||
var
|
var
|
||||||
b: TSynEditStrings;
|
b: TSynEditStrings;
|
||||||
begin
|
begin
|
||||||
|
inherited;
|
||||||
FUndoRealCount := -1;
|
FUndoRealCount := -1;
|
||||||
FRedoRealCount := -1;
|
FRedoRealCount := -1;
|
||||||
b := ViewedTextBuffer;
|
b := ViewedTextBuffer;
|
||||||
|
@ -117,8 +117,7 @@ type
|
|||||||
FEditor: TSynEdit;
|
FEditor: TSynEdit;
|
||||||
FEditPlugin: TSynEditPlugin1; // used to get the LinesInserted and
|
FEditPlugin: TSynEditPlugin1; // used to get the LinesInserted and
|
||||||
// LinesDeleted messages
|
// LinesDeleted messages
|
||||||
FSyncroEdit: TSynPluginSyncroEdit;
|
FSyncroLockCount: Integer;
|
||||||
FTemplateEdit: TSynPluginTemplateEdit;
|
|
||||||
FCodeTemplates: TSynEditAutoComplete;
|
FCodeTemplates: TSynEditAutoComplete;
|
||||||
FHasExecutionMarks: Boolean;
|
FHasExecutionMarks: Boolean;
|
||||||
FMarksRequested: Boolean;
|
FMarksRequested: Boolean;
|
||||||
@ -171,6 +170,8 @@ type
|
|||||||
procedure EditorPaste(Sender: TObject; var AText: String;
|
procedure EditorPaste(Sender: TObject; var AText: String;
|
||||||
var AMode: TSynSelectionMode; ALogStartPos: TPoint;
|
var AMode: TSynSelectionMode; ALogStartPos: TPoint;
|
||||||
var AnAction: TSynCopyPasteAction);
|
var AnAction: TSynCopyPasteAction);
|
||||||
|
procedure EditorActivateSyncro(Sender: TObject);
|
||||||
|
procedure EditorDeactivateSyncro(Sender: TObject);
|
||||||
procedure SetCodeBuffer(NewCodeBuffer: TCodeBuffer);
|
procedure SetCodeBuffer(NewCodeBuffer: TCodeBuffer);
|
||||||
function GetSource: TStrings;
|
function GetSource: TStrings;
|
||||||
procedure SetPageName(const AValue: string);
|
procedure SetPageName(const AValue: string);
|
||||||
@ -405,10 +406,9 @@ type
|
|||||||
property ReadOnly: Boolean read GetReadOnly write SetReadOnly;
|
property ReadOnly: Boolean read GetReadOnly write SetReadOnly;
|
||||||
property Source: TStrings read GetSource write SetSource;
|
property Source: TStrings read GetSource write SetSource;
|
||||||
property SourceNotebook: TSourceNotebook read FSourceNoteBook;
|
property SourceNotebook: TSourceNotebook read FSourceNoteBook;
|
||||||
property SyncroEdit: TSynPluginSyncroEdit read FSyncroEdit;
|
|
||||||
property SyntaxHighlighterType: TLazSyntaxHighlighter
|
property SyntaxHighlighterType: TLazSyntaxHighlighter
|
||||||
read fSyntaxHighlighterType write SetSyntaxHighlighterType;
|
read fSyntaxHighlighterType write SetSyntaxHighlighterType;
|
||||||
property TemplateEdit: TSynPluginTemplateEdit read FTemplateEdit;
|
property SyncroLockCount: Integer read FSyncroLockCount;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
@ -1181,6 +1181,7 @@ Begin
|
|||||||
FExecutionMark := nil;
|
FExecutionMark := nil;
|
||||||
FHasExecutionMarks := False;
|
FHasExecutionMarks := False;
|
||||||
FMarksRequested := False;
|
FMarksRequested := False;
|
||||||
|
FSyncroLockCount := 0;
|
||||||
FLineInfoNotification := TIDELineInfoNotification.Create;
|
FLineInfoNotification := TIDELineInfoNotification.Create;
|
||||||
FLineInfoNotification.AddReference;
|
FLineInfoNotification.AddReference;
|
||||||
FLineInfoNotification.OnChange := @LineInfoNotificationChange;
|
FLineInfoNotification.OnChange := @LineInfoNotificationChange;
|
||||||
@ -2598,6 +2599,8 @@ 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 ');
|
||||||
@ -2641,11 +2644,15 @@ Begin
|
|||||||
FCodeTemplates.AddEditor(FEditor);
|
FCodeTemplates.AddEditor(FEditor);
|
||||||
if aCompletion<>nil then
|
if aCompletion<>nil then
|
||||||
aCompletion.AddEditor(FEditor);
|
aCompletion.AddEditor(FEditor);
|
||||||
FTemplateEdit:=TSynPluginTemplateEdit.Create(FEditor);
|
TemplateEdit:=TSynPluginTemplateEdit.Create(FEditor);
|
||||||
FSyncroEdit := TSynPluginSyncroEdit.Create(FEditor);
|
TemplateEdit.OnActivate := @EditorActivateSyncro;
|
||||||
|
TemplateEdit.OnDeactivate := @EditorDeactivateSyncro;
|
||||||
|
SyncroEdit := TSynPluginSyncroEdit.Create(FEditor);
|
||||||
bmp := CreateBitmapFromLazarusResource('tsynsyncroedit');
|
bmp := CreateBitmapFromLazarusResource('tsynsyncroedit');
|
||||||
FSyncroEdit.GutterGlyph.Assign(bmp);
|
SyncroEdit.GutterGlyph.Assign(bmp);
|
||||||
bmp.Free;
|
bmp.Free;
|
||||||
|
SyncroEdit.OnActivate := @EditorActivateSyncro;
|
||||||
|
SyncroEdit.OnDeactivate := @EditorDeactivateSyncro;
|
||||||
RefreshEditorSettings;
|
RefreshEditorSettings;
|
||||||
FEditor.EndUpdate;
|
FEditor.EndUpdate;
|
||||||
end else begin
|
end else begin
|
||||||
@ -3037,8 +3044,7 @@ var
|
|||||||
NewSrc: string;
|
NewSrc: string;
|
||||||
begin
|
begin
|
||||||
if AMode<>smNormal then exit;
|
if AMode<>smNormal then exit;
|
||||||
if SyncroEdit.Active then exit;
|
if SyncroLockCount > 0 then exit;
|
||||||
if TemplateEdit.Active then exit;
|
|
||||||
if not CodeToolsOpts.IndentOnPaste then exit;
|
if not CodeToolsOpts.IndentOnPaste then exit;
|
||||||
{$IFDEF VerboseIndenter}
|
{$IFDEF VerboseIndenter}
|
||||||
debugln(['TSourceEditor.EditorPaste LogCaret=',dbgs(ALogStartPos)]);
|
debugln(['TSourceEditor.EditorPaste LogCaret=',dbgs(ALogStartPos)]);
|
||||||
@ -3072,6 +3078,16 @@ begin
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TSourceEditor.EditorActivateSyncro(Sender: TObject);
|
||||||
|
begin
|
||||||
|
inc(FSyncroLockCount);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSourceEditor.EditorDeactivateSyncro(Sender: TObject);
|
||||||
|
begin
|
||||||
|
dec(FSyncroLockCount);
|
||||||
|
end;
|
||||||
|
|
||||||
Procedure TSourceEditor.EditorMouseMoved(Sender: TObject;
|
Procedure TSourceEditor.EditorMouseMoved(Sender: TObject;
|
||||||
Shift: TShiftState; X,Y: Integer);
|
Shift: TShiftState; X,Y: Integer);
|
||||||
begin
|
begin
|
||||||
@ -7021,8 +7037,7 @@ begin
|
|||||||
Reason, SetIndentProc);
|
Reason, SetIndentProc);
|
||||||
if Result then exit;
|
if Result then exit;
|
||||||
end;
|
end;
|
||||||
if (SrcEdit.SyncroEdit<>nil) and SrcEdit.SyncroEdit.Active then exit;
|
if (SrcEdit.SyncroLockCount > 0) then exit;
|
||||||
if (SrcEdit.TemplateEdit<>nil) and SrcEdit.TemplateEdit.Active then exit;
|
|
||||||
if not (SrcEdit.SyntaxHighlighterType in [lshFreePascal, lshDelphi]) then
|
if not (SrcEdit.SyntaxHighlighterType in [lshFreePascal, lshDelphi]) then
|
||||||
exit;
|
exit;
|
||||||
if Reason<>ecLineBreak then exit;
|
if Reason<>ecLineBreak then exit;
|
||||||
|
Loading…
Reference in New Issue
Block a user