Merged revision(s) 57182 #bd833943f7 from trunk:

IDE: Config for SynEdit outline colors. Issue #32930
........

git-svn-id: branches/fixes_1_8@57221 -
This commit is contained in:
martin 2018-02-02 17:46:16 +00:00
parent 871435b3f8
commit 2b8ebdfb51
12 changed files with 186 additions and 19 deletions

View File

@ -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.

View File

@ -43,6 +43,12 @@
<ahaGutterSeparator Background="clWhite" Foreground="clGray"/>
<ahaGutter Background="clBtnFace"/>
<ahaRightMargin Foreground="clSilver"/>
<ahaOutlineLevel1Color Foreground="clRed"/>
<ahaOutlineLevel2Color Foreground="39159"/>
<ahaOutlineLevel3Color Foreground="2280512"/>
<ahaOutlineLevel4Color Foreground="13421568"/>
<ahaOutlineLevel5Color Foreground="16738346"/>
<ahaOutlineLevel6Color Foreground="13566148"/>
</SchemeDefault>
</Globals>
<LangObjectPascal Version="6">

View File

@ -43,6 +43,12 @@
<ahaGutterSeparator Background="clWhite" Foreground="clGray"/>
<ahaGutter Background="clBtnFace"/>
<ahaRightMargin Foreground="clSilver"/>
<ahaOutlineLevel1Color Foreground="clRed"/>
<ahaOutlineLevel2Color Foreground="39159"/>
<ahaOutlineLevel3Color Foreground="2280512"/>
<ahaOutlineLevel4Color Foreground="13421568"/>
<ahaOutlineLevel5Color Foreground="16738346"/>
<ahaOutlineLevel6Color Foreground="13566148"/>
</SchemeDelphi>
</Globals>
<LangObjectPascal Version="6">

View File

@ -43,6 +43,12 @@
<ahaGutterSeparator Background="clWhite" Foreground="clGray"/>
<ahaGutter Background="clNavy"/>
<ahaRightMargin Foreground="clSilver"/>
<ahaOutlineLevel1Color Foreground="clRed"/>
<ahaOutlineLevel2Color Foreground="39159"/>
<ahaOutlineLevel3Color Foreground="2280512"/>
<ahaOutlineLevel4Color Foreground="13421568"/>
<ahaOutlineLevel5Color Foreground="16738346"/>
<ahaOutlineLevel6Color Foreground="13566148"/>
</SchemeOcean>
</Globals>
<LangObjectPascal Version="6">

View File

@ -42,6 +42,12 @@
<ahaCodeFoldingTree Foreground="clSilver"/>
<ahaGutterSeparator Background="clWhite" Foreground="clGray"/>
<ahaGutter Background="clNavy"/>
<ahaOutlineLevel1Color Foreground="clRed"/>
<ahaOutlineLevel2Color Foreground="39159"/>
<ahaOutlineLevel3Color Foreground="2280512"/>
<ahaOutlineLevel4Color Foreground="13421568"/>
<ahaOutlineLevel5Color Foreground="16738346"/>
<ahaOutlineLevel6Color Foreground="13566148"/>
</SchemePascal_Classic>
</Globals>
<LangObjectPascal Version="6">

View File

@ -43,6 +43,12 @@
<ahaGutterSeparator Background="clWhite" Foreground="clGray"/>
<ahaGutter Background="clBlack"/>
<ahaRightMargin Foreground="clSilver"/>
<ahaOutlineLevel1Color Foreground="clRed"/>
<ahaOutlineLevel2Color Foreground="39159"/>
<ahaOutlineLevel3Color Foreground="2280512"/>
<ahaOutlineLevel4Color Foreground="13421568"/>
<ahaOutlineLevel5Color Foreground="16738346"/>
<ahaOutlineLevel6Color Foreground="13566148"/>
</SchemeTwilight>
</Globals>
<LangObjectPascal Version="6">

View File

@ -120,7 +120,8 @@ const
'', // ahaSpecialVisibleChars
'', // ahaTopInfoHint
'', '', '', // ahaIfDefBlockInactive, ahaIfDefBlockActive, ahaIfDefBlockTmpActive
'', '', '' // ahaIfDefNodeInactive, ahaIfDefNodeActive, ahaIfDefNodeTmpActive
'', '', '', // ahaIfDefNodeInactive, ahaIfDefNodeActive, ahaIfDefNodeTmpActive
'', '', '', '', '', '', '', '', '', '' // ahaOutlineLevel1Color..ahaOutlineLevel10Color
);
ahaGroupMap: array[TAdditionalHilightAttribute] of TAhaGroupName = (
@ -162,7 +163,17 @@ const
{ ahaIfDefBlockTmpActive } agnIfDef,
{ ahaIfDefNodeInactive } agnIfDef,
{ ahaIfDefNodeActive } agnIfDef,
{ ahaIfDefNodeTmpActive } agnIfDef
{ ahaIfDefNodeTmpActive } agnIfDef,
{ 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 =
(
@ -204,7 +215,17 @@ const
{ 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]
{ ahaIfDefNodeTmpActive } [hafBackColor, hafForeColor, hafFrameColor, hafAlpha, hafPrior, hafFrameStyle, hafFrameEdges, hafStyle, hafStyleMask],
{ ahaFoldLevel1Color } [hafForeColor],
{ ahaFoldLevel2Color } [hafForeColor],
{ ahaFoldLevel3Color } [hafForeColor],
{ ahaFoldLevel4Color } [hafForeColor],
{ ahaFoldLevel5Color } [hafForeColor],
{ ahaFoldLevel6Color } [hafForeColor],
{ ahaFoldLevel7Color } [hafForeColor],
{ ahaFoldLevel8Color } [hafForeColor],
{ ahaFoldLevel9Color } [hafForeColor],
{ ahaFoldLevel10Color } [hafForeColor]
);
@ -2462,6 +2483,18 @@ begin
AdditionalHighlightAttributes[ahaIfDefNodeTmpActive] := dlgIfDefNodeTmpActive;
AdditionalHighlightGroupNames[agnIfDef] := dlgAddHiAttrGroupIfDef;
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;
@ -6486,6 +6519,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;

Binary file not shown.

View File

@ -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

View File

@ -449,6 +449,7 @@
<Unit61>
<Filename Value="debugmanager.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="DebugManager"/>
</Unit61>
<Unit62>
<Filename Value="progresswnd.pas"/>
@ -758,6 +759,7 @@
<Unit115>
<Filename Value="sourcemarks.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="SourceMarks"/>
</Unit115>
<Unit116>
<Filename Value="checklfmdlg.pas"/>

View File

@ -2089,6 +2089,16 @@ resourcestring
dlgAddHiAttrSyncroEditOther = 'Other Cells';
dlgAddHiAttrSyncroEditArea = 'Selected Area';
dlgAddHiAttrGutterSeparator = 'Gutter Separator';
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';
@ -2105,6 +2115,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';

View File

@ -63,12 +63,13 @@ type
ahaGutter, ahaRightMargin, ahaSpecialVisibleChars,
ahaTopInfoHint,
ahaIfDefBlockInactive, ahaIfDefBlockActive, ahaIfDefBlockTmpActive,
ahaIfDefNodeInactive, ahaIfDefNodeActive, ahaIfDefNodeTmpActive
ahaIfDefNodeInactive, ahaIfDefNodeActive, ahaIfDefNodeTmpActive,
ahaOutlineLevel1Color, ahaOutlineLevel2Color, ahaOutlineLevel3Color, ahaOutlineLevel4Color, ahaOutlineLevel5Color, ahaOutlineLevel6Color, ahaOutlineLevel7Color, ahaOutlineLevel8Color, ahaOutlineLevel9Color, ahaOutlineLevel10Color
);
TAhaGroupName = (
agnDefault, agnLanguage, agnText, agnLine, agnGutter, agnTemplateMode, agnSyncronMode,
agnIfDef
agnIfDef, agnOutlineColors
);
TSourceEditorBase = class;