diff --git a/components/synedit/synpluginsyncronizededitbase.pp b/components/synedit/synpluginsyncronizededitbase.pp index ef2ca409f7..78d2128d87 100644 --- a/components/synedit/synpluginsyncronizededitbase.pp +++ b/components/synedit/synpluginsyncronizededitbase.pp @@ -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; diff --git a/ide/sourceeditor.pp b/ide/sourceeditor.pp index 0be2a69fdc..2780967c3a 100644 --- a/ide/sourceeditor.pp +++ b/ide/sourceeditor.pp @@ -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;