Skip to content

Commit

Permalink
Highlight Julia/Rust function definition name and function call with …
Browse files Browse the repository at this point in the history
…different color.
  • Loading branch information
zufuliu committed Nov 8, 2019
1 parent 14e0fd5 commit f8f42be
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 4 deletions.
2 changes: 2 additions & 0 deletions scintilla/include/SciLexer.h
Expand Up @@ -801,6 +801,7 @@
#define SCE_RUST_ATTRIBUTE 27
#define SCE_RUST_CONSTANT 28
#define SCE_RUST_LINE_CONTINUE 29
#define SCE_RUST_FUNCTION_DEFINE 30
#define SCE_VIM_DEFAULT 0
#define SCE_VIM_COMMENTLINE 1
#define SCE_VIM_NUMBER 2
Expand Down Expand Up @@ -876,6 +877,7 @@
#define SCE_JULIA_TYPE 29
#define SCE_JULIA_CONSTANT 30
#define SCE_JULIA_BASIC_FUNCTION 31
#define SCE_JULIA_FUNCTION_DEFINE 40
/* --Autogenerated -- end of section automatically generated from SciLexer.iface */

#endif
2 changes: 2 additions & 0 deletions scintilla/include/SciLexer.iface
Expand Up @@ -1930,6 +1930,7 @@ val SCE_RUST_VARIABLE=26
val SCE_RUST_ATTRIBUTE=27
val SCE_RUST_CONSTANT=28
val SCE_RUST_LINE_CONTINUE=29
val SCE_RUST_FUNCTION_DEFINE=30
# Lexical states for SCLEX_VIM
lex Vim=SCLEX_VIM SCE_VIM_
val SCE_VIM_DEFAULT=0
Expand Down Expand Up @@ -2011,3 +2012,4 @@ val SCE_JULIA_WORD_DEMOTED=28
val SCE_JULIA_TYPE=29
val SCE_JULIA_CONSTANT=30
val SCE_JULIA_BASIC_FUNCTION=31
val SCE_JULIA_FUNCTION_DEFINE=40
4 changes: 2 additions & 2 deletions scintilla/lexers/LexJulia.cxx
Expand Up @@ -185,7 +185,7 @@ void ColouriseJuliaDoc(Sci_PositionU startPos, Sci_Position lengthDoc, int initS
} else if (strcmp(s, "macro") == 0) {
kwType = SCE_JULIA_MACRO;
} else if (strcmp(s, "function") == 0) {
kwType = SCE_JULIA_FUNCTION;
kwType = SCE_JULIA_FUNCTION_DEFINE;
} else if (strcmp(s, "abstract") == 0 || strcmp(s, "primitive") == 0) {
kwType = SCE_JULIA_WORD;
}
Expand All @@ -198,7 +198,7 @@ void ColouriseJuliaDoc(Sci_PositionU startPos, Sci_Position lengthDoc, int initS
sc.ChangeState(SCE_JULIA_BASIC_FUNCTION);
} else if (kwType != SCE_JULIA_DEFAULT && kwType != SCE_JULIA_WORD) {
sc.ChangeState(kwType);
if (kwType == SCE_JULIA_FUNCTION && sc.ch == '!') {
if (kwType == SCE_JULIA_FUNCTION_DEFINE && sc.ch == '!') {
sc.Forward();
}
} else {
Expand Down
4 changes: 2 additions & 2 deletions scintilla/lexers/LexRust.cxx
Expand Up @@ -123,7 +123,7 @@ void ColouriseRustDoc(Sci_PositionU startPos, Sci_Position lengthDoc, int initSt
if (strcmp(s, "struct") == 0) {
kwType = SCE_RUST_STRUCT;
} else if (strcmp(s, "fn") == 0) {
kwType = SCE_RUST_FUNCTION;
kwType = SCE_RUST_FUNCTION_DEFINE;
} else if (strcmp(s, "trait") == 0) {
kwType = SCE_RUST_TRAIT;
} else if (strcmp(s, "enum") == 0) {
Expand Down Expand Up @@ -161,7 +161,7 @@ void ColouriseRustDoc(Sci_PositionU startPos, Sci_Position lengthDoc, int initSt
} else {
const int chNext = sc.GetNextNSChar();
if (chNext == '(') {
sc.ChangeState(SCE_RUST_FUNCTION);
sc.ChangeState((kwType == SCE_RUST_FUNCTION_DEFINE)? kwType : SCE_RUST_FUNCTION);
} else if (chNext == '!') {
sc.ChangeState(SCE_RUST_MACRO);
} else if (kwType != SCE_RUST_DEFAULT) {
Expand Down
1 change: 1 addition & 0 deletions src/EditLexers/stlJulia.c
Expand Up @@ -188,6 +188,7 @@ static EDITSTYLE Styles_Julia[] = {
{ SCE_JULIA_CONSTANT, NP2STYLE_Constant, EDITSTYLE_HOLE(L"Constant"), L"fore:#307300" },
{ SCE_JULIA_MACRO, NP2STYLE_Macro, EDITSTYLE_HOLE(L"Macro"), L"fore:#FF8000" },
{ SCE_JULIA_BASIC_FUNCTION, NP2STYLE_BasicFunction, EDITSTYLE_HOLE(L"Basic Function"), L"fore:#0080C0" },
{ SCE_JULIA_FUNCTION_DEFINE, NP2STYLE_FunctionDef, EDITSTYLE_HOLE(L"Function Define"), L"bold; fore:#A46000" },
{ SCE_JULIA_FUNCTION, NP2STYLE_Function, EDITSTYLE_HOLE(L"Function"), L"fore:#A46000" },
{ MULTI_STYLE(SCE_JULIA_COMMENTLINE, SCE_JULIA_COMMENTBLOCK, 0, 0), NP2STYLE_Comment, EDITSTYLE_HOLE(L"Comment"), L"fore:#608060" },
{ MULTI_STYLE(SCE_JULIA_CHARACTER, SCE_JULIA_STRING, 0, 0), NP2STYLE_String, EDITSTYLE_HOLE(L"String"), L"fore:#008000" },
Expand Down
1 change: 1 addition & 0 deletions src/EditLexers/stlRust.c
Expand Up @@ -226,6 +226,7 @@ static EDITSTYLE Styles_Rust[] = {
{ SCE_RUST_ENUMERATION, NP2STYLE_Enumeration, EDITSTYLE_HOLE(L"Enumeration"), L"fore:#FF8000" },
{ SCE_RUST_CONSTANT, NP2STYLE_Constant, EDITSTYLE_HOLE(L"Constant"), L"fore:#B000B0" },
{ SCE_RUST_MACRO, NP2STYLE_Macro, EDITSTYLE_HOLE(L"Macro"), L"fore:#FF8000" },
{ SCE_RUST_FUNCTION_DEFINE, NP2STYLE_FunctionDef, EDITSTYLE_HOLE(L"Function Define"), L"bold; fore:#A46000" },
{ SCE_RUST_FUNCTION, NP2STYLE_Function, EDITSTYLE_HOLE(L"Function"), L"fore:#A46000" },
{ MULTI_STYLE(SCE_RUST_COMMENTBLOCK, SCE_RUST_COMMENTLINE, 0, 0), NP2STYLE_Comment, EDITSTYLE_HOLE(L"Comment"), L"fore:#608060" },
{ MULTI_STYLE(SCE_RUST_COMMENTBLOCKDOC, SCE_RUST_COMMENTLINEDOC, 0, 0), NP2STYLE_DocComment, EDITSTYLE_HOLE(L"Doc Comment"), L"fore:#408040" },
Expand Down

0 comments on commit f8f42be

Please sign in to comment.