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