Skip to content

Commit

Permalink
[Zig] Fix \u{} escape highlighting, highlight top-level comment.
Browse files Browse the repository at this point in the history
  • Loading branch information
zufuliu committed Aug 24, 2024
1 parent 3ca39c8 commit a88cba6
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 18 deletions.
31 changes: 16 additions & 15 deletions scintilla/include/SciLexer.h
Original file line number Diff line number Diff line change
Expand Up @@ -1827,21 +1827,22 @@
#define SCE_ZIG_DEFAULT 0
#define SCE_ZIG_COMMENTLINE 1
#define SCE_ZIG_COMMENTLINEDOC 2
#define SCE_ZIG_TASKMARKER 3
#define SCE_ZIG_NUMBER 4
#define SCE_ZIG_OPERATOR 5
#define SCE_ZIG_CHARACTER 6
#define SCE_ZIG_STRING 7
#define SCE_ZIG_MULTISTRING 8
#define SCE_ZIG_ESCAPECHAR 9
#define SCE_ZIG_FORMAT_SPECIFIER 10
#define SCE_ZIG_PLACEHOLDER 11
#define SCE_ZIG_IDENTIFIER 12
#define SCE_ZIG_BUILTIN_FUNCTION 13
#define SCE_ZIG_WORD 14
#define SCE_ZIG_TYPE 15
#define SCE_ZIG_FUNCTION 16
#define SCE_ZIG_FUNCTION_DEFINITION 17
#define SCE_ZIG_COMMENTLINETOP 3
#define SCE_ZIG_TASKMARKER 4
#define SCE_ZIG_NUMBER 5
#define SCE_ZIG_OPERATOR 6
#define SCE_ZIG_CHARACTER 7
#define SCE_ZIG_STRING 8
#define SCE_ZIG_MULTISTRING 9
#define SCE_ZIG_ESCAPECHAR 10
#define SCE_ZIG_FORMAT_SPECIFIER 11
#define SCE_ZIG_PLACEHOLDER 12
#define SCE_ZIG_IDENTIFIER 13
#define SCE_ZIG_BUILTIN_FUNCTION 14
#define SCE_ZIG_WORD 15
#define SCE_ZIG_TYPE 16
#define SCE_ZIG_FUNCTION 17
#define SCE_ZIG_FUNCTION_DEFINITION 18
#define SCE_MATHEMATICA_DEFAULT 0
#define SCE_MATHEMATICA_COMMENTLINE 1
#define SCE_MATHEMATICA_COMMENT 2
Expand Down
1 change: 1 addition & 0 deletions scintilla/include/SciLexer.iface
Original file line number Diff line number Diff line change
Expand Up @@ -3135,6 +3135,7 @@ lex Zig=SCLEX_ZIG SCE_ZIG_
val SCE_ZIG_DEFAULT=
val SCE_ZIG_COMMENTLINE=
val SCE_ZIG_COMMENTLINEDOC=
val SCE_ZIG_COMMENTLINETOP=
val SCE_ZIG_TASKMARKER=
val SCE_ZIG_NUMBER=
val SCE_ZIG_OPERATOR=
Expand Down
8 changes: 6 additions & 2 deletions scintilla/lexers/LexZig.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ void ColouriseZigDoc(Sci_PositionU startPos, Sci_Position lengthDoc, int initSty
sc.Forward();
if (sc.Match('u', '{')) {
escSeq.brace = true;
escSeq.digitsLeft = 7;
sc.Forward();
}
} else if ((sc.ch == '\'' && sc.state == SCE_ZIG_CHARACTER) || (sc.ch == '\"' && sc.state == SCE_ZIG_STRING)) {
Expand Down Expand Up @@ -277,6 +278,7 @@ void ColouriseZigDoc(Sci_PositionU startPos, Sci_Position lengthDoc, int initSty

case SCE_ZIG_COMMENTLINE:
case SCE_ZIG_COMMENTLINEDOC:
case SCE_ZIG_COMMENTLINETOP:
if (sc.atLineStart) {
sc.SetState(SCE_ZIG_DEFAULT);
}
Expand All @@ -289,8 +291,10 @@ void ColouriseZigDoc(Sci_PositionU startPos, Sci_Position lengthDoc, int initSty
lineState = ZigLineStateMaskLineComment;
}
sc.SetState(SCE_ZIG_COMMENTLINE);
sc.Forward();
if (sc.chNext == '!' || sc.chNext == '/') {
sc.Forward(2);
if (sc.ch == '!') {
sc.ChangeState(SCE_ZIG_COMMENTLINETOP);
} else if (sc.ch == '/' && sc.chNext != '/') {
sc.ChangeState(SCE_ZIG_COMMENTLINEDOC);
}
} else if (sc.Match('\\', '\\')) {
Expand Down
2 changes: 1 addition & 1 deletion src/EditLexers/stlZig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ static EDITSTYLE Styles_Zig[] = {
{ SCE_ZIG_FUNCTION_DEFINITION, NP2StyleX_FunctionDefinition, L"bold; fore:#0080C0" },
{ SCE_ZIG_FUNCTION, NP2StyleX_Function, L"fore:#A46000" },
{ SCE_ZIG_COMMENTLINE, NP2StyleX_Comment, L"fore:#608060" },
{ SCE_ZIG_COMMENTLINEDOC, NP2StyleX_DocComment, L"fore:#408040" },
{ MULTI_STYLE(SCE_ZIG_COMMENTLINEDOC, SCE_ZIG_COMMENTLINETOP, 0, 0), NP2StyleX_DocComment, L"fore:#408040" },
{ MULTI_STYLE(SCE_ZIG_CHARACTER, SCE_ZIG_STRING, 0, 0), NP2StyleX_String, L"fore:#008000" },
{ SCE_ZIG_MULTISTRING, NP2StyleX_RawString, L"fore:#008080" },
{ SCE_ZIG_ESCAPECHAR, NP2StyleX_EscapeSequence, L"fore:#0080C0" },
Expand Down

0 comments on commit a88cba6

Please sign in to comment.