SynEdit: Ifdef Markup: remove ifdef, make live

git-svn-id: trunk@41608 -
This commit is contained in:
martin 2013-06-08 23:05:45 +00:00
parent 56864b2c96
commit e6c03e1b84
3 changed files with 9 additions and 69 deletions

View File

@ -99,19 +99,14 @@ type
ahaTemplateEditOther, ahaSyncroEditCur, ahaSyncroEditSync,
ahaSyncroEditOther, ahaSyncroEditArea, ahaGutterSeparator,
ahaGutter, ahaRightMargin, ahaSpecialVisibleChars,
ahaTopInfoHint
{$IFDEF WithSynMarkupIfDef}
, ahaIfDefBlockInactive, ahaIfDefBlockActive, ahaIfDefBlockTmpActive,
ahaTopInfoHint,
ahaIfDefBlockInactive, ahaIfDefBlockActive, ahaIfDefBlockTmpActive,
ahaIfDefNodeInactive, ahaIfDefNodeActive, ahaIfDefNodeTmpActive
{$ENDIF}
);
TAhaGroupName = (
agnDefault, agnLanguage, agnText, agnLine, agnGutter, agnTemplateMode, agnSyncronMode
{$IFDEF WithSynMarkupIfDef}
, agnIfDef
{$ENDIF}
agnDefault, agnLanguage, agnText, agnLine, agnGutter, agnTemplateMode, agnSyncronMode,
agnIfDef
);
TColorSchemeAttributeFeature =
@ -146,11 +141,9 @@ const
'', // ahaGutter
'', // ahaRightMargin
'', // ahaSpecialVisibleChars
'' // ahaTopInfoHint
{$IFDEF WithSynMarkupIfDef}
, '', '', '', // ahaIfDefBlockInactive, ahaIfDefBlockActive, ahaIfDefBlockTmpActive
'', // ahaTopInfoHint
'', '', '', // ahaIfDefBlockInactive, ahaIfDefBlockActive, ahaIfDefBlockTmpActive
'', '', '' // ahaIfDefNodeInactive, ahaIfDefNodeActive, ahaIfDefNodeTmpActive
{$ENDIF}
);
ahaGroupMap: array[TAdditionalHilightAttribute] of TAhaGroupName = (
@ -184,16 +177,13 @@ const
{ ahaGutter } agnGutter,
{ ahaRightMargin} agnGutter,
{ ahaSpecialVisibleChars } agnText,
{ ahaTopInfoHint } agnLine
{$IFDEF WithSynMarkupIfDef}
,
{ ahaTopInfoHint } agnLine,
{ ahaIfDefBlockInactive } agnIfDef,
{ ahaIfDefBlockActive } agnIfDef,
{ ahaIfDefBlockTmpActive } agnIfDef,
{ ahaIfDefNodeInactive } agnIfDef,
{ ahaIfDefNodeActive } agnIfDef,
{ ahaIfDefNodeTmpActive } agnIfDef
{$ENDIF}
);
ahaSupportedFeatures: array[TAdditionalHilightAttribute] of TColorSchemeAttributeFeatures =
(
@ -227,16 +217,13 @@ const
{ ahaGutter } [hafBackColor],
{ ahaRightMargin} [hafForeColor],
{ ahaSpecialVisibleChars }[hafBackColor, hafForeColor, hafFrameColor, hafAlpha, hafPrior, hafFrameStyle, hafFrameEdges, hafStyle, hafStyleMask],
{ ahaTopInfoHint } [hafBackColor, hafForeColor, hafFrameColor, hafAlpha, hafPrior, hafFrameStyle, hafFrameEdges, hafStyle, hafStyleMask]
{$IFDEF WithSynMarkupIfDef}
,
{ ahaTopInfoHint } [hafBackColor, hafForeColor, hafFrameColor, hafAlpha, hafPrior, hafFrameStyle, hafFrameEdges, hafStyle, hafStyleMask],
{ ahaIfDefBlockInactive } [hafBackColor, hafForeColor, hafFrameColor, hafAlpha, hafPrior, hafFrameStyle, hafFrameEdges, hafStyle, hafStyleMask],
{ ahaIfDefBlockActive } [hafBackColor, hafForeColor, hafFrameColor, hafAlpha, hafPrior, hafFrameStyle, hafFrameEdges, hafStyle, hafStyleMask],
{ ahaIfDefBlockTmpActive }[hafBackColor, hafForeColor, hafFrameColor, hafAlpha, hafPrior, hafFrameStyle, hafFrameEdges, hafStyle, hafStyleMask],
{ ahaIfDefNodeInactive } [hafBackColor, hafForeColor, hafFrameColor, hafAlpha, hafPrior, hafFrameStyle, hafFrameEdges, hafStyle, hafStyleMask],
{ ahaIfDefNodeActive } [hafBackColor, hafForeColor, hafFrameColor, hafAlpha, hafPrior, hafFrameStyle, hafFrameEdges, hafStyle, hafStyleMask],
{ ahaIfDefNodeTmpActive } [hafBackColor, hafForeColor, hafFrameColor, hafAlpha, hafPrior, hafFrameStyle, hafFrameEdges, hafStyle, hafStyleMask]
{$ENDIF}
);
@ -2512,7 +2499,6 @@ begin
AdditionalHighlightAttributes[ahaRightMargin] := dlgRightMargin;
AdditionalHighlightAttributes[ahaSpecialVisibleChars] := dlgAddHiSpecialVisibleChars;
AdditionalHighlightAttributes[ahaTopInfoHint] := dlgTopInfoHint;
{$IFDEF WithSynMarkupIfDef}
AdditionalHighlightAttributes[ahaIfDefBlockInactive] := dlgIfDefBlockInactive;
AdditionalHighlightAttributes[ahaIfDefBlockActive] := dlgIfDefBlockActive;
AdditionalHighlightAttributes[ahaIfDefBlockTmpActive] := dlgIfDefBlockTmpActive;
@ -2520,7 +2506,6 @@ begin
AdditionalHighlightAttributes[ahaIfDefNodeActive] := dlgIfDefNodeActive;
AdditionalHighlightAttributes[ahaIfDefNodeTmpActive] := dlgIfDefNodeTmpActive;
AdditionalHighlightGroupNames[agnIfDef] := dlgAddHiAttrGroupIfDef;
{$ENDIF}
AdditionalHighlightGroupNames[agnDefault] := dlgAddHiAttrGroupDefault;
AdditionalHighlightGroupNames[agnText] := dlgAddHiAttrGroupText;
@ -6236,7 +6221,6 @@ begin
SetMarkupColorByClass(ahaHighlightWord, TSynEditMarkupHighlightAllCaret);
SetMarkupColorByClass(ahaWordGroup, TSynEditMarkupWordGroup);
SetMarkupColorByClass(ahaSpecialVisibleChars, TSynEditMarkupSpecialChar);
{$IFDEF WithSynMarkupIfDef}
if ASynEdit is TIDESynEditor then begin
with TIDESynEditor(ASynEdit) do begin
if AttributeByEnum[ahaIfDefBlockInactive] <> nil
@ -6259,7 +6243,6 @@ begin
else MarkupIfDef.MarkupInfoTempNodeEnabled.Clear;
end;
end;
{$ENDIF}
SetGutterColorByClass(ahaLineNumber, TSynGutterLineNumber);
SetGutterColorByClass(ahaModifiedLine, TSynGutterChanges);
SetGutterColorByClass(ahaCodeFoldingTree, TSynGutterCodeFolding);

