GitHub uses a different style for Bash backticks, example
http://github.com/git/git/blob/master/git-pull.sh
Instead of coloring the entire section they only color the
opening "$(" and closing ")"
This is desirable with Scintilla because keywords within backticks could be highlighted instead of the whole section being one color. I am not asking that this be implemented per se, but if someone could help me along with the code. I was able to do this
--- a/scintilla/lexers/LexBash.cxx
+++ b/scintilla/lexers/LexBash.cxx
@@ -628,7 +628,7 @@ static void ColouriseBashDoc(unsigned int startPos, int length, i
sc.SetState(SCE_SH_BACKTICKS);
QuoteStack.Start(sc.ch, BASH_DELIM_BACKTICK);
} else if (sc.ch == '$') {
- if (sc.Match("$((")) {
+ if (sc.Match("$((") || sc.Match("$(")) {^M
sc.SetState(SCE_SH_OPERATOR); // handle '((
continue;
}
but this doesnt give style to the "$(" and ")", only allow keyword styles within the
backticks.
Here is a patch that has been casually tested.
The $( and ) are styled as operators, anything else would be non-trivial. The cmdState line tells the lexer the next word may be a keyword.
Kein-Hong, thanks for you reply. However after looking again it appears my original patch already set
$(and)as operators. This is not desired because I would like to style the backticks independent of operators.Assuming you don't want $() to clash with ``, you'll need a new style. Add the style entry in the appropriate places, then duplicate the relevant code running operators for the new $() style.
BUT... the flaw or problem in the above solution is this: how does the closing parentheses know it needs to use the $( style? Matched $( and ) in its own style cannot be trivially implemented, since our lexer code is lower-level but faster compared to regexp or high-level matchers. So, styling it as operators is the quickest solution, else much more time will have to be invested.
Related to [feature-requests:#1033], highlight
$(and)as operator would be the simplest change.Related
Feature Requests:
#1033The new lexer option lexer.bash.command.substitution with value 1 or 2 may be used to display states inside the command substitution.
https://github.com/ScintillaOrg/lexilla/issues/153