fix, synchronized edition broken

after a while, due to a shared component.
This commit is contained in:
Basile Burg 2015-04-20 00:59:02 +02:00
parent 6668c04bd3
commit 169c42c2e9
2 changed files with 19 additions and 21 deletions

View File

@ -36,8 +36,6 @@ type
private private
fKeyChanged: boolean; fKeyChanged: boolean;
fDoc: TCESynMemo; fDoc: TCESynMemo;
// TODO-cbugfix: syncro-edit partially broken, undetermined condition
fSyncEdit: TSynPluginSyncroEdit;
fTokList: TLexTokenList; fTokList: TLexTokenList;
fErrList: TLexErrorList; fErrList: TLexErrorList;
fModStart: boolean; fModStart: boolean;
@ -90,25 +88,12 @@ end;
{$REGION Standard Comp/Obj------------------------------------------------------} {$REGION Standard Comp/Obj------------------------------------------------------}
constructor TCEEditorWidget.create(aOwner: TComponent); constructor TCEEditorWidget.create(aOwner: TComponent);
var
png: TPortableNetworkGraphic;
begin begin
inherited; inherited;
// //
fTokList := TLexTokenList.Create; fTokList := TLexTokenList.Create;
fErrList := TLexErrorList.Create; fErrList := TLexErrorList.Create;
//
completion.OnPaintItem := @completionItemPaint; completion.OnPaintItem := @completionItemPaint;
fSyncEdit := TSynPluginSyncroEdit.Create(self);
fSyncEdit.CaseSensitive:=true;
png := TPortableNetworkGraphic.Create;
try
png.LoadFromLazarusResource('link_edit');
fSyncEdit.GutterGlyph.Assign(png);
finally
png.Free;
end;
//
{$IFDEF LINUX} {$IFDEF LINUX}
PageControl.OnCloseTabClicked := @pageCloseBtnClick; PageControl.OnCloseTabClicked := @pageCloseBtnClick;
{$ENDIF} {$ENDIF}
@ -297,11 +282,9 @@ end;
procedure TCEEditorWidget.focusedEditorChanged; procedure TCEEditorWidget.focusedEditorChanged;
begin begin
macRecorder.Clear; macRecorder.Clear;
fSyncEdit.Clear;
if fDoc = nil then exit; if fDoc = nil then exit;
// //
macRecorder.Editor:= fDoc; macRecorder.Editor:= fDoc;
fSyncEdit.Editor := fDoc;
completion.Editor := fDoc; completion.Editor := fDoc;
if (pageControl.ActivePage.Caption = '') then if (pageControl.ActivePage.Caption = '') then
begin begin
@ -458,7 +441,7 @@ begin
// - editor is saved // - editor is saved
// - gutter is updated (green bar indicating a saved block) // - gutter is updated (green bar indicating a saved block)
// - syncroedit icon is hidden // - syncroedit icon is hidden
if fSyncEdit.Active then if fDoc.syncroEdit.Active then
fDoc.Refresh; fDoc.Refresh;
end; end;
{$ENDREGION} {$ENDREGION}

View File

@ -5,7 +5,7 @@ unit ce_synmemo;
interface interface
uses uses
Classes, SysUtils, controls,lcltype, Forms, graphics, ExtCtrls, crc, Classes, SysUtils, controls,lcltype, Forms, graphics, ExtCtrls, crc, SynPluginSyncroEdit,
SynEditKeyCmds, LazSynEditText, SynEditHighlighter, SynEdit, SynHighlighterLFM, SynEditKeyCmds, LazSynEditText, SynEditHighlighter, SynEdit, SynHighlighterLFM,
SynEditMouseCmds, SynEditFoldedView, ce_common, ce_observer, ce_writableComponent, SynEditMouseCmds, SynEditFoldedView, ce_common, ce_observer, ce_writableComponent,
ce_d2syn, ce_txtsyn; ce_d2syn, ce_txtsyn;
@ -22,7 +22,7 @@ type
AData: Pointer): TRect; override; AData: Pointer): TRect; override;
end; end;
// Stores the state of a particulat source code folding. // Stores the state of a particular source code folding.
TCEFoldCache = class(TCollectionItem) TCEFoldCache = class(TCollectionItem)
private private
fCollapsed: boolean; fCollapsed: boolean;
@ -94,6 +94,7 @@ type
fHintTimer: TIdleTimer; fHintTimer: TIdleTimer;
fCanShowHint: boolean; fCanShowHint: boolean;
fOldMousePos: TPoint; fOldMousePos: TPoint;
fSyncEdit: TSynPluginSyncroEdit;
function getMouseFileBytePos: Integer; function getMouseFileBytePos: Integer;
procedure changeNotify(Sender: TObject); procedure changeNotify(Sender: TObject);
procedure identifierToD2Syn; procedure identifierToD2Syn;
@ -132,6 +133,7 @@ type
property modified: boolean read fModified; property modified: boolean read fModified;
property tempFilename: string read fTempFileName; property tempFilename: string read fTempFileName;
// //
property syncroEdit: TSynPluginSyncroEdit read fSyncEdit;
property isDSource: boolean read fIsDSource; property isDSource: boolean read fIsDSource;
property isProjectSource: boolean read fIsConfig; property isProjectSource: boolean read fIsConfig;
property TextView; property TextView;
@ -327,6 +329,8 @@ end;
{$REGION TCESynMemo ------------------------------------------------------------} {$REGION TCESynMemo ------------------------------------------------------------}
constructor TCESynMemo.Create(aOwner: TComponent); constructor TCESynMemo.Create(aOwner: TComponent);
var
png: TPortableNetworkGraphic;
begin begin
inherited; inherited;
// //
@ -348,6 +352,17 @@ begin
Gutter.CodeFoldPart.MarkupInfo.Foreground := clGray; Gutter.CodeFoldPart.MarkupInfo.Foreground := clGray;
BracketMatchColor.Foreground:=clRed; BracketMatchColor.Foreground:=clRed;
// //
fSyncEdit := TSynPluginSyncroEdit.Create(self);
fSyncEdit.Editor := self;
fSyncEdit.CaseSensitive := true;
png := TPortableNetworkGraphic.Create;
try
png.LoadFromLazarusResource('link_edit');
fSyncEdit.GutterGlyph.Assign(png);
finally
png.Free;
end;
//
MouseLinkColor.Style:= [fsUnderline]; MouseLinkColor.Style:= [fsUnderline];
with MouseActions.Add do begin with MouseActions.Add do begin
Command := emcMouseLink; Command := emcMouseLink;