View File

@ -246,10 +246,9 @@ type
FTempTopLine: Integer;
FEditPlugin: TSynEditPlugin1; // used to get the LinesInserted and
// LinesDeleted messages
{$IFDEF WithSynMarkupIfDef}
FOnIfdefNodeStateRequest: TSynMarkupIfdefStateRequest;
FLastIfDefNodeScannerStep: integer;
{$ENDIF}
FSyncroLockCount: Integer;
FPageName: string;
@ -312,9 +311,7 @@ type
procedure SetVisible(Value: boolean);
procedure UnbindEditor;
{$IFDEF WithSynMarkupIfDef}
procedure UpdateIfDefNodeStates(Force: Boolean = False);
{$ENDIF}
protected
ErrorMsgs: TStrings;
@ -510,11 +507,9 @@ type
function SourceToDebugLine(aLinePos: Integer): Integer;
function DebugToSourceLine(aLinePos: Integer): Integer;
{$IFDEF WithSynMarkupIfDef}
procedure InvalidateAllIfdefNodes;
procedure SetIfdefNodeState(ALinePos, AstartPos: Integer; AState: TSynMarkupIfdefNodeState);
property OnIfdefNodeStateRequest: TSynMarkupIfdefStateRequest read FOnIfdefNodeStateRequest write FOnIfdefNodeStateRequest;
{$ENDIF}
public
// properties
property CodeBuffer: TCodeBuffer read GetCodeBuffer write SetCodeBuffer;
@ -2344,19 +2339,15 @@ begin
if assigned(SharedEditors[i].FEditPlugin) then
SharedEditors[i].FEditPlugin.Enabled := False;
SynEditor.BeginUpdate;
{$IFDEF WithSynMarkupIfDef}
SynEditor.InvalidateAllIfdefNodes;
{$ENDIF}
FCodeBuffer.AssignTo(SynEditor.Lines, false);
FEditorStampCommitedToCodetools:=(SynEditor.Lines as TSynEditLines).TextChangeStamp;
SynEditor.EndUpdate;
for i := 0 to FSharedEditorList.Count - 1 do begin
if assigned(SharedEditors[i].FEditPlugin) then
SharedEditors[i].FEditPlugin.Enabled := True;
{$IFDEF WithSynMarkupIfDef}
if SharedEditors[i].Visible then
SharedEditors[i].UpdateIfDefNodeStates(True);
{$ENDIF}
end;
end;
for i := 0 to FSharedEditorList.Count - 1 do begin
@ -2480,9 +2471,7 @@ begin
for i := 0 to SharedEditorCount-1 do
SharedEditors[i].BeforeCodeBufferReplace;
{$IFDEF WithSynMarkupIfDef}
SynEditor.InvalidateAllIfdefNodes;
{$ENDIF}
Sender.AssignTo(SynEditor.Lines,false);
for i := 0 to SharedEditorCount-1 do
@ -2490,10 +2479,8 @@ begin
// HasExecutionMarks is shared through synedit => this is only needed once // but HasExecutionMarks must be called on each synedit, so each synedit is notified
for i := 0 to FSharedEditorList.Count - 1 do begin
SharedEditors[i].FillExecutionMarks;
{$IFDEF WithSynMarkupIfDef}
if SharedEditors[i].Visible then
SharedEditors[i].UpdateIfDefNodeStates(True);
{$ENDIF}
end;
end;
if CodeToolsInSync then begin
@ -4262,10 +4249,8 @@ Begin
EditorOpts.GetSynEditSettings(FEditor,SimilarEditor);
SourceNotebook.UpdateActiveEditColors(FEditor);
{$IFDEF WithSynMarkupIfDef}
if Visible then
UpdateIfDefNodeStates(True);
{$ENDIF}
end;
procedure TSourceEditor.ccAddMessage(Texts: String);
@ -5427,7 +5412,6 @@ begin
Result := FEditor.IDEGutterMarks.DebugLineToSourceLine(aLinePos);
end;
{$IFDEF WithSynMarkupIfDef}
procedure TSourceEditor.InvalidateAllIfdefNodes;
begin
FEditor.InvalidateAllIfdefNodes;
@ -5531,7 +5515,6 @@ begin
EditorComponent.EndUpdate;
end;
end;
{$ENDIF}
function TSourceEditor.SharedEditorCount: Integer;
begin
@ -5623,9 +5606,7 @@ begin
OnPlaceBookmark := nil;
OnClearBookmark := nil;
OnChangeUpdating := nil;
{$IFDEF WithSynMarkupIfDef}
OnIfdefNodeStateRequest := nil;
{$ENDIF}
UnregisterMouseActionExecHandler(@EditorHandleMouseAction);
end;
for i := 0 to EditorComponent.PluginCount - 1 do
@ -7218,9 +7199,7 @@ procedure TSourceNotebook.CopyEditor(OldPageIndex, NewWindowIndex,
var
DestWin: TSourceNotebook;
SrcEdit, NewEdit: TSourceEditor;
{$IFDEF WithSynMarkupIfDef}
i: Integer;
{$ENDIF}
begin
if (NewWindowIndex < 0) or (NewWindowIndex >= Manager.SourceWindowCount) then
exit;
@ -7244,11 +7223,9 @@ begin
UpdatePageNames;
UpdateProjectFiles;
DestWin.UpdateProjectFiles(NewEdit);
{$IFDEF WithSynMarkupIfDef}
// Creating a shared edit invalidates the tree in SynMarkup. Force setting it for all editors
for i := 0 to SrcEdit.SharedEditorCount - 1 do
SrcEdit.SharedEditors[i].UpdateIfDefNodeStates(True);
{$ENDIF}
// Update IsVisibleTab; needs UnitEditorInfo created in DestWin.UpdateProjectFiles
if Focus then begin
Manager.ActiveEditor := NewEdit;
@ -8035,9 +8012,7 @@ Begin
TopLine := SrcEdit.EditorComponent.TopLine;
TSynEditMarkupManager(SrcEdit.EditorComponent.MarkupMgr).IncPaintLock;
SrcEdit.BeginUpdate;
{$IFDEF WithSynMarkupIfDef}
SrcEdit.UpdateIfDefNodeStates;
{$ENDIF}
SrcEdit.Visible := True;
SrcEdit.EndUpdate;
// Restore the intial Positions, must be after lock
@ -10106,21 +10081,17 @@ begin
end;
procedure TSourceEditorManager.CodeToolsToSrcEditTimerTimer(Sender: TObject);
{$IFDEF WithSynMarkupIfDef}
var
i: Integer;
SrcEdit: TSourceEditor;
{$ENDIF}
begin
CodeToolsToSrcEditTimer.Enabled:=false;
{$IFDEF WithSynMarkupIfDef}
for i:=0 to SourceEditorCount-1 do begin
SrcEdit:=SourceEditors[i];
if not SrcEdit.EditorComponent.IsVisible then continue;
SrcEdit.UpdateIfDefNodeStates;
end;
{$ENDIF}
end;
procedure TSourceEditorManager.OnWordCompletionGetSource(var Source: TStrings;

View File

@ -208,10 +208,8 @@ type
FSyncroEdit: TSynPluginSyncroEdit;
FTemplateEdit: TSynPluginTemplateEdit;
FMarkupForGutterMark: TSynEditMarkupGutterMark;
{$IFDEF WithSynMarkupIfDef}
FOnIfdefNodeStateRequest: TSynMarkupIfdefStateRequest;
FMarkupIfDef: TSynEditMarkupIfDef;
{$ENDIF}
FTopInfoDisplay: TSourceLazSynTopInfoView;
FSrcSynCaretChangedLock: boolean;
FExtraMarkupLine: TSynEditMarkupSpecialLine;
@ -219,10 +217,8 @@ type
FTopInfoMarkup: TSynSelectedColor;
FUserWordsList: TList;
{$IFDEF WithSynMarkupIfDef}
function DoIfDefNodeStateRequest(Sender: TObject; LinePos,
XStartPos: Integer; CurrentState: TSynMarkupIfdefNodeStateEx): TSynMarkupIfdefNodeState;
{$ENDIF}
function GetHighlightUserWordCount: Integer;
function GetHighlightUserWords(AIndex: Integer): TSourceSynEditMarkupHighlightAllMulti;
function GetIDEGutterMarks: TIDESynGutterMarks;
@ -257,13 +253,11 @@ type
property HighlightUserWordCount: Integer read GetHighlightUserWordCount write SetHighlightUserWordCount;
property HighlightUserWords[AIndex: Integer]: TSourceSynEditMarkupHighlightAllMulti read GetHighlightUserWords;
property MarkupMgr;
{$IFDEF WithSynMarkupIfDef}
function IsIfdefMarkupActive: Boolean;
procedure InvalidateAllIfdefNodes;
procedure SetIfdefNodeState(ALinePos, AstartPos: Integer; AState: TSynMarkupIfdefNodeState);
property OnIfdefNodeStateRequest: TSynMarkupIfdefStateRequest read FOnIfdefNodeStateRequest write FOnIfdefNodeStateRequest;
property MarkupIfDef: TSynEditMarkupIfDef read FMarkupIfDef;
{$ENDIF}
end;
TIDESynHighlighterPasRangeList = class(TSynHighlighterPasRangeList)
@ -1499,7 +1493,6 @@ begin
Result := TIDESynGutterMarks(Gutter.Parts.ByClass[TIDESynGutterMarks, 0]);
end;
{$IFDEF WithSynMarkupIfDef}
function TIDESynEditor.IsIfdefMarkupActive: Boolean;
begin
Result := FMarkupIfDef.RealEnabled;
@ -1525,7 +1518,6 @@ procedure TIDESynEditor.SetIfdefNodeState(ALinePos, AstartPos: Integer;
begin
FMarkupIfDef.SetNodeState(ALinePos, AstartPos, AState);
end;
{$ENDIF}
function TIDESynEditor.GetHighlightUserWordCount: Integer;
begin
@ -1552,18 +1544,14 @@ begin
exit
end;
{$IFDEF WithSynMarkupIfDef}
FMarkupIfDef.Highlighter := nil;
{$ENDIF}
inherited SetHighlighter(Value);
{$IFDEF WithSynMarkupIfDef}
if Highlighter is TSynPasSyn then
FMarkupIfDef.Highlighter := TSynPasSyn(Highlighter)
else
FMarkupIfDef.Highlighter := nil;
{$ENDIF}
if FUserWordsList = nil then
exit;
@ -1585,12 +1573,10 @@ begin
FMarkupForGutterMark := TSynEditMarkupGutterMark.Create(Self, FWordBreaker);
TSynEditMarkupManager(MarkupMgr).AddMarkUp(FMarkupForGutterMark);
{$IFDEF WithSynMarkupIfDef}
FMarkupIfDef := TSynEditMarkupIfDef.Create(Self);
FMarkupIfDef.FoldView := TSynEditFoldedView(FoldedTextBuffer);
//FMarkupIfDef.OnNodeStateRequest := @DoIfDefNodeStateRequest;
TSynEditMarkupManager(MarkupMgr).AddMarkUp(FMarkupIfDef);
{$ENDIF}
FPaintArea := TSourceLazSynSurfaceManager.Create(Self, FPaintArea);
GetCaretObj.AddChangeHandler({$IFDEF FPC}@{$ENDIF}SrcSynCaretChanged);