View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0032930 | Lazarus | IDE | public | 2018-01-02 16:37 | 2018-01-29 22:04 |
Reporter | Vojtech Cihak | Assigned To | Martin Friebe | ||
Priority | normal | Severity | minor | Reproducibility | N/A |
Status | resolved | Resolution | fixed | ||
Product Version | 1.9 (SVN) | ||||
Target Version | 1.8.2 | Fixed in Version | 1.8.2 | ||
Summary | 0032930: Outlines in Source Editor (feature request) | ||||
Description | Currently, colors of Outlines are hardcoded. Request no.1 is to make them configurable. Then, some people will want to use outlines but with standart colors (lets say all black). Request no.2 is to enable multiple pen styles. Outlines of nested blocks can be painted solid-dashed-dotted in repeatig sequece: | ¦ . | ¦ . | ¦ . | ¦ . | ¦ . or style can be assinged separately (case-of dotted, begin-end solid etc.) | ||||
Tags | No tags attached. | ||||
Fixed in Revision | 57182 | ||||
LazTarget | - | ||||
Widgetset | |||||
Attached Files |
|
|
color_options_for_outline_coloring.patch (18,709 bytes)
Index: components/synedit/syneditmarkupfoldcoloring.pas =================================================================== --- components/synedit/syneditmarkupfoldcoloring.pas (revision 57125) +++ components/synedit/syneditmarkupfoldcoloring.pas (working copy) @@ -43,7 +43,7 @@ unit SynEditMarkupFoldColoring; {$mode objfpc}{$H+} -{ $define SynEditMarkupFoldColoringDebug} +{off $define SynEditMarkupFoldColoringDebug} interface @@ -71,10 +71,21 @@ TSynEditMarkupFoldColors = class(TSynEditMarkup) private + fUpdateColors: Boolean; function GetFirstCharacterColumn(index: Integer): Byte; procedure TextBufferChanged(Sender: TObject); private FHighlighter: TSynCustomFoldHighlighter; + FColor1: TSynSelectedColor; + FColor2: TSynSelectedColor; + FColor3: TSynSelectedColor; + FColor4: TSynSelectedColor; + FColor5: TSynSelectedColor; + FColor6: TSynSelectedColor; + FColor7: TSynSelectedColor; + FColor8: TSynSelectedColor; + FColor9: TSynSelectedColor; + FColor10: TSynSelectedColor; FNestList: TLazSynEditNestedFoldsList; // cache @@ -88,7 +99,7 @@ FDefaultGroup: integer; FFoldColorInfos: TMarkupFoldColorInfos; - Colors : array of TColor; + FColors : array of TColor; FPreparedRow: integer; FLastNode: TSynFoldNodeInfo; FLastEnabled: Boolean; @@ -100,6 +111,7 @@ 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 +120,7 @@ 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 +135,16 @@ procedure PrepareMarkupForRow(aRow : Integer); override; property DefaultGroup : integer read FDefaultGroup write SetDefaultGroup; + property Color1: TSynSelectedColor read FColor1; + property Color2: TSynSelectedColor read FColor2; + property Color3: TSynSelectedColor read FColor3; + property Color4: TSynSelectedColor read FColor4; + property Color5: TSynSelectedColor read FColor5; + property Color6: TSynSelectedColor read FColor6; + property Color7: TSynSelectedColor read FColor7; + property Color8: TSynSelectedColor read FColor8; + property Color9: TSynSelectedColor read FColor9; + property Color10: TSynSelectedColor read FColor10; end; implementation @@ -169,6 +192,27 @@ FNestList.FoldFlags := [sfbIncludeDisabled]; FNestList.IncludeOpeningOnLine := True; + FColor1 := TSynSelectedColor.Create; + FColor1.OnChange := @ColorChanged; + FColor2 := TSynSelectedColor.Create; + FColor2.OnChange := @ColorChanged; + FColor3 := TSynSelectedColor.Create; + FColor3.OnChange := @ColorChanged; + FColor4 := TSynSelectedColor.Create; + FColor4.OnChange := @ColorChanged; + FColor5 := TSynSelectedColor.Create; + FColor5.OnChange := @ColorChanged; + FColor6 := TSynSelectedColor.Create; + FColor6.OnChange := @ColorChanged; + FColor7 := TSynSelectedColor.Create; + FColor7.OnChange := @ColorChanged; + FColor8 := TSynSelectedColor.Create; + FColor8.OnChange := @ColorChanged; + FColor9 := TSynSelectedColor.Create; + FColor9.OnChange := @ColorChanged; + FColor10 := TSynSelectedColor.Create; + FColor10.OnChange := @ColorChanged; + MarkupInfo.Foreground := clGreen; MarkupInfo.Background := clNone; MarkupInfo.Style := []; @@ -175,17 +219,32 @@ 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); + FColor1.FrameColor := clRed; + FColor2.FrameColor := $000098F7; //orange + FColor3.FrameColor := $0022CC40; //green + FColor4.FrameColor := $00CCCC00; //cyan + FColor5.FrameColor := $00FF682A; //blue + FColor6.FrameColor := $00CF00C4; //purple + FColor7.FrameColor := clNone; + FColor8.FrameColor := clNone; + FColor9.FrameColor := clNone; + FColor10.FrameColor := clNone; + end; destructor TSynEditMarkupFoldColors.Destroy; begin + FColor1.Free; + FColor2.Free; + FColor3.Free; + FColor4.Free; + FColor5.Free; + FColor6.Free; + FColor7.Free; + FColor8.Free; + FColor9.Free; + FColor10.Free; if Assigned(Lines) then begin Lines.RemoveChangeHandler(senrLineCount, @LinesChanged); Lines.RemoveChangeHandler(senrHighlightChanged, @HighlightChanged); @@ -242,12 +301,12 @@ 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 +402,7 @@ 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; @@ -354,6 +413,7 @@ begin y := ToIdx(aRow); + FNestList.Clear; FNestList.Line := y; NestCount := FNestList.Count; FHighlighter.CurrentLines := Lines; @@ -391,7 +451,7 @@ 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 +511,7 @@ 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 +570,7 @@ 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; @@ -577,6 +637,12 @@ //DebugLn('PrepareMarkupForRow %d', [aRow]); {$ENDIF} if not Assigned(FHighlighter) then exit; + + if fUpdateColors then begin + UpdateColors; + fUpdateColors := False; + end; + FPreparedRow := aRow; FFoldColorInfosCount := 0; //reset needed to prevent using of invalid area @@ -664,6 +730,37 @@ end; end; +procedure TSynEditMarkupFoldColors.UpdateColors; +var + c: Integer; + + procedure AddColor(pColor: TSynSelectedColor); + begin + if pColor.FrameColor = clNone then exit; + fColors[c] := pColor.FrameColor; + inc(c); + end; + +begin + SetLength(fColors, 10); + c := 0; + AddColor(FColor1); + AddColor(FColor2); + AddColor(FColor3); + AddColor(FColor4); + AddColor(FColor5); + AddColor(FColor6); + AddColor(FColor7); + AddColor(FColor8); + AddColor(FColor9); + AddColor(FColor10); + if c = 0 then begin + fColors[c] := $FF; + inc(c); + end; + SetLength(fColors, c); +end; + procedure TSynEditMarkupFoldColors.DoTextChanged(StartLine, EndLine, ACountDiff: Integer); @@ -952,6 +1049,11 @@ InvalidateSynLines(1, Lines.Count); end; +procedure TSynEditMarkupFoldColors.ColorChanged(AMarkup: TObject); +begin + fUpdateColors := True; +end; + end. Index: ide/editoroptions.pp =================================================================== --- ide/editoroptions.pp (revision 57125) +++ ide/editoroptions.pp (working copy) @@ -121,7 +121,8 @@ '', // ahaTopInfoHint '', '', '', // ahaIfDefBlockInactive, ahaIfDefBlockActive, ahaIfDefBlockTmpActive '', '', '', // ahaIfDefNodeInactive, ahaIfDefNodeActive, ahaIfDefNodeTmpActive - '', '', '', '' // ahaIdentComplWindow, ahaIdentComplWindowBorder, ahaIdentComplWindowSelection, ahaIdentComplWindowHighlight + '', '', '', '', // ahaIdentComplWindow, ahaIdentComplWindowBorder, ahaIdentComplWindowSelection, ahaIdentComplWindowHighlight + '', '', '', '', '', '', '', '', '', '' // ahaOutlineColor01..10 ); ahaGroupMap: array[TAdditionalHilightAttribute] of TAhaGroupName = ( @@ -167,7 +168,17 @@ { ahaIdentComplWindow } agnIdentComplWindow, { ahaIdentComplWindowBorder } agnIdentComplWindow, { ahaIdentComplWindowSelection } agnIdentComplWindow, - { ahaIdentComplWindowHighlight } agnIdentComplWindow + { ahaIdentComplWindowHighlight } agnIdentComplWindow, + { ahaOutlineColor1 } agnOutlineColors, + { ahaOutlineColor2 } agnOutlineColors, + { ahaOutlineColor3 } agnOutlineColors, + { ahaOutlineColor4 } agnOutlineColors, + { ahaOutlineColor5 } agnOutlineColors, + { ahaOutlineColor6 } agnOutlineColors, + { ahaOutlineColor7 } agnOutlineColors, + { ahaOutlineColor8 } agnOutlineColors, + { ahaOutlineColor9 } agnOutlineColors, + { ahaOutlineColor10 } agnOutlineColors ); ahaSupportedFeatures: array[TAdditionalHilightAttribute] of TColorSchemeAttributeFeatures = @@ -214,7 +225,17 @@ { ahaIdentComplWindow } [hafBackColor, hafForeColor], { ahaIdentComplWindowBorder } [hafForeColor], { ahaIdentComplWindowSelection } [hafBackColor, hafForeColor], - { ahaIdentComplWindowHighlight } [hafForeColor] + { ahaIdentComplWindowHighlight } [hafForeColor], + { ahaFoldColor1 } [hafFrameColor, hafFrameStyle], + { ahaFoldColor2 } [hafFrameColor, hafFrameStyle], + { ahaFoldColor3 } [hafFrameColor, hafFrameStyle], + { ahaFoldColor4 } [hafFrameColor, hafFrameStyle], + { ahaFoldColor5 } [hafFrameColor, hafFrameStyle], + { ahaFoldColor6 } [hafFrameColor, hafFrameStyle], + { ahaFoldColor7 } [hafFrameColor, hafFrameStyle], + { ahaFoldColor8 } [hafFrameColor, hafFrameStyle], + { ahaFoldColor9 } [hafFrameColor, hafFrameStyle], + { ahaFoldColor10 } [hafFrameColor, hafFrameStyle] ); @@ -2478,6 +2499,18 @@ AdditionalHighlightAttributes[ahaIdentComplWindowHighlight] := dlgAddHiAttrHighlightPrefix; AdditionalHighlightGroupNames[agnIdentComplWindow] := dlgIdentifierCompletion; + AdditionalHighlightAttributes[ahaOutlineColor1] := dlgAddHiAttrOutlineColor1; + AdditionalHighlightAttributes[ahaOutlineColor2] := dlgAddHiAttrOutlineColor2; + AdditionalHighlightAttributes[ahaOutlineColor3] := dlgAddHiAttrOutlineColor3; + AdditionalHighlightAttributes[ahaOutlineColor4] := dlgAddHiAttrOutlineColor4; + AdditionalHighlightAttributes[ahaOutlineColor5] := dlgAddHiAttrOutlineColor5; + AdditionalHighlightAttributes[ahaOutlineColor6] := dlgAddHiAttrOutlineColor6; + AdditionalHighlightAttributes[ahaOutlineColor7] := dlgAddHiAttrOutlineColor7; + AdditionalHighlightAttributes[ahaOutlineColor8] := dlgAddHiAttrOutlineColor8; + AdditionalHighlightAttributes[ahaOutlineColor9] := dlgAddHiAttrOutlineColor9; + AdditionalHighlightAttributes[ahaOutlineColor10] := dlgAddHiAttrOutlineColor10; + AdditionalHighlightGroupNames[agnOutlineColors] := dlgAddHiAttrGroupOutlineColors; + AdditionalHighlightGroupNames[agnDefault] := dlgAddHiAttrGroupDefault; AdditionalHighlightGroupNames[agnText] := dlgAddHiAttrGroupText; AdditionalHighlightGroupNames[agnLine] := dlgAddHiAttrGroupLine; @@ -6541,6 +6574,21 @@ 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(ahaOutlineColor1, TSynEditMarkupFoldColors(aSynEdit.Markup[i]).Color1); + SetMarkupColor(ahaOutlineColor2, TSynEditMarkupFoldColors(aSynEdit.Markup[i]).Color2); + SetMarkupColor(ahaOutlineColor3, TSynEditMarkupFoldColors(aSynEdit.Markup[i]).Color3); + SetMarkupColor(ahaOutlineColor4, TSynEditMarkupFoldColors(aSynEdit.Markup[i]).Color4); + SetMarkupColor(ahaOutlineColor5, TSynEditMarkupFoldColors(aSynEdit.Markup[i]).Color5); + SetMarkupColor(ahaOutlineColor6, TSynEditMarkupFoldColors(aSynEdit.Markup[i]).Color6); + SetMarkupColor(ahaOutlineColor7, TSynEditMarkupFoldColors(aSynEdit.Markup[i]).Color7); + SetMarkupColor(ahaOutlineColor8, TSynEditMarkupFoldColors(aSynEdit.Markup[i]).Color8); + SetMarkupColor(ahaOutlineColor9, TSynEditMarkupFoldColors(aSynEdit.Markup[i]).Color9); + SetMarkupColor(ahaOutlineColor10, TSynEditMarkupFoldColors(aSynEdit.Markup[i]).Color10); + end; finally ASynEdit.EndUpdate; end; @@ -6825,20 +6873,18 @@ i, l: Integer; begin Result := length(s1) - length(s2); - if Result <> 0 then - exit; i := 1; if Result < 0 then l := length(s1) else l := length(s2); - while i < l do begin + while i <= l do begin Result := ord(s1[i]) - ord(s2[i]); if Result <> 0 then exit; inc(i); end; - Result := 0; + Result := length(s1) - length(s2); end; initialization Index: ide/frames/editor_color_options.pas =================================================================== --- ide/frames/editor_color_options.pas (revision 57125) +++ ide/frames/editor_color_options.pas (working copy) @@ -276,6 +276,19 @@ exit; end; + // Special draw oultine color + if Attri.Group = agnOutlineColors then begin + c := Attri.FrameColor; + 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 Index: ide/lazarusidestrconsts.pas =================================================================== --- ide/lazarusidestrconsts.pas (revision 57125) +++ ide/lazarusidestrconsts.pas (working copy) @@ -2104,6 +2104,16 @@ dlgAddHiAttrDefaultWindow = 'Default Text / Window'; dlgAddHiAttrWindowBorder = 'Window border'; dlgAddHiAttrHighlightPrefix = 'Highlight prefix'; + dlgAddHiAttrOutlineColor1 = 'Color 1'; + dlgAddHiAttrOutlineColor2 = 'Color 2'; + dlgAddHiAttrOutlineColor3 = 'Color 3'; + dlgAddHiAttrOutlineColor4 = 'Color 4'; + dlgAddHiAttrOutlineColor5 = 'Color 5'; + dlgAddHiAttrOutlineColor6 = 'Color 6'; + dlgAddHiAttrOutlineColor7 = 'Color 7'; + dlgAddHiAttrOutlineColor8 = 'Color 8'; + dlgAddHiAttrOutlineColor9 = 'Color 9'; + dlgAddHiAttrOutlineColor10 = 'Color 10'; dlgAddHiSpecialVisibleChars = 'Visualized Special Chars'; dlgTopInfoHint = 'Current Class/Proc Hint'; dlgIfDefBlockInactive = 'Inactive $IFDEF code'; @@ -2120,6 +2130,7 @@ dlgAddHiAttrGroupSyncroEdit = 'Syncron Edit'; dlgAddHiAttrGroupTemplateEdit = 'Template Edit'; dlgAddHiAttrGroupIfDef = 'IfDef'; + dlgAddHiAttrGroupOutlineColors = 'Outline Colors'; dlgEditAccessCaptionLockedInView = 'Locked, if text in view'; dlgEditAccessCaptionUnLockedInSoftView = 'Unlocked, if text in centered view'; Index: ide/sourceeditprocs.pas =================================================================== --- ide/sourceeditprocs.pas (revision 57125) +++ ide/sourceeditprocs.pas (working copy) @@ -154,8 +154,8 @@ BGGreen: Integer; BGBlue: Integer; TokenStart: Integer; - BackgroundColor: TColorRef; - ForegroundColor: TColorRef; + BackgroundColor: TColor; + ForegroundColor: TColor; AllowFontColor: Boolean; procedure SetFontColor(NewColor: TColor); @@ -193,7 +193,7 @@ RedDiff:=Abs(FGRed-BGRed); GreenDiff:=Abs(FGGreen-BGGreen); BlueDiff:=Abs(FGBlue -BGBlue); - if RedDiff*RedDiff + GreenDiff*GreenDiff + BlueDiff*BlueDiff<30000 then + if RedDiff*RedDiff + GreenDiff*GreenDiff + BlueDiff*BlueDiff<20000 then begin NewColor:=InvertColor(NewColor); {IncreaseDiff(FGRed,BGRed); Index: ide/sourcemarks.pas =================================================================== --- ide/sourcemarks.pas (revision 57125) +++ ide/sourcemarks.pas (working copy) @@ -64,12 +64,13 @@ ahaTopInfoHint, ahaIfDefBlockInactive, ahaIfDefBlockActive, ahaIfDefBlockTmpActive, ahaIfDefNodeInactive, ahaIfDefNodeActive, ahaIfDefNodeTmpActive, - ahaIdentComplWindow, ahaIdentComplWindowBorder, ahaIdentComplWindowSelection, ahaIdentComplWindowHighlight + ahaIdentComplWindow, ahaIdentComplWindowBorder, ahaIdentComplWindowSelection, ahaIdentComplWindowHighlight, + ahaOutlineColor1, ahaOutlineColor2, ahaOutlineColor3, ahaOutlineColor4, ahaOutlineColor5, ahaOutlineColor6, ahaOutlineColor7, ahaOutlineColor8, ahaOutlineColor9, ahaOutlineColor10 ); TAhaGroupName = ( agnDefault, agnLanguage, agnText, agnLine, agnGutter, agnTemplateMode, agnSyncronMode, - agnIfDef, agnIdentComplWindow + agnIfDef, agnIdentComplWindow, agnOutlineColors ); TSourceEditorBase = class; |
|
Here is a patch for no.1 |
|
I applied patch, so some notes and questions. 1) After apply, all outlines become red. By default all checkboxes (Text-mark) are unchecked. Shouldn't be the default the same as it is now? 2) Items are sorted alphabetically, Color1, Color10, Color2, ... It would be nice to have Color 10 as the last. But Color 0-9 will not work too. Anyway, thanks, it works. |
|
>2) Items are sorted alphabetically, Color1, Color10, Color2, ... It would be nice to have Color 10 as the last. But Color 0-9 will not work too. Sorry, forgot to fix a bug. I'll update the patch. >1) After apply, all outlines become red. By default all checkboxes (Text-mark) are unchecked. Shouldn't be the default the same as it is now? At the moment you have to set the colors once. But this will not work due to the bug i missed to fix. Try it and you'll see. |
|
Strange: The bugfix is already in the patch and the names with one digit contain an additional space in front of it. See patch: =================================================================== --- ide/lazarusidestrconsts.pas (revision 57125) +++ ide/lazarusidestrconsts.pas (working copy) @@ -2104,6 +2104,16 @@ dlgAddHiAttrDefaultWindow = 'Default Text / Window'; dlgAddHiAttrWindowBorder = 'Window border'; dlgAddHiAttrHighlightPrefix = 'Highlight prefix'; + dlgAddHiAttrOutlineColor1 = 'Color 1'; + dlgAddHiAttrOutlineColor2 = 'Color 2'; + dlgAddHiAttrOutlineColor3 = 'Color 3'; + dlgAddHiAttrOutlineColor4 = 'Color 4'; + dlgAddHiAttrOutlineColor5 = 'Color 5'; + dlgAddHiAttrOutlineColor6 = 'Color 6'; + dlgAddHiAttrOutlineColor7 = 'Color 7'; + dlgAddHiAttrOutlineColor8 = 'Color 8'; + dlgAddHiAttrOutlineColor9 = 'Color 9'; + dlgAddHiAttrOutlineColor10 = 'Color 10'; dlgAddHiSpecialVisibleChars = 'Visualized Special Chars'; dlgTopInfoHint = 'Current Class/Proc Hint'; dlgIfDefBlockInactive = 'Inactive $IFDEF code'; Maybe the sorting routine still has a bug, i can't see atm. You can try to delete the function DoCompareText from ide/editoroptions.pp:TQuickStringlist |
|
Sorry, can't reproduce this here. Patch is working fine on a plain trunk version here. What fpc version are you using? I used trunk. |
|
I use 3.0.4. I'll try trunk too. |
|
Even with 3.1.1 is sorted wrongly (1, 10, 2, 3...). But double spaces are there. |
|
Which OS and bitness are you using? |
|
color_options_for_outline_coloring_V2.patch (18,718 bytes)
Index: components/synedit/syneditmarkupfoldcoloring.pas =================================================================== --- components/synedit/syneditmarkupfoldcoloring.pas (revision 57141) +++ components/synedit/syneditmarkupfoldcoloring.pas (working copy) @@ -43,7 +43,7 @@ unit SynEditMarkupFoldColoring; {$mode objfpc}{$H+} -{ $define SynEditMarkupFoldColoringDebug} +{off $define SynEditMarkupFoldColoringDebug} interface @@ -71,10 +71,21 @@ TSynEditMarkupFoldColors = class(TSynEditMarkup) private + fUpdateColors: Boolean; function GetFirstCharacterColumn(index: Integer): Byte; procedure TextBufferChanged(Sender: TObject); private FHighlighter: TSynCustomFoldHighlighter; + FColor1: TSynSelectedColor; + FColor2: TSynSelectedColor; + FColor3: TSynSelectedColor; + FColor4: TSynSelectedColor; + FColor5: TSynSelectedColor; + FColor6: TSynSelectedColor; + FColor7: TSynSelectedColor; + FColor8: TSynSelectedColor; + FColor9: TSynSelectedColor; + FColor10: TSynSelectedColor; FNestList: TLazSynEditNestedFoldsList; // cache @@ -88,7 +99,7 @@ FDefaultGroup: integer; FFoldColorInfos: TMarkupFoldColorInfos; - Colors : array of TColor; + FColors : array of TColor; FPreparedRow: integer; FLastNode: TSynFoldNodeInfo; FLastEnabled: Boolean; @@ -100,6 +111,7 @@ 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 +120,7 @@ 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 +135,16 @@ procedure PrepareMarkupForRow(aRow : Integer); override; property DefaultGroup : integer read FDefaultGroup write SetDefaultGroup; + property Color1: TSynSelectedColor read FColor1; + property Color2: TSynSelectedColor read FColor2; + property Color3: TSynSelectedColor read FColor3; + property Color4: TSynSelectedColor read FColor4; + property Color5: TSynSelectedColor read FColor5; + property Color6: TSynSelectedColor read FColor6; + property Color7: TSynSelectedColor read FColor7; + property Color8: TSynSelectedColor read FColor8; + property Color9: TSynSelectedColor read FColor9; + property Color10: TSynSelectedColor read FColor10; end; implementation @@ -169,6 +192,27 @@ FNestList.FoldFlags := [sfbIncludeDisabled]; FNestList.IncludeOpeningOnLine := True; + FColor1 := TSynSelectedColor.Create; + FColor1.OnChange := @ColorChanged; + FColor2 := TSynSelectedColor.Create; + FColor2.OnChange := @ColorChanged; + FColor3 := TSynSelectedColor.Create; + FColor3.OnChange := @ColorChanged; + FColor4 := TSynSelectedColor.Create; + FColor4.OnChange := @ColorChanged; + FColor5 := TSynSelectedColor.Create; + FColor5.OnChange := @ColorChanged; + FColor6 := TSynSelectedColor.Create; + FColor6.OnChange := @ColorChanged; + FColor7 := TSynSelectedColor.Create; + FColor7.OnChange := @ColorChanged; + FColor8 := TSynSelectedColor.Create; + FColor8.OnChange := @ColorChanged; + FColor9 := TSynSelectedColor.Create; + FColor9.OnChange := @ColorChanged; + FColor10 := TSynSelectedColor.Create; + FColor10.OnChange := @ColorChanged; + MarkupInfo.Foreground := clGreen; MarkupInfo.Background := clNone; MarkupInfo.Style := []; @@ -175,17 +219,32 @@ 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); + FColor1.FrameColor := clRed; + FColor2.FrameColor := $000098F7; //orange + FColor3.FrameColor := $0022CC40; //green + FColor4.FrameColor := $00CCCC00; //cyan + FColor5.FrameColor := $00FF682A; //blue + FColor6.FrameColor := $00CF00C4; //purple + FColor7.FrameColor := clNone; + FColor8.FrameColor := clNone; + FColor9.FrameColor := clNone; + FColor10.FrameColor := clNone; + end; destructor TSynEditMarkupFoldColors.Destroy; begin + FColor1.Free; + FColor2.Free; + FColor3.Free; + FColor4.Free; + FColor5.Free; + FColor6.Free; + FColor7.Free; + FColor8.Free; + FColor9.Free; + FColor10.Free; if Assigned(Lines) then begin Lines.RemoveChangeHandler(senrLineCount, @LinesChanged); Lines.RemoveChangeHandler(senrHighlightChanged, @HighlightChanged); @@ -242,12 +301,12 @@ 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 +402,7 @@ 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; @@ -354,6 +413,7 @@ begin y := ToIdx(aRow); + FNestList.Clear; FNestList.Line := y; NestCount := FNestList.Count; FHighlighter.CurrentLines := Lines; @@ -391,7 +451,7 @@ 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 +511,7 @@ 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 +570,7 @@ 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; @@ -577,6 +637,12 @@ //DebugLn('PrepareMarkupForRow %d', [aRow]); {$ENDIF} if not Assigned(FHighlighter) then exit; + + if fUpdateColors then begin + UpdateColors; + fUpdateColors := False; + end; + FPreparedRow := aRow; FFoldColorInfosCount := 0; //reset needed to prevent using of invalid area @@ -664,6 +730,37 @@ end; end; +procedure TSynEditMarkupFoldColors.UpdateColors; +var + c: Integer; + + procedure AddColor(pColor: TSynSelectedColor); + begin + if pColor.FrameColor = clNone then exit; + fColors[c] := pColor.FrameColor; + inc(c); + end; + +begin + SetLength(fColors, 10); + c := 0; + AddColor(FColor1); + AddColor(FColor2); + AddColor(FColor3); + AddColor(FColor4); + AddColor(FColor5); + AddColor(FColor6); + AddColor(FColor7); + AddColor(FColor8); + AddColor(FColor9); + AddColor(FColor10); + if c = 0 then begin + fColors[c] := $FF; + inc(c); + end; + SetLength(fColors, c); +end; + procedure TSynEditMarkupFoldColors.DoTextChanged(StartLine, EndLine, ACountDiff: Integer); @@ -952,6 +1049,11 @@ InvalidateSynLines(1, Lines.Count); end; +procedure TSynEditMarkupFoldColors.ColorChanged(AMarkup: TObject); +begin + fUpdateColors := True; +end; + end. Index: ide/editoroptions.pp =================================================================== --- ide/editoroptions.pp (revision 57141) +++ ide/editoroptions.pp (working copy) @@ -121,7 +121,8 @@ '', // ahaTopInfoHint '', '', '', // ahaIfDefBlockInactive, ahaIfDefBlockActive, ahaIfDefBlockTmpActive '', '', '', // ahaIfDefNodeInactive, ahaIfDefNodeActive, ahaIfDefNodeTmpActive - '', '', '', '' // ahaIdentComplWindow, ahaIdentComplWindowBorder, ahaIdentComplWindowSelection, ahaIdentComplWindowHighlight + '', '', '', '', // ahaIdentComplWindow, ahaIdentComplWindowBorder, ahaIdentComplWindowSelection, ahaIdentComplWindowHighlight + '', '', '', '', '', '', '', '', '', '' // ahaOutlineColor01..10 ); ahaGroupMap: array[TAdditionalHilightAttribute] of TAhaGroupName = ( @@ -167,7 +168,17 @@ { ahaIdentComplWindow } agnIdentComplWindow, { ahaIdentComplWindowBorder } agnIdentComplWindow, { ahaIdentComplWindowSelection } agnIdentComplWindow, - { ahaIdentComplWindowHighlight } agnIdentComplWindow + { ahaIdentComplWindowHighlight } agnIdentComplWindow, + { ahaOutlineColor01 } agnOutlineColors, + { ahaOutlineColor02 } agnOutlineColors, + { ahaOutlineColor03 } agnOutlineColors, + { ahaOutlineColor04 } agnOutlineColors, + { ahaOutlineColor05 } agnOutlineColors, + { ahaOutlineColor06 } agnOutlineColors, + { ahaOutlineColor07 } agnOutlineColors, + { ahaOutlineColor08 } agnOutlineColors, + { ahaOutlineColor09 } agnOutlineColors, + { ahaOutlineColor10 } agnOutlineColors ); ahaSupportedFeatures: array[TAdditionalHilightAttribute] of TColorSchemeAttributeFeatures = @@ -214,7 +225,17 @@ { ahaIdentComplWindow } [hafBackColor, hafForeColor], { ahaIdentComplWindowBorder } [hafForeColor], { ahaIdentComplWindowSelection } [hafBackColor, hafForeColor], - { ahaIdentComplWindowHighlight } [hafForeColor] + { ahaIdentComplWindowHighlight } [hafForeColor], + { ahaFoldColor01 } [hafFrameColor, hafFrameStyle], + { ahaFoldColor02 } [hafFrameColor, hafFrameStyle], + { ahaFoldColor03 } [hafFrameColor, hafFrameStyle], + { ahaFoldColor04 } [hafFrameColor, hafFrameStyle], + { ahaFoldColor05 } [hafFrameColor, hafFrameStyle], + { ahaFoldColor06 } [hafFrameColor, hafFrameStyle], + { ahaFoldColor07 } [hafFrameColor, hafFrameStyle], + { ahaFoldColor08 } [hafFrameColor, hafFrameStyle], + { ahaFoldColor09 } [hafFrameColor, hafFrameStyle], + { ahaFoldColor10 } [hafFrameColor, hafFrameStyle] ); @@ -2478,6 +2499,18 @@ AdditionalHighlightAttributes[ahaIdentComplWindowHighlight] := dlgAddHiAttrHighlightPrefix; AdditionalHighlightGroupNames[agnIdentComplWindow] := dlgIdentifierCompletion; + AdditionalHighlightAttributes[ahaOutlineColor01] := dlgAddHiAttrOutlineColor1; + AdditionalHighlightAttributes[ahaOutlineColor02] := dlgAddHiAttrOutlineColor2; + AdditionalHighlightAttributes[ahaOutlineColor03] := dlgAddHiAttrOutlineColor3; + AdditionalHighlightAttributes[ahaOutlineColor04] := dlgAddHiAttrOutlineColor4; + AdditionalHighlightAttributes[ahaOutlineColor05] := dlgAddHiAttrOutlineColor5; + AdditionalHighlightAttributes[ahaOutlineColor06] := dlgAddHiAttrOutlineColor6; + AdditionalHighlightAttributes[ahaOutlineColor07] := dlgAddHiAttrOutlineColor7; + AdditionalHighlightAttributes[ahaOutlineColor08] := dlgAddHiAttrOutlineColor8; + AdditionalHighlightAttributes[ahaOutlineColor09] := dlgAddHiAttrOutlineColor9; + AdditionalHighlightAttributes[ahaOutlineColor10] := dlgAddHiAttrOutlineColor10; + AdditionalHighlightGroupNames[agnOutlineColors] := dlgAddHiAttrGroupOutlineColors; + AdditionalHighlightGroupNames[agnDefault] := dlgAddHiAttrGroupDefault; AdditionalHighlightGroupNames[agnText] := dlgAddHiAttrGroupText; AdditionalHighlightGroupNames[agnLine] := dlgAddHiAttrGroupLine; @@ -6541,6 +6574,21 @@ 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(ahaOutlineColor01, TSynEditMarkupFoldColors(aSynEdit.Markup[i]).Color1); + SetMarkupColor(ahaOutlineColor02, TSynEditMarkupFoldColors(aSynEdit.Markup[i]).Color2); + SetMarkupColor(ahaOutlineColor03, TSynEditMarkupFoldColors(aSynEdit.Markup[i]).Color3); + SetMarkupColor(ahaOutlineColor04, TSynEditMarkupFoldColors(aSynEdit.Markup[i]).Color4); + SetMarkupColor(ahaOutlineColor05, TSynEditMarkupFoldColors(aSynEdit.Markup[i]).Color5); + SetMarkupColor(ahaOutlineColor06, TSynEditMarkupFoldColors(aSynEdit.Markup[i]).Color6); + SetMarkupColor(ahaOutlineColor07, TSynEditMarkupFoldColors(aSynEdit.Markup[i]).Color7); + SetMarkupColor(ahaOutlineColor08, TSynEditMarkupFoldColors(aSynEdit.Markup[i]).Color8); + SetMarkupColor(ahaOutlineColor09, TSynEditMarkupFoldColors(aSynEdit.Markup[i]).Color9); + SetMarkupColor(ahaOutlineColor10, TSynEditMarkupFoldColors(aSynEdit.Markup[i]).Color10); + end; finally ASynEdit.EndUpdate; end; @@ -6825,20 +6873,18 @@ i, l: Integer; begin Result := length(s1) - length(s2); - if Result <> 0 then - exit; i := 1; if Result < 0 then l := length(s1) else l := length(s2); - while i < l do begin + while i <= l do begin Result := ord(s1[i]) - ord(s2[i]); if Result <> 0 then exit; inc(i); end; - Result := 0; + Result := length(s1) - length(s2); end; initialization Index: ide/frames/editor_color_options.pas =================================================================== --- ide/frames/editor_color_options.pas (revision 57141) +++ ide/frames/editor_color_options.pas (working copy) @@ -276,6 +276,19 @@ exit; end; + // Special draw oultine color + if Attri.Group = agnOutlineColors then begin + c := Attri.FrameColor; + 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 Index: ide/lazarusidestrconsts.pas =================================================================== --- ide/lazarusidestrconsts.pas (revision 57141) +++ ide/lazarusidestrconsts.pas (working copy) @@ -2104,6 +2104,16 @@ dlgAddHiAttrDefaultWindow = 'Default Text / Window'; dlgAddHiAttrWindowBorder = 'Window border'; dlgAddHiAttrHighlightPrefix = 'Highlight prefix'; + dlgAddHiAttrOutlineColor1 = 'Color 1'; + dlgAddHiAttrOutlineColor2 = 'Color 2'; + dlgAddHiAttrOutlineColor3 = 'Color 3'; + dlgAddHiAttrOutlineColor4 = 'Color 4'; + dlgAddHiAttrOutlineColor5 = 'Color 5'; + dlgAddHiAttrOutlineColor6 = 'Color 6'; + dlgAddHiAttrOutlineColor7 = 'Color 7'; + dlgAddHiAttrOutlineColor8 = 'Color 8'; + dlgAddHiAttrOutlineColor9 = 'Color 9'; + dlgAddHiAttrOutlineColor10 = 'Color 10'; dlgAddHiSpecialVisibleChars = 'Visualized Special Chars'; dlgTopInfoHint = 'Current Class/Proc Hint'; dlgIfDefBlockInactive = 'Inactive $IFDEF code'; @@ -2120,6 +2130,7 @@ dlgAddHiAttrGroupSyncroEdit = 'Syncron Edit'; dlgAddHiAttrGroupTemplateEdit = 'Template Edit'; dlgAddHiAttrGroupIfDef = 'IfDef'; + dlgAddHiAttrGroupOutlineColors = 'Outline Colors'; dlgEditAccessCaptionLockedInView = 'Locked, if text in view'; dlgEditAccessCaptionUnLockedInSoftView = 'Unlocked, if text in centered view'; Index: ide/sourceeditprocs.pas =================================================================== --- ide/sourceeditprocs.pas (revision 57141) +++ ide/sourceeditprocs.pas (working copy) @@ -154,8 +154,8 @@ BGGreen: Integer; BGBlue: Integer; TokenStart: Integer; - BackgroundColor: TColorRef; - ForegroundColor: TColorRef; + BackgroundColor: TColor; + ForegroundColor: TColor; AllowFontColor: Boolean; procedure SetFontColor(NewColor: TColor); @@ -193,7 +193,7 @@ RedDiff:=Abs(FGRed-BGRed); GreenDiff:=Abs(FGGreen-BGGreen); BlueDiff:=Abs(FGBlue -BGBlue); - if RedDiff*RedDiff + GreenDiff*GreenDiff + BlueDiff*BlueDiff<30000 then + if RedDiff*RedDiff + GreenDiff*GreenDiff + BlueDiff*BlueDiff<20000 then begin NewColor:=InvertColor(NewColor); {IncreaseDiff(FGRed,BGRed); Index: ide/sourcemarks.pas =================================================================== --- ide/sourcemarks.pas (revision 57141) +++ ide/sourcemarks.pas (working copy) @@ -64,12 +64,13 @@ ahaTopInfoHint, ahaIfDefBlockInactive, ahaIfDefBlockActive, ahaIfDefBlockTmpActive, ahaIfDefNodeInactive, ahaIfDefNodeActive, ahaIfDefNodeTmpActive, - ahaIdentComplWindow, ahaIdentComplWindowBorder, ahaIdentComplWindowSelection, ahaIdentComplWindowHighlight + ahaIdentComplWindow, ahaIdentComplWindowBorder, ahaIdentComplWindowSelection, ahaIdentComplWindowHighlight, + ahaOutlineColor01, ahaOutlineColor02, ahaOutlineColor03, ahaOutlineColor04, ahaOutlineColor05, ahaOutlineColor06, ahaOutlineColor07, ahaOutlineColor08, ahaOutlineColor09, ahaOutlineColor10 ); TAhaGroupName = ( agnDefault, agnLanguage, agnText, agnLine, agnGutter, agnTemplateMode, agnSyncronMode, - agnIfDef, agnIdentComplWindow + agnIfDef, agnIdentComplWindow, agnOutlineColors ); TSourceEditorBase = class; |
|
I suppose you are using an OS other than Windows 10. I prepared a new patch which uses other names for the attributes (TAdditionalHilightAttribute). So they should be added to the treeview in the right order. You have to edit you editoroptions.xml in the config to keep your colors for outlining. Just add a 0 to the single digit colors: ahaOutlineColor01 ahaOutlineColor02 ahaOutlineColor03 ahaOutlineColor04 ahaOutlineColor05 ahaOutlineColor06 ahaOutlineColor07 ahaOutlineColor08 ahaOutlineColor09 ahaOutlineColor10 |
|
Linux, 64-bits |
|
Okay, then TTreeView behaves differently on Linux concerning sorting of child nodes. The new patch should help then. |
|
I applied patch V2 and updated editoroptions.xml but it remained. See picture. There must be something wrong with alphasorting in treeview. |
|
|
|
Yes, i think so, too! Can you make a new bug report with simple sample project for that issue? |
|
I did: https://bugs.freepascal.org/view.php?id=33064 |
|
Thanks! |
|
color_options_for_outline_coloring_V3.patch (21,044 bytes)
Index: components/synedit/syneditmarkupfoldcoloring.pas =================================================================== --- components/synedit/syneditmarkupfoldcoloring.pas (revision 57176) +++ components/synedit/syneditmarkupfoldcoloring.pas (working copy) @@ -43,7 +43,7 @@ unit SynEditMarkupFoldColoring; {$mode objfpc}{$H+} -{ $define SynEditMarkupFoldColoringDebug} +{off $define SynEditMarkupFoldColoringDebug} interface @@ -71,10 +71,12 @@ 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,7 +90,7 @@ FDefaultGroup: integer; FFoldColorInfos: TMarkupFoldColorInfos; - Colors : array of TColor; + FColors : array of TColor; FPreparedRow: integer; FLastNode: TSynFoldNodeInfo; FLastEnabled: Boolean; @@ -95,11 +97,13 @@ 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 @@ 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 @@ 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 @@ { TSynEditMarkupFoldColors } constructor TSynEditMarkupFoldColors.Create(ASynEdit: TSynEditBase); +var + i: Integer; begin inherited Create(ASynEdit); @@ -169,6 +177,12 @@ 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 := []; @@ -175,17 +189,26 @@ 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); @@ -242,12 +265,12 @@ 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 +366,7 @@ 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; @@ -354,6 +377,7 @@ begin y := ToIdx(aRow); + FNestList.Clear; FNestList.Line := y; NestCount := FNestList.Count; FHighlighter.CurrentLines := Lines; @@ -391,7 +415,7 @@ 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 +475,7 @@ 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 +534,7 @@ 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 +592,12 @@ 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; @@ -577,6 +607,12 @@ //DebugLn('PrepareMarkupForRow %d', [aRow]); {$ENDIF} if not Assigned(FHighlighter) then exit; + + if fUpdateColors then begin + UpdateColors; + fUpdateColors := False; + end; + FPreparedRow := aRow; FFoldColorInfosCount := 0; //reset needed to prevent using of invalid area @@ -664,6 +700,29 @@ 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); +end; + procedure TSynEditMarkupFoldColors.DoTextChanged(StartLine, EndLine, ACountDiff: Integer); @@ -952,6 +1011,11 @@ InvalidateSynLines(1, Lines.Count); end; +procedure TSynEditMarkupFoldColors.ColorChanged(AMarkup: TObject); +begin + fUpdateColors := True; +end; + end. Index: ide/ColorDefault.xml =================================================================== --- ide/ColorDefault.xml (revision 57176) +++ ide/ColorDefault.xml (working copy) @@ -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"> Index: ide/ColorDelphi.xml =================================================================== --- ide/ColorDelphi.xml (revision 57176) +++ ide/ColorDelphi.xml (working copy) @@ -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"> Index: ide/ColorOcean.xml =================================================================== --- ide/ColorOcean.xml (revision 57176) +++ ide/ColorOcean.xml (working copy) @@ -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"> Index: ide/ColorPascalClassic.xml =================================================================== --- ide/ColorPascalClassic.xml (revision 57176) +++ ide/ColorPascalClassic.xml (working copy) @@ -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"> Index: ide/ColorTwilight.xml =================================================================== --- ide/ColorTwilight.xml (revision 57176) +++ ide/ColorTwilight.xml (working copy) @@ -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"> Index: ide/editoroptions.pp =================================================================== --- ide/editoroptions.pp (revision 57176) +++ ide/editoroptions.pp (working copy) @@ -121,7 +121,8 @@ '', // 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 @@ { 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 @@ { 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 @@ 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 @@ 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; Index: ide/editoroptions.res =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: ide/frames/editor_color_options.pas =================================================================== --- ide/frames/editor_color_options.pas (revision 57176) +++ ide/frames/editor_color_options.pas (working copy) @@ -276,6 +276,19 @@ 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 Index: ide/lazarusidestrconsts.pas =================================================================== --- ide/lazarusidestrconsts.pas (revision 57176) +++ ide/lazarusidestrconsts.pas (working copy) @@ -2104,6 +2104,16 @@ 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 @@ dlgAddHiAttrGroupSyncroEdit = 'Syncron Edit'; dlgAddHiAttrGroupTemplateEdit = 'Template Edit'; dlgAddHiAttrGroupIfDef = 'IfDef'; + dlgAddHiAttrGroupOutlineColors = 'Outline Colors'; dlgEditAccessCaptionLockedInView = 'Locked, if text in view'; dlgEditAccessCaptionUnLockedInSoftView = 'Unlocked, if text in centered view'; Index: ide/sourcemarks.pas =================================================================== --- ide/sourcemarks.pas (revision 57176) +++ ide/sourcemarks.pas (working copy) @@ -64,12 +64,13 @@ 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; |
|
|