Skip to content

Commit

Permalink
[Swift] Highlight #macro.
Browse files Browse the repository at this point in the history
  • Loading branch information
zufuliu committed Feb 22, 2024
1 parent 5479ed3 commit 4e05bfb
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 21 deletions.
33 changes: 17 additions & 16 deletions scintilla/include/SciLexer.h
Original file line number Diff line number Diff line change
Expand Up @@ -1490,30 +1490,31 @@
#define SCE_SWIFT_COMMENTBLOCK 3
#define SCE_SWIFT_COMMENTBLOCKDOC 4
#define SCE_SWIFT_TASKMARKER 5
#define SCE_SWIFT_FUNCTION 6
#define SCE_SWIFT_OPERATOR 7
#define SCE_SWIFT_OPERATOR2 8
#define SCE_SWIFT_OPERATOR_PF 9
#define SCE_SWIFT_OPERATOR 6
#define SCE_SWIFT_OPERATOR2 7
#define SCE_SWIFT_OPERATOR_PF 8
#define SCE_SWIFT_NUMBER 9
#define SCE_SWIFT_ESCAPECHAR 10
#define SCE_SWIFT_STRING 11
#define SCE_SWIFT_TRIPLE_STRING 12
#define SCE_SWIFT_STRING_ED 13
#define SCE_SWIFT_TRIPLE_STRING_ED 14
#define SCE_SWIFT_REGEX_ED 15
#define SCE_SWIFT_REGEX 16
#define SCE_SWIFT_NUMBER 17
#define SCE_SWIFT_DIRECTIVE 18
#define SCE_SWIFT_IDENTIFIER 19
#define SCE_SWIFT_IDENTIFIER_BT 20
#define SCE_SWIFT_ATTRIBUTE 21
#define SCE_SWIFT_VARIABLE 22
#define SCE_SWIFT_WORD 23
#define SCE_SWIFT_CLASS 24
#define SCE_SWIFT_STRUCT 25
#define SCE_SWIFT_PROTOCOL 26
#define SCE_SWIFT_ENUM 27
#define SCE_SWIFT_DIRECTIVE 17
#define SCE_SWIFT_IDENTIFIER 18
#define SCE_SWIFT_IDENTIFIER_BT 19
#define SCE_SWIFT_ATTRIBUTE 20
#define SCE_SWIFT_VARIABLE 21
#define SCE_SWIFT_WORD 22
#define SCE_SWIFT_CLASS 23
#define SCE_SWIFT_STRUCT 24
#define SCE_SWIFT_PROTOCOL 25
#define SCE_SWIFT_ENUM 26
#define SCE_SWIFT_MACRO 27
#define SCE_SWIFT_FUNCTION_DEFINITION 28
#define SCE_SWIFT_LABEL 29
#define SCE_SWIFT_FUNCTION 29
#define SCE_SWIFT_LABEL 30
#define SCE_JS_DEFAULT 0
#define SCE_JS_COMMENTLINE 1
#define SCE_JS_COMMENTLINEDOC 2
Expand Down
5 changes: 3 additions & 2 deletions scintilla/include/SciLexer.iface
Original file line number Diff line number Diff line change
Expand Up @@ -2788,18 +2788,17 @@ val SCE_SWIFT_COMMENTLINEDOC=
val SCE_SWIFT_COMMENTBLOCK=
val SCE_SWIFT_COMMENTBLOCKDOC=
val SCE_SWIFT_TASKMARKER=
val SCE_SWIFT_FUNCTION=
val SCE_SWIFT_OPERATOR=
val SCE_SWIFT_OPERATOR2=
val SCE_SWIFT_OPERATOR_PF=
val SCE_SWIFT_NUMBER=
val SCE_SWIFT_ESCAPECHAR=
val SCE_SWIFT_STRING=11
val SCE_SWIFT_TRIPLE_STRING=12
val SCE_SWIFT_STRING_ED=13
val SCE_SWIFT_TRIPLE_STRING_ED=14
val SCE_SWIFT_REGEX_ED=
val SCE_SWIFT_REGEX=
val SCE_SWIFT_NUMBER=
val SCE_SWIFT_DIRECTIVE=
val SCE_SWIFT_IDENTIFIER=
val SCE_SWIFT_IDENTIFIER_BT=
Expand All @@ -2810,7 +2809,9 @@ val SCE_SWIFT_CLASS=
val SCE_SWIFT_STRUCT=
val SCE_SWIFT_PROTOCOL=
val SCE_SWIFT_ENUM=
val SCE_SWIFT_MACRO=
val SCE_SWIFT_FUNCTION_DEFINITION=
val SCE_SWIFT_FUNCTION=
val SCE_SWIFT_LABEL=
# Lexical states for SCLEX_JAVASCRIPT
lex JavaScript=SCLEX_JAVASCRIPT SCE_JS_ SCE_JSX_
Expand Down
5 changes: 2 additions & 3 deletions scintilla/lexers/LexSwift.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ constexpr bool IsEscapeSequence(int ch) noexcept {

constexpr bool FollowExpression(int chPrevNonWhite, int stylePrevNonWhite) noexcept {
return chPrevNonWhite == ')' || chPrevNonWhite == ']'
|| (stylePrevNonWhite >= SCE_SWIFT_OPERATOR_PF && stylePrevNonWhite <= SCE_SWIFT_NUMBER)
|| (stylePrevNonWhite >= SCE_SWIFT_OPERATOR_PF && stylePrevNonWhite < SCE_SWIFT_DIRECTIVE)
|| IsIdentifierCharEx(chPrevNonWhite);
}

Expand Down Expand Up @@ -186,8 +186,7 @@ void ColouriseSwiftDoc(Sci_PositionU startPos, Sci_Position lengthDoc, int initS
sc.GetCurrent(s, sizeof(s));
if (sc.state == SCE_SWIFT_DIRECTIVE) {
if (!keywordLists[KeywordIndex_Directive].InListPrefixed(s + 1, '(')) {
// required for code folding
sc.ChangeState(SCE_SWIFT_DEFAULT);
sc.ChangeState(SCE_SWIFT_MACRO);
}
} else if (keywordLists[KeywordIndex_Keyword].InList(s)) {
sc.ChangeState(SCE_SWIFT_WORD);
Expand Down
1 change: 1 addition & 0 deletions src/EditLexers/stlSwift.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ static EDITSTYLE Styles_Swift[] = {
{ SCE_SWIFT_STRUCT, NP2StyleX_Structure, L"fore:#0080FF" },
{ SCE_SWIFT_PROTOCOL, NP2StyleX_Protocol, L"bold; fore:#1E90FF" },
{ SCE_SWIFT_ENUM, NP2StyleX_Enumeration, L"fore:#FF8000" },
{ SCE_SWIFT_MACRO, NP2StyleX_Macro, L"fore:#808000" },
{ SCE_SWIFT_FUNCTION_DEFINITION, NP2StyleX_FunctionDefinition, L"bold; fore:#A46000" },
{ SCE_SWIFT_FUNCTION, NP2StyleX_Function, L"fore:#A46000" },
{ MULTI_STYLE(SCE_SWIFT_COMMENTBLOCK, SCE_SWIFT_COMMENTLINE, 0, 0), NP2StyleX_Comment, L"fore:#608060" },
Expand Down

0 comments on commit 4e05bfb

Please sign in to comment.