Skip to content

Commit

Permalink
Colorize YAML anchor and alias with different style.
Browse files Browse the repository at this point in the history
  • Loading branch information
zufuliu committed Mar 10, 2020
1 parent 516b012 commit 33b0c7a
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 9 deletions.
5 changes: 3 additions & 2 deletions scintilla/include/SciLexer.h
Expand Up @@ -614,8 +614,8 @@
#define SCE_YAML_IDENTIFIER 2
#define SCE_YAML_KEYWORD 3
#define SCE_YAML_NUMBER 4
#define SCE_YAML_REFERENCE 5
#define SCE_YAML_DOCUMENT 6
#define SCE_YAML_ANCHOR 5
#define SCE_YAML_ALIAS 6
#define SCE_YAML_TEXT 7
#define SCE_YAML_ERROR 8
#define SCE_YAML_OPERATOR 9
Expand All @@ -629,6 +629,7 @@
#define SCE_YAML_VERBATIM_TAG 17
#define SCE_YAML_DATETIME 18
#define SCE_YAML_INDENTED_TEXT 19
#define SCE_YAML_DOCUMENT 20
#define SCE_V_DEFAULT 0
#define SCE_V_COMMENT 1
#define SCE_V_COMMENTLINE 2
Expand Down
5 changes: 3 additions & 2 deletions scintilla/include/SciLexer.iface
Expand Up @@ -1140,8 +1140,8 @@ val SCE_YAML_COMMENT=1
val SCE_YAML_IDENTIFIER=2
val SCE_YAML_KEYWORD=3
val SCE_YAML_NUMBER=4
val SCE_YAML_REFERENCE=5
val SCE_YAML_DOCUMENT=6
val SCE_YAML_ANCHOR=5
val SCE_YAML_ALIAS=6
val SCE_YAML_TEXT=7
val SCE_YAML_ERROR=8
val SCE_YAML_OPERATOR=9
Expand All @@ -1155,6 +1155,7 @@ val SCE_YAML_TAG=16
val SCE_YAML_VERBATIM_TAG=17
val SCE_YAML_DATETIME=18
val SCE_YAML_INDENTED_TEXT=19
val SCE_YAML_DOCUMENT=20
# Lexical states for SCLEX_TEX
#lex TeX=SCLEX_TEX SCE_TEX_
#val SCE_TEX_DEFAULT=0
Expand Down
5 changes: 3 additions & 2 deletions scintilla/lexers/LexYAML.cxx
Expand Up @@ -245,7 +245,8 @@ void ColouriseYAMLDoc(Sci_PositionU startPos, Sci_Position lengthDoc, int initSt
}
break;

case SCE_YAML_REFERENCE:
case SCE_YAML_ANCHOR:
case SCE_YAML_ALIAS:
if (!IsYAMLAnchorChar(sc.ch)) {
sc.SetState(SCE_YAML_DEFAULT);
}
Expand Down Expand Up @@ -338,7 +339,7 @@ void ColouriseYAMLDoc(Sci_PositionU startPos, Sci_Position lengthDoc, int initSt
} else if (sc.ch == '\"') {
sc.SetState(SCE_YAML_STRING2);
} else if ((sc.ch == '&' || sc.ch == '*') && IsYAMLAnchorChar(sc.chNext)) {
sc.SetState(SCE_YAML_REFERENCE);
sc.SetState((sc.ch == '&')? SCE_YAML_ANCHOR : SCE_YAML_ALIAS);
} else if (sc.ch == '!') {
if (sc.chNext == '<') {
sc.SetState(SCE_YAML_VERBATIM_TAG);
Expand Down
2 changes: 1 addition & 1 deletion src/EditLexers/EditStyle.h
Expand Up @@ -236,7 +236,7 @@
#define NP2STYLE_DateTime 63566
#define NP2STYLE_Action 63567
#define NP2STYLE_ModuleDirective 63568
#define NP2STYLE_Reference 63569
#define NP2STYLE_Anchor 63569
#define NP2STYLE_TextBlock 63570
#define NP2STYLE_Math 63571
#define NP2STYLE_SpecialCharacter 63572
Expand Down
2 changes: 1 addition & 1 deletion src/EditLexers/EditStyleX.h
Expand Up @@ -244,7 +244,7 @@
#define NP2StyleX_DateTime EDITSTYLE_HOLE(DateTime, L"DateTime")
#define NP2StyleX_Action EDITSTYLE_HOLE(Action, L"Action")
#define NP2StyleX_ModuleDirective EDITSTYLE_HOLE(ModuleDirective, L"Module Directive")
#define NP2StyleX_Reference EDITSTYLE_HOLE(Reference, L"Reference")
#define NP2StyleX_Anchor EDITSTYLE_HOLE(Anchor, L"Anchor")
#define NP2StyleX_TextBlock EDITSTYLE_HOLE(TextBlock, L"Text Block")
#define NP2StyleX_Math EDITSTYLE_HOLE(Math, L"Math")
#define NP2StyleX_SpecialCharacter EDITSTYLE_HOLE(SpecialCharacter, L"Special Character")
Expand Down
3 changes: 2 additions & 1 deletion src/EditLexers/stlYAML.c
Expand Up @@ -19,7 +19,8 @@ static EDITSTYLE Styles_YAML[] = {
{ SCE_YAML_DIRECTIVE, NP2StyleX_Directive, L"fore:#FF8000" },
{ SCE_YAML_DOCUMENT, NP2StyleX_Document, L"bold; back:#FFC040; eolfilled" },
{ SCE_YAML_KEY, NP2StyleX_Property, L"fore:#A46000" },
{ SCE_YAML_REFERENCE, NP2StyleX_Reference, L"fore:#9E4D2A" },
{ SCE_YAML_ANCHOR, NP2StyleX_Anchor, L"fore:#9E4D2A" },
{ SCE_YAML_ALIAS, NP2StyleX_Alias, L"fore:#9E4D2A" },
{ MULTI_STYLE(SCE_YAML_TAG, SCE_YAML_VERBATIM_TAG, 0, 0), NP2StyleX_Tag, L"fore:#7C5AF3" },
{ SCE_YAML_COMMENT, NP2StyleX_Comment, L"fore:#608060" },
{ MULTI_STYLE(SCE_YAML_STRING1, SCE_YAML_STRING2, 0, 0), NP2StyleX_String, L"fore:#008000" },
Expand Down

0 comments on commit 33b0c7a

Please sign in to comment.