Commit bd833943 authored by Martin's avatar Martin
Browse files

IDE: Config for SynEdit outline colors. Issue #32930

git-svn-id: trunk@57182 -
parent d66a7bc3
......@@ -71,10 +71,12 @@ type
TSynEditMarkupFoldColors = class(TSynEditMarkup)
private
fUpdateColors: Boolean;
function GetFirstCharacterColumn(index: Integer): Byte;
procedure TextBufferChanged(Sender: TObject);
private
FHighlighter: TSynCustomFoldHighlighter;
FMarkupColors: array of TSynSelectedColor;
FNestList: TLazSynEditNestedFoldsList;
// cache
......@@ -88,18 +90,20 @@ type
FDefaultGroup: integer;
FFoldColorInfos: TMarkupFoldColorInfos;
Colors : array of TColor;
FColors : array of TColor;
FPreparedRow: integer;
FLastNode: TSynFoldNodeInfo;
FLastEnabled: Boolean;
procedure DoMarkupParentFoldAtRow(aRow: Integer);
procedure DoMarkupParentCloseFoldAtRow(aRow: Integer);
function GetColor(pIndex: Integer): TSynSelectedColor;
procedure SetDefaultGroup(AValue: integer);
procedure SetCacheCount(pNewCount: Integer);
procedure SetFoldColorInfosCount(pNewCount: Integer);
procedure InitCache;
procedure ClearCache;
procedure UpdateColors;
property FirstCharacterColumn[index: Integer]: Byte read GetFirstCharacterColumn;
protected
// Notifications about Changes to the text
......@@ -108,6 +112,7 @@ type
procedure LinesChanged(Sender: TSynEditStrings; aIndex, aCount: Integer);
procedure HighlightChanged(Sender: TSynEditStrings; aIndex, aCount: Integer);
procedure DoEnabledChanged(Sender: TObject); override;
procedure ColorChanged(AMarkup: TObject);
public
constructor Create(ASynEdit : TSynEditBase);
destructor Destroy; override;
......@@ -122,6 +127,7 @@ type
procedure PrepareMarkupForRow(aRow : Integer); override;
property DefaultGroup : integer read FDefaultGroup write SetDefaultGroup;
property Color[pIndex: Integer]: TSynSelectedColor read GetColor;
end;
implementation
......@@ -147,6 +153,8 @@ end;
{ TSynEditMarkupFoldColors }
constructor TSynEditMarkupFoldColors.Create(ASynEdit: TSynEditBase);
var
i: Integer;
begin
inherited Create(ASynEdit);
......@@ -169,23 +177,38 @@ begin
FNestList.FoldFlags := [sfbIncludeDisabled];
FNestList.IncludeOpeningOnLine := True;
SetLength(FMarkupColors, 10);
for i := 0 to length(FMarkupColors) - 1 do begin
FMarkupColors[i] := TSynSelectedColor.Create;
FMarkupColors[i].OnChange := @ColorChanged;
end;
MarkupInfo.Foreground := clGreen;
MarkupInfo.Background := clNone;
MarkupInfo.Style := [];
MarkupInfo.StyleMask := [];
MarkupInfo.FrameEdges:= sfeLeft;
SetLength(Colors, 6);
Colors[0] := clRed;
Colors[1] := $000098F7; //orange
Colors[2] := $0022CC40; //green
Colors[3] := $00CCCC00; //cyan
Colors[4] := $00FF682A; //blue
Colors[5] := $00CF00C4; //purple
SetLength(FColors, 6);
FMarkupColors[0].Foreground := clRed;
FMarkupColors[1].Foreground := $000098F7; //orange
FMarkupColors[2].Foreground := $0022CC40; //green
FMarkupColors[3].Foreground := $00CCCC00; //cyan
FMarkupColors[4].Foreground := $00FF682A; //blue
FMarkupColors[5].Foreground := $00CF00C4; //purple
FMarkupColors[6].Foreground := clNone;
FMarkupColors[7].Foreground := clNone;
FMarkupColors[8].Foreground := clNone;
FMarkupColors[9].Foreground := clNone;
end;
destructor TSynEditMarkupFoldColors.Destroy;
var
i: Integer;
begin
for i := 0 to Length(FMarkupColors) - 1 do
FMarkupColors[i].Free;
if Assigned(Lines) then begin
Lines.RemoveChangeHandler(senrLineCount, @LinesChanged);
Lines.RemoveChangeHandler(senrHighlightChanged, @HighlightChanged);
......@@ -204,6 +227,8 @@ begin
if not Assigned(FHighlighter) then
exit;
FNestList.Clear; // for next markup start
if fUpdateColors then
UpdateColors;
end;
function TSynEditMarkupFoldColors.GetMarkupAttributeAtRowCol(
......@@ -242,12 +267,12 @@ begin
x2both := max(x2both, x2);
MarkupInfo.SetFrameBoundsLog(x, x2both);
if Border then begin
MarkupInfo.FrameColor:= Colors[ColorIdx];
MarkupInfo.FrameColor:= FColors[ColorIdx];
MarkupInfo.FrameEdges:= sfeLeft;
end else begin
MarkupInfo.FrameColor:= clNone;
MarkupInfo.FrameEdges:= sfeNone;
MarkupInfo.Foreground := Colors[ColorIdx];
MarkupInfo.Foreground := FColors[ColorIdx];
end;
end;
end;
......@@ -343,7 +368,7 @@ var
if not Border and (sfaOutlineNoColor in ANode.FoldAction) then
Ignore := True;
Level := lvl;
ColorIdx := Max(0, lvl) mod (length(Colors));
ColorIdx := Max(0, lvl) mod (length(FColors));
end;
end;
......@@ -391,7 +416,7 @@ begin
if sfaOutlineKeepLevel in FFoldColorInfos[FFoldColorInfosCount - 2].SrcNode.FoldAction then begin
lvl := FFoldColorInfos[FFoldColorInfosCount - 2].Level;
FFoldColorInfos[FFoldColorInfosCount - 1].Level := lvl;
FFoldColorInfos[FFoldColorInfosCount - 1].ColorIdx := Max(0, lvl) mod (length(Colors));
FFoldColorInfos[FFoldColorInfosCount - 1].ColorIdx := Max(0, lvl) mod (length(FColors));
end;
end;
......@@ -451,7 +476,7 @@ var
X2 := ANode.LogXEnd + 1;
Level := lvl;
if not (sfaOutlineNocolor in ANode.FoldAction) then
ColorIdx := Max(0, lvl) mod (length(Colors))
ColorIdx := Max(0, lvl) mod (length(FColors))
else
ColorIdx := -1;
end;
......@@ -510,7 +535,7 @@ begin
or (sfaOutlineKeepLevel in FFoldColorInfos[FFoldColorInfosCount - 2].SrcNode.FoldAction) then begin
lvl := FFoldColorInfos[FFoldColorInfosCount - 2].Level;
FFoldColorInfos[FFoldColorInfosCount - 1].Level := lvl;
FFoldColorInfos[FFoldColorInfosCount - 1].ColorIdx := Max(0, lvl) mod (length(Colors));
FFoldColorInfos[FFoldColorInfosCount - 1].ColorIdx := Max(0, lvl) mod (length(FColors));
end;
end;
......@@ -568,6 +593,12 @@ begin
end;
end;
function TSynEditMarkupFoldColors.GetColor(pIndex: Integer): TSynSelectedColor;
begin
Assert((pIndex >= 0) and (pIndex < Length(FMarkupColors)), 'Index out of range');
Result := FMarkupColors[pIndex];
end;
procedure TSynEditMarkupFoldColors.PrepareMarkupForRow(aRow: Integer);
var
i, LastX, j: Integer;
......@@ -664,6 +695,30 @@ begin
end;
end;
procedure TSynEditMarkupFoldColors.UpdateColors;
var
c, i: Integer;
procedure AddColor(pColor: TSynSelectedColor);
begin
if pColor.Foreground = clNone then exit;
fColors[c] := pColor.Foreground;
inc(c);
end;
begin
SetLength(fColors, Length(FMarkupColors));
c := 0;
for i := 0 to length(FMarkupColors) -1 do
AddColor(FMarkupColors[i]);
if c = 0 then begin
fColors[c] := $0000FF; // default red
inc(c);
end;
SetLength(fColors, c);
fUpdateColors := False;
end;
procedure TSynEditMarkupFoldColors.DoTextChanged(StartLine, EndLine,
ACountDiff: Integer);
......@@ -952,6 +1007,13 @@ begin
InvalidateSynLines(1, Lines.Count);
end;
procedure TSynEditMarkupFoldColors.ColorChanged(AMarkup: TObject);
begin
fUpdateColors := True;
if Assigned(Lines) then
InvalidateSynLines(1, Lines.Count);
end;
end.
......@@ -44,6 +44,12 @@
<ahaGutter Background="clBtnFace"/>
<ahaRightMargin Foreground="clSilver"/>
<ahaIdentComplWindowHighlight Foreground="187"/>
<ahaOutlineLevel1Color Foreground="clRed"/>
<ahaOutlineLevel2Color Foreground="39159"/>
<ahaOutlineLevel3Color Foreground="2280512"/>
<ahaOutlineLevel4Color Foreground="13421568"/>
<ahaOutlineLevel5Color Foreground="16738346"/>
<ahaOutlineLevel6Color Foreground="13566148"/>
</SchemeDefault>
</Globals>
<LangObjectPascal Version="6">
......
......@@ -44,6 +44,12 @@
<ahaGutter Background="clBtnFace"/>
<ahaRightMargin Foreground="clSilver"/>
<ahaIdentComplWindowHighlight Foreground="191"/>
<ahaOutlineLevel1Color Foreground="clRed"/>
<ahaOutlineLevel2Color Foreground="39159"/>
<ahaOutlineLevel3Color Foreground="2280512"/>
<ahaOutlineLevel4Color Foreground="13421568"/>
<ahaOutlineLevel5Color Foreground="16738346"/>
<ahaOutlineLevel6Color Foreground="13566148"/>
</SchemeDelphi>
</Globals>
<LangObjectPascal Version="6">
......
......@@ -45,6 +45,12 @@
<ahaRightMargin Foreground="clSilver"/>
<ahaIdentComplWindowHighlight Foreground="clAqua"/>
<ahaIdentComplWindow Background="8388649"/>
<ahaOutlineLevel1Color Foreground="clRed"/>
<ahaOutlineLevel2Color Foreground="39159"/>
<ahaOutlineLevel3Color Foreground="2280512"/>
<ahaOutlineLevel4Color Foreground="13421568"/>
<ahaOutlineLevel5Color Foreground="16738346"/>
<ahaOutlineLevel6Color Foreground="13566148"/>
</SchemeOcean>
</Globals>
<LangObjectPascal Version="6">
......
......@@ -44,6 +44,12 @@
<ahaGutter Background="clNavy"/>
<ahaIdentComplWindowHighlight Foreground="clAqua"/>
<ahaIdentComplWindow Background="10420276"/>
<ahaOutlineLevel1Color Foreground="clRed"/>
<ahaOutlineLevel2Color Foreground="39159"/>
<ahaOutlineLevel3Color Foreground="2280512"/>
<ahaOutlineLevel4Color Foreground="13421568"/>
<ahaOutlineLevel5Color Foreground="16738346"/>
<ahaOutlineLevel6Color Foreground="13566148"/>
</SchemePascal_Classic>
</Globals>
<LangObjectPascal Version="6">
......
......@@ -46,6 +46,12 @@
<ahaIdentComplWindow Background="3552822"/>
<ahaIdentComplWindowBorder Foreground="7039851"/>
<ahaIdentComplWindowHighlight Foreground="clLime"/>
<ahaOutlineLevel1Color Foreground="clRed"/>
<ahaOutlineLevel2Color Foreground="39159"/>
<ahaOutlineLevel3Color Foreground="2280512"/>
<ahaOutlineLevel4Color Foreground="13421568"/>
<ahaOutlineLevel5Color Foreground="16738346"/>
<ahaOutlineLevel6Color Foreground="13566148"/>
</SchemeTwilight>
</Globals>
<LangObjectPascal Version="6">
......
......@@ -121,7 +121,8 @@ const
'', // ahaTopInfoHint
'', '', '', // ahaIfDefBlockInactive, ahaIfDefBlockActive, ahaIfDefBlockTmpActive
'', '', '', // ahaIfDefNodeInactive, ahaIfDefNodeActive, ahaIfDefNodeTmpActive
'', '', '', '' // ahaIdentComplWindow, ahaIdentComplWindowBorder, ahaIdentComplWindowSelection, ahaIdentComplWindowHighlight
'', '', '', '', // ahaIdentComplWindow, ahaIdentComplWindowBorder, ahaIdentComplWindowSelection, ahaIdentComplWindowHighlight
'', '', '', '', '', '', '', '', '', '' // ahaOutlineLevel1Color..ahaOutlineLevel10Color
);
ahaGroupMap: array[TAdditionalHilightAttribute] of TAhaGroupName = (
......@@ -167,7 +168,17 @@ const
{ ahaIdentComplWindow } agnIdentComplWindow,
{ ahaIdentComplWindowBorder } agnIdentComplWindow,
{ ahaIdentComplWindowSelection } agnIdentComplWindow,
{ ahaIdentComplWindowHighlight } agnIdentComplWindow
{ ahaIdentComplWindowHighlight } agnIdentComplWindow,
{ ahaOutlineLevel1Color } agnOutlineColors,
{ ahaOutlineLevel2Color } agnOutlineColors,
{ ahaOutlineLevel3Color } agnOutlineColors,
{ ahaOutlineLevel4Color } agnOutlineColors,
{ ahaOutlineLevel5Color } agnOutlineColors,
{ ahaOutlineLevel6Color } agnOutlineColors,
{ ahaOutlineLevel7Color } agnOutlineColors,
{ ahaOutlineLevel8Color } agnOutlineColors,
{ ahaOutlineLevel9Color } agnOutlineColors,
{ ahaOutlineLevel10Color } agnOutlineColors
);
ahaSupportedFeatures: array[TAdditionalHilightAttribute] of TColorSchemeAttributeFeatures =
......@@ -214,7 +225,17 @@ const
{ ahaIdentComplWindow } [hafBackColor, hafForeColor],
{ ahaIdentComplWindowBorder } [hafForeColor],
{ ahaIdentComplWindowSelection } [hafBackColor, hafForeColor],
{ ahaIdentComplWindowHighlight } [hafForeColor]
{ ahaIdentComplWindowHighlight } [hafForeColor],
{ ahaFoldLevel1Color } [hafForeColor],
{ ahaFoldLevel2Color } [hafForeColor],
{ ahaFoldLevel3Color } [hafForeColor],
{ ahaFoldLevel4Color } [hafForeColor],
{ ahaFoldLevel5Color } [hafForeColor],
{ ahaFoldLevel6Color } [hafForeColor],
{ ahaFoldLevel7Color } [hafForeColor],
{ ahaFoldLevel8Color } [hafForeColor],
{ ahaFoldLevel9Color } [hafForeColor],
{ ahaFoldLevel10Color } [hafForeColor]
);
......@@ -2478,6 +2499,18 @@ begin
AdditionalHighlightAttributes[ahaIdentComplWindowHighlight] := dlgAddHiAttrHighlightPrefix;
AdditionalHighlightGroupNames[agnIdentComplWindow] := dlgIdentifierCompletion;
AdditionalHighlightAttributes[ahaOutlineLevel1Color] := dlgAddHiAttrOutlineLevel1Color;
AdditionalHighlightAttributes[ahaOutlineLevel2Color] := dlgAddHiAttrOutlineLevel2Color;
AdditionalHighlightAttributes[ahaOutlineLevel3Color] := dlgAddHiAttrOutlineLevel3Color;
AdditionalHighlightAttributes[ahaOutlineLevel4Color] := dlgAddHiAttrOutlineLevel4Color;
AdditionalHighlightAttributes[ahaOutlineLevel5Color] := dlgAddHiAttrOutlineLevel5Color;
AdditionalHighlightAttributes[ahaOutlineLevel6Color] := dlgAddHiAttrOutlineLevel6Color;
AdditionalHighlightAttributes[ahaOutlineLevel7Color] := dlgAddHiAttrOutlineLevel7Color;
AdditionalHighlightAttributes[ahaOutlineLevel8Color] := dlgAddHiAttrOutlineLevel8Color;
AdditionalHighlightAttributes[ahaOutlineLevel9Color] := dlgAddHiAttrOutlineLevel9Color;
AdditionalHighlightAttributes[ahaOutlineLevel10Color] := dlgAddHiAttrOutlineLevel10Color;
AdditionalHighlightGroupNames[agnOutlineColors] := dlgAddHiAttrGroupOutlineColors;
AdditionalHighlightGroupNames[agnDefault] := dlgAddHiAttrGroupDefault;
AdditionalHighlightGroupNames[agnText] := dlgAddHiAttrGroupText;
AdditionalHighlightGroupNames[agnLine] := dlgAddHiAttrGroupLine;
......@@ -6541,6 +6574,21 @@ begin
SetMarkupColor(ahaSyncroEditSync, TSynPluginSyncroEdit(aSynEdit.Plugin[i]).MarkupInfoSync);
SetMarkupColor(ahaSyncroEditArea, TSynPluginSyncroEdit(aSynEdit.Plugin[i]).MarkupInfoArea);
end;
i := aSynEdit.MarkupCount - 1;
while (i >= 0) and not(aSynEdit.Markup[i] is TSynEditMarkupFoldColors) do
dec(i);
if i >= 0 then begin
SetMarkupColor(ahaOutlineLevel1Color, TSynEditMarkupFoldColors(aSynEdit.Markup[i]).Color[0]);
SetMarkupColor(ahaOutlineLevel2Color, TSynEditMarkupFoldColors(aSynEdit.Markup[i]).Color[1]);
SetMarkupColor(ahaOutlineLevel3Color, TSynEditMarkupFoldColors(aSynEdit.Markup[i]).Color[2]);
SetMarkupColor(ahaOutlineLevel4Color, TSynEditMarkupFoldColors(aSynEdit.Markup[i]).Color[3]);
SetMarkupColor(ahaOutlineLevel5Color, TSynEditMarkupFoldColors(aSynEdit.Markup[i]).Color[4]);
SetMarkupColor(ahaOutlineLevel6Color, TSynEditMarkupFoldColors(aSynEdit.Markup[i]).Color[5]);
SetMarkupColor(ahaOutlineLevel7Color, TSynEditMarkupFoldColors(aSynEdit.Markup[i]).Color[6]);
SetMarkupColor(ahaOutlineLevel8Color, TSynEditMarkupFoldColors(aSynEdit.Markup[i]).Color[7]);
SetMarkupColor(ahaOutlineLevel9Color, TSynEditMarkupFoldColors(aSynEdit.Markup[i]).Color[8]);
SetMarkupColor(ahaOutlineLevel10Color, TSynEditMarkupFoldColors(aSynEdit.Markup[i]).Color[9]);
end;
finally
ASynEdit.EndUpdate;
end;
......
No preview for this file type
......@@ -276,6 +276,19 @@ begin
exit;
end;
// Special draw oultine color
if Attri.Group = agnOutlineColors then begin
c := Attri.Foreground;
if c <> clNone then begin
TheTree.Canvas.Pen.Color := c;
TheTree.Canvas.MoveTo(NodeRect.Left+(FullAbcWidth div 2), NodeRect.Top+2);
TheTree.Canvas.LineTo(NodeRect.Left+(FullAbcWidth div 2), NodeRect.Bottom-2);
TheTree.Canvas.MoveTo(NodeRect.Left+(FullAbcWidth div 2)+1, NodeRect.Top+2);
TheTree.Canvas.LineTo(NodeRect.Left+(FullAbcWidth div 2)+1, NodeRect.Bottom-2);
end;
exit;
end;
// Draw preview Frame
TheTree.Canvas.Pen.Color := Attri.FrameColor;
if (hafFrameColor in Attri.Features) and (AttriIdx <> ord(ahaCodeFoldingTree)) and
......
......@@ -2104,6 +2104,16 @@ resourcestring
dlgAddHiAttrDefaultWindow = 'Default Text / Window';
dlgAddHiAttrWindowBorder = 'Window border';
dlgAddHiAttrHighlightPrefix = 'Highlight prefix';
dlgAddHiAttrOutlineLevel1Color = 'Level 1';
dlgAddHiAttrOutlineLevel2Color = 'Level 2';
dlgAddHiAttrOutlineLevel3Color = 'Level 3';
dlgAddHiAttrOutlineLevel4Color = 'Level 4';
dlgAddHiAttrOutlineLevel5Color = 'Level 5';
dlgAddHiAttrOutlineLevel6Color = 'Level 6';
dlgAddHiAttrOutlineLevel7Color = 'Level 7';
dlgAddHiAttrOutlineLevel8Color = 'Level 8';
dlgAddHiAttrOutlineLevel9Color = 'Level 9';
dlgAddHiAttrOutlineLevel10Color = 'Level 10';
dlgAddHiSpecialVisibleChars = 'Visualized Special Chars';
dlgTopInfoHint = 'Current Class/Proc Hint';
dlgIfDefBlockInactive = 'Inactive $IFDEF code';
......@@ -2120,6 +2130,7 @@ resourcestring
dlgAddHiAttrGroupSyncroEdit = 'Syncron Edit';
dlgAddHiAttrGroupTemplateEdit = 'Template Edit';
dlgAddHiAttrGroupIfDef = 'IfDef';
dlgAddHiAttrGroupOutlineColors = 'Outline Colors';
dlgEditAccessCaptionLockedInView = 'Locked, if text in view';
dlgEditAccessCaptionUnLockedInSoftView = 'Unlocked, if text in centered view';
......
......@@ -64,12 +64,13 @@ type
ahaTopInfoHint,
ahaIfDefBlockInactive, ahaIfDefBlockActive, ahaIfDefBlockTmpActive,
ahaIfDefNodeInactive, ahaIfDefNodeActive, ahaIfDefNodeTmpActive,
ahaIdentComplWindow, ahaIdentComplWindowBorder, ahaIdentComplWindowSelection, ahaIdentComplWindowHighlight
ahaIdentComplWindow, ahaIdentComplWindowBorder, ahaIdentComplWindowSelection, ahaIdentComplWindowHighlight,
ahaOutlineLevel1Color, ahaOutlineLevel2Color, ahaOutlineLevel3Color, ahaOutlineLevel4Color, ahaOutlineLevel5Color, ahaOutlineLevel6Color, ahaOutlineLevel7Color, ahaOutlineLevel8Color, ahaOutlineLevel9Color, ahaOutlineLevel10Color
);
TAhaGroupName = (
agnDefault, agnLanguage, agnText, agnLine, agnGutter, agnTemplateMode, agnSyncronMode,
agnIfDef, agnIdentComplWindow
agnIfDef, agnIdentComplWindow, agnOutlineColors
);
TSourceEditorBase = class;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment