add highlighter attribute for function calls and definitions

This commit is contained in:
Basile Burg 2020-07-05 19:18:04 +02:00
parent 87c8ca3cd1
commit f3df449a9d
3 changed files with 24 additions and 2 deletions

View File

@ -2,7 +2,8 @@
## Enhancements
- GDB commander: added the _maxCallStackDepth_ option. It prevents slowdowns, especially after an automatic break caused by a stack overflow.
- D highlighter: added option to highlights function calls and function definition. Use options window: _Editor/HighlighterDlang/calls_ to test it as by default the same properties as identifiers are used.
- GDB commander: added the _maxCallStackDepth_ option. It prevents slowdowns, especially after an automatic break got SEGFAULT caused by a stack overflow.
## Bugs fixed

View File

@ -12,7 +12,7 @@ uses
type
TTokenKind = (tkCommt, tkIdent, tkKeywd, tkStrng, tkBlank, tkSymbl, tkNumbr,
tkDDocs, tkSpecK, tkError, tkAsmbl, tkAttri, tkLost, tkTypes);
tkDDocs, tkSpecK, tkError, tkAsmbl, tkAttri, tkLost, tkTypes, tkCall);
TRangeKind = (rkString1, rkString2, rkBlockCom1, rkBlockCom2,
rkBlockDoc1, rkBlockDoc2, rkAsm, rkAttrib,
@ -63,6 +63,7 @@ type
fAttriAttrib: TSynHighlighterAttributes;
fLost_Attrib: TSynHighlighterAttributes;
fTypesAttrib: TSynHighlighterAttributes;
fFCallAttrib: TSynHighlighterAttributes;
fLineBuf: string;
fTokStart, fTokStop: Integer;
fTokKind: TTokenKind;
@ -84,6 +85,7 @@ type
procedure setErrorAttrib(value: TSynHighlighterAttributes);
procedure setAttriAttrib(value: TSynHighlighterAttributes);
procedure setTypesAttrib(value: TSynHighlighterAttributes);
procedure setFCallAttrib(value: TSynHighlighterAttributes);
procedure doAttribChange(sender: TObject);
procedure doChanged;
protected
@ -105,6 +107,7 @@ type
property errors: TSynHighlighterAttributes read fErrorAttrib write setErrorAttrib stored true;
property attributes: TSynHighlighterAttributes read fAttriAttrib write setAttriAttrib stored true;
property types: TSynHighlighterAttributes read fTypesAttrib write setTypesAttrib stored true;
property calls: TSynHighlighterAttributes read fFCallAttrib write setFCallAttrib stored true;
property DefaultFilter stored false;
property enabled stored false;
public
@ -217,6 +220,7 @@ begin
fErrorAttrib := TSynHighlighterAttributes.Create('Error','Error');
fAttriAttrib := TSynHighlighterAttributes.Create('Attri','Attri');
fTypesAttrib := TSynHighlighterAttributes.Create('Types','Types');
fFCallAttrib := TSynHighlighterAttributes.Create('Calls','Calls');
fLost_Attrib := TSynHighlighterAttributes.Create('Lost','Lost');
fNumbrAttrib.Foreground := $000079F2;
@ -231,6 +235,7 @@ begin
fLost_Attrib.Foreground := clLime;
fDDocsAttrib.Foreground := clTeal;
fTypesAttrib.Foreground := clBlack;
fFCallAttrib.Foreground := clBlack;
fLost_Attrib.Background := clBlack;
@ -260,6 +265,7 @@ begin
AddAttribute(fErrorAttrib);
AddAttribute(fAttriAttrib);
AddAttribute(fTypesAttrib);
AddAttribute(fFCallAttrib);
fAttribLut[TTokenKind.tkident] := fIdentAttrib;
fAttribLut[TTokenKind.tkBlank] := fWhiteAttrib;
@ -275,6 +281,7 @@ begin
fAttribLut[TTokenKind.tkAttri] := fAttriAttrib;
fAttribLut[TTokenKind.tkTypes] := fTypesAttrib;
fAttribLut[TTokenKind.tkLost] := fLost_Attrib;
fAttribLut[TTokenKind.tkCall] := fFCallAttrib;
SetAttributesOnChange(@doAttribChange);
fTokStop := 1;
@ -395,6 +402,11 @@ begin
fTypesAttrib.Assign(value);
end;
procedure TSynD2Syn.setFCallAttrib(value: TSynHighlighterAttributes);
begin
fFCallAttrib.Assign(value);
end;
procedure TSynD2Syn.setLine(const NewValue: string; LineNumber: Integer);
begin
inherited;
@ -1142,6 +1154,8 @@ begin
fTokKind := tkSpecK
else if fPhobosStyleType and ('A' <= fLineBuf[FTokStart]) and (fLineBuf[FTokStart] <= 'Z') then
fTokKind:= tkTypes
else if reader^ = '(' then
fTokKind:= tkCall
else if rkAsm in fCurrRange.rangeKinds then
fTokKind:=tkAsmbl;
exit;

View File

@ -384,6 +384,8 @@ begin
getHl.types.Foreground:=clBlack;
getHl.types.Style:=[fsBold];
getHl.phobosStyleType := True;
//
getHl.calls.Assign(getHl.identifiers);
end;
with fPresets.insertPreset(1) do
begin
@ -429,6 +431,7 @@ begin
selection.Foreground := clNone;
selection.BackPriority:= 2;
getHl.phobosStyleType := True;
getHl.calls.Assign(getHl.identifiers);
end;
with fPresets.insertPreset(2) do
begin
@ -471,6 +474,7 @@ begin
selection.Foreground := clNone;
selection.BackPriority := 1;
getHl.phobosStyleType := True;
getHl.calls.Assign(getHl.identifiers);
end;
with fPresets.insertPreset(3) do
begin
@ -508,6 +512,7 @@ begin
selection.Foreground := clNone;
selection.BackPriority := 10;
getHl.phobosStyleType := True;
getHl.calls.Assign(getHl.identifiers);
end;
with fPresets.insertPreset(4) do
begin
@ -545,6 +550,7 @@ begin
selection.Background := 12837345;
selection.Foreground := clNone;
getHl.phobosStyleType := True;
getHl.calls.Assign(getHl.identifiers);
end;
with fPresets.insertPreset(5) do
begin
@ -587,6 +593,7 @@ begin
mouseLink.Style := [fsBold, fsUnderline];
selection.Background := $9DAABC;
selection.Foreground := clNone;
getHl.calls.Assign(getHl.identifiers);
end;
fEditor := TSynEdit.Create(self);