Skip to content

Commit

Permalink
+upd: Lexilla Lib v5.1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
RaiKoHoff committed Feb 9, 2022
1 parent 424beae commit d9ecb08
Show file tree
Hide file tree
Showing 29 changed files with 400 additions and 186 deletions.
13 changes: 11 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,13 @@ indent_style = space
indent_size = 4
tab_width = 4

[**.{ini}]
charset = utf-8-sig
[lexilla/**.{h,c,cpp,hpp,cxx}]
# Set default charset
#charset = utf-8
# space (w=2) indentation
indent_style = tab
indent_size = 4
tab_width = 4

[language/**.{h,rc}]
charset = utf-8
Expand All @@ -33,3 +38,7 @@ tab_width = 4

[language/common_res.rc]
charset = latin1

[**.{ini}]
charset = utf-8-sig

11 changes: 4 additions & 7 deletions lexilla/doc/Lexilla.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<meta name="keywords" content="Scintilla, SciTE, Editing Component, Text Editor" />
<meta name="Description"
content="www.scintilla.org is the home of the Scintilla editing component and SciTE text editor application." />
<meta name="Date.Modified" content="20211207" />
<meta name="Date.Modified" content="20220209" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style type="text/css">
.logo {
Expand Down Expand Up @@ -61,8 +61,8 @@
<font color="#FFCC99" size="4"> A library of language lexers for use with Scintilla</font>
</td>
<td width="40%" align="right">
<font color="#FFCC99" size="3">Release version 5.1.4<br />
Site last modified December 7 2021</font>
<font color="#FFCC99" size="3">Release version 5.1.5<br />
Site last modified February 9 2022</font>
</td>
<td width="20%">
&nbsp;
Expand All @@ -77,13 +77,10 @@
</tr>
</table>
<ul id="versionlist">
<li>Version 5.1.5 improves Bash, Batch, F#, HTML, Inno Setup, and Python.</li>
<li>Version 5.1.4 adds lexers for AsciiDoc and GDScript.</li>
<li>Version 5.1.3 improves Rust.</li>
<li>Version 5.1.2 improves CSS, F#, Inno Setup, Markdown, and PHP.</li>
<li>Version 5.1.1 improves C++, Julia, Markdown, Matlab, and PHP.</li>
<li>Version 5.1.0 is a stable release: the interfaces between Scintilla and Lexilla and between
platform-independent code and platform layers should remain compatible through 5.x releases.
Improvements were made for ASP, Erlang, F#, Raku, Ruby, Tcl, and YAML.</li>
</ul>
<ul id="menu">
<li id="remote1"><a href="https://www.scintilla.org/SciTEImage.html">Screenshot</a></li>
Expand Down
10 changes: 5 additions & 5 deletions lexilla/doc/LexillaDownload.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
<table bgcolor="#CCCCCC" width="100%" cellspacing="0" cellpadding="8" border="0">
<tr>
<td>
<font size="4"> <a href="https://www.scintilla.org/lexilla514.zip">
<font size="4"> <a href="https://www.scintilla.org/lexilla515.zip">
Windows</a>&nbsp;&nbsp;
<a href="https://www.scintilla.org/lexilla514.tgz">
<a href="https://www.scintilla.org/lexilla515.tgz">
GTK/Linux</a>&nbsp;&nbsp;
</font>
</td>
Expand All @@ -42,16 +42,16 @@ <h2>
containing very few restrictions.
</p>
<h3>
Release 4.4.6
Release 5.1.5
</h3>
<h4>
Source Code
</h4>
The source code package contains all of the source code for Lexilla but no binary
executable code and is available in
<ul>
<li><a href="https://www.scintilla.org/lexilla514.zip">zip format</a> (1.1M) commonly used on Windows</li>
<li><a href="https://www.scintilla.org/lexilla514.tgz">tgz format</a> (0.8M) commonly used on Linux and compatible operating systems</li>
<li><a href="https://www.scintilla.org/lexilla515.zip">zip format</a> (1.1M) commonly used on Windows</li>
<li><a href="https://www.scintilla.org/lexilla515.tgz">tgz format</a> (0.9M) commonly used on Linux and compatible operating systems</li>
</ul>
Instructions for building on both Windows and Linux are included in the readme file.
<h4>
Expand Down
47 changes: 46 additions & 1 deletion lexilla/doc/LexillaHistory.html
Original file line number Diff line number Diff line change
Expand Up @@ -574,9 +574,54 @@ <h2>Contributors</h2>
<td>Michael Heath</td>
<td>Antonio Cebrián</td>
<td>David Yu Yang</td>
<td>Arkadiusz Michalski</td>
</tr><tr>
<td>Red_M</td>
</tr>
</table>
<h2>Releases</h2>
<h3>
<a href="https://www.scintilla.org/lexilla515.zip">Release 5.1.5</a>
</h3>
<ul>
<li>
Released 9 February 2022.
</li>
<li>
Bash: Treat \r\n line ends the same as \n. This makes testing easier.
<a href="https://github.com/ScintillaOrg/lexilla/issues/57">Issue #57</a>.
</li>
<li>
Batch: Recognise "::" comments when second command on line.
<a href="https://sourceforge.net/p/scintilla/bugs/2304/">Bug #2304</a>.
</li>
<li>
F#: Recognise format specifiers in interpolated strings and %B for binary.
<a href="https://github.com/ScintillaOrg/lexilla/issues/46">Issue #46</a>.
</li>
<li>
F#: More accurate line-based folding.
<a href="https://github.com/ScintillaOrg/lexilla/issues/56">Issue #56</a>.
</li>
<li>
HTML: Fix folding inside script blocks.
<a href="https://github.com/ScintillaOrg/lexilla/issues/47">Issue #47</a>,
<a href="https://github.com/ScintillaOrg/lexilla/issues/53">Issue #53</a>.
</li>
<li>
Inno Setup: Fix multiline comments in code.
<a href="https://github.com/ScintillaOrg/lexilla/issues/44">Issue #44</a>.
</li>
<li>
Python: Add attribute style with properties lexer.python.identifier.attributes and
lexer.python.decorator.attributes.
<a href="https://github.com/ScintillaOrg/lexilla/pull/49">Pull request #49</a>.
</li>
<li>
Allow choice of object file directory with makefile by setting DIR_O.
<a href="https://github.com/ScintillaOrg/lexilla/issues/50">Issue #50</a>.
</li>
</ul>
<h3>
<a href="https://www.scintilla.org/lexilla514.zip">Release 5.1.4</a>
</h3>
Expand All @@ -595,7 +640,7 @@ <h3>
</li>
<li>
Fix strings ending in escaped '\' in F#.
<a href="https://github.com/ScintillaOrg/lexilla/issues/38">Issue #38</a>,
<a href="https://github.com/ScintillaOrg/lexilla/issues/38">Issue #38</a>.
</li>
<li>
Better handling of bad terminators and folding for X12.
Expand Down
1 change: 1 addition & 0 deletions lexilla/include/LexicalStyles.iface
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ val SCE_P_FSTRING=16
val SCE_P_FCHARACTER=17
val SCE_P_FTRIPLE=18
val SCE_P_FTRIPLEDOUBLE=19
val SCE_P_ATTRIBUTE=20
# Lexical states for SCLEX_CPP
# Lexical states for SCLEX_BULLANT
# Lexical states for SCLEX_COBOL
Expand Down
1 change: 1 addition & 0 deletions lexilla/include/SciLexer.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@
#define SCE_P_FCHARACTER 17
#define SCE_P_FTRIPLE 18
#define SCE_P_FTRIPLEDOUBLE 19
#define SCE_P_ATTRIBUTE 20
#define SCE_C_DEFAULT 0
#define SCE_C_COMMENT 1
#define SCE_C_COMMENTLINE 2
Expand Down
8 changes: 4 additions & 4 deletions lexilla/lexers/LexBash.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ void SCI_METHOD LexerBash::Lex(Sci_PositionU startPos, Sci_Position length, int
sc.SetState(SCE_SH_DEFAULT);
break;
case SCE_SH_COMMENTLINE:
if (sc.atLineEnd && sc.chPrev != '\\') {
if (sc.MatchLineEnd() && sc.chPrev != '\\') {
sc.SetState(SCE_SH_DEFAULT);
}
break;
Expand Down Expand Up @@ -678,13 +678,13 @@ void SCI_METHOD LexerBash::Lex(Sci_PositionU startPos, Sci_Position length, int
if (sc.atLineStart) {
sc.SetState(SCE_SH_HERE_Q);
int prefixws = 0;
while (sc.ch == '\t' && !sc.atLineEnd) { // tabulation prefix
while (sc.ch == '\t' && !sc.MatchLineEnd()) { // tabulation prefix
sc.Forward();
prefixws++;
}
if (prefixws > 0)
sc.SetState(SCE_SH_HERE_Q);
while (!sc.atLineEnd) {
while (!sc.MatchLineEnd()) {
sc.Forward();
}
char s[HERE_DELIM_MAX];
Expand Down Expand Up @@ -794,7 +794,7 @@ void SCI_METHOD LexerBash::Lex(Sci_PositionU startPos, Sci_Position length, int
}

// Must check end of HereDoc state 1 before default state is handled
if (HereDoc.State == 1 && sc.atLineEnd) {
if (HereDoc.State == 1 && sc.MatchLineEnd()) {
// Begin of here-doc (the line after the here-doc delimiter):
// Lexically, the here-doc starts from the next line after the >>, but the
// first line of here-doc seem to follow the style of the last EOL sequence
Expand Down
9 changes: 6 additions & 3 deletions lexilla/lexers/LexBatch.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,12 @@ void ColouriseBatchDoc(
Sci_PositionU wbo = 0; // Word Buffer Offset - also Special Keyword Buffer Length

// Check for Comment - return if found
if ((CompareCaseInsensitive(wordBuffer, "rem") == 0) && continueProcessing) {
styler.ColourTo(endPos, SCE_BAT_COMMENT);
break;
if (continueProcessing) {
if ((CompareCaseInsensitive(wordBuffer, "rem") == 0) || (wordBuffer[0] == ':' && wordBuffer[1] == ':')) {
styler.ColourTo(startLine + offset - strlen(wordBuffer) - 1, SCE_BAT_DEFAULT);
styler.ColourTo(endPos, SCE_BAT_COMMENT);
break;
}
}
// Check for Separator
if (IsBSeparator(wordBuffer[0])) {
Expand Down
57 changes: 32 additions & 25 deletions lexilla/lexers/LexHTML.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,13 @@ script_type segIsScriptingIndicator(Accessor &styler, Sci_PositionU start, Sci_P
char s[100];
GetTextSegment(styler, start, end, s, sizeof(s));
//Platform::DebugPrintf("Scripting indicator [%s]\n", s);
if (strstr(s, "src")) // External script
return eScriptNone;
if (strstr(s, "vbs"))
return eScriptVBS;
if (strstr(s, "pyth"))
return eScriptPython;
if (strstr(s, "javas"))
return eScriptJS;
if (strstr(s, "jscr"))
// https://html.spec.whatwg.org/multipage/scripting.html#attr-script-type
// https://mimesniff.spec.whatwg.org/#javascript-mime-type
if (strstr(s, "javas") || strstr(s, "ecmas") || strstr(s, "module") || strstr(s, "jscr"))
return eScriptJS;
if (strstr(s, "php"))
return eScriptPHP;
Expand Down Expand Up @@ -183,9 +181,8 @@ int stateForPrintState(int StateToPrint) {
return state;
}

inline bool IsNumber(Sci_PositionU start, Accessor &styler) {
return IsADigit(styler[start]) || (styler[start] == '.') ||
(styler[start] == '-') || (styler[start] == '#');
constexpr bool IsNumberChar(char ch) noexcept {
return IsADigit(ch) || ch == '.' || ch == '-' || ch == '#';
}

inline bool isStringState(int state) {
Expand Down Expand Up @@ -254,20 +251,27 @@ inline bool isCommentASPState(int state) {
return bResult;
}

void classifyAttribHTML(Sci_PositionU start, Sci_PositionU end, const WordList &keywords, Accessor &styler) {
const bool wordIsNumber = IsNumber(start, styler);
bool classifyAttribHTML(script_mode inScriptType, Sci_PositionU start, Sci_PositionU end, const WordList &keywords, Accessor &styler) {
char chAttr = SCE_H_ATTRIBUTEUNKNOWN;
if (wordIsNumber) {
bool isLanguageType = false;
if (IsNumberChar(styler[start])) {
chAttr = SCE_H_NUMBER;
} else {
std::string s = GetStringSegment(styler, start, end);
const std::string s = GetStringSegment(styler, start, end);
if (keywords.InList(s.c_str()))
chAttr = SCE_H_ATTRIBUTE;
if (inScriptType == eNonHtmlScript) {
// see https://html.spec.whatwg.org/multipage/scripting.html#script-processing-model
if (s == "type" || s == "language") {
isLanguageType = true;
}
}
}
if ((chAttr == SCE_H_ATTRIBUTEUNKNOWN) && !keywords)
// No keywords -> all are known
chAttr = SCE_H_ATTRIBUTE;
styler.ColourTo(end, chAttr);
return isLanguageType;
}

// https://html.spec.whatwg.org/multipage/custom-elements.html#custom-elements-core-concepts
Expand Down Expand Up @@ -1129,6 +1133,7 @@ void SCI_METHOD LexerHTML::Lex(Sci_PositionU startPos, Sci_Position length, int
script_type aspScript = static_cast<script_type>((lineState >> 4) & 0x0F); // 4 bits of script name
script_type clientScript = static_cast<script_type>((lineState >> 8) & 0x0F); // 4 bits of script name
int beforePreProc = (lineState >> 12) & 0xFF; // 8 bits of state
bool isLanguageType = (lineState >> 20) & 1; // type or language attribute for script tag

script_type scriptLanguage = ScriptOfState(state);
// If eNonHtmlScript coincides with SCE_H_COMMENT, assume eScriptComment
Expand Down Expand Up @@ -1210,7 +1215,9 @@ void SCI_METHOD LexerHTML::Lex(Sci_PositionU startPos, Sci_Position length, int
case eScriptPHP:
//not currently supported case eScriptVBS:

if ((state != SCE_HPHP_COMMENT) && (state != SCE_HPHP_COMMENTLINE) && (state != SCE_HJ_COMMENT) && (state != SCE_HJ_COMMENTLINE) && (state != SCE_HJ_COMMENTDOC) && (!isStringState(state))) {
if (!(state == SCE_HPHP_COMMENT || state == SCE_HPHP_COMMENTLINE) &&
!(state == SCE_HJ_REGEX || state == SCE_HJ_COMMENT || state == SCE_HJ_COMMENTLINE || state == SCE_HJ_COMMENTDOC) &&
!isStringState(state)) {
//Platform::DebugPrintf("state=%d, StateToPrint=%d, initStyle=%d\n", state, StateToPrint, initStyle);
//if ((state == SCE_HPHP_OPERATOR) || (state == SCE_HPHP_DEFAULT) || (state == SCE_HJ_SYMBOLS) || (state == SCE_HJ_START) || (state == SCE_HJ_DEFAULT)) {
if (ch == '#') {
Expand Down Expand Up @@ -1282,7 +1289,8 @@ void SCI_METHOD LexerHTML::Lex(Sci_PositionU startPos, Sci_Position length, int
((tagClosing ? 1 : 0) << 3) |
((aspScript & 0x0F) << 4) |
((clientScript & 0x0F) << 8) |
((beforePreProc & 0xFF) << 12));
((beforePreProc & 0xFF) << 12) |
((isLanguageType ? 1 : 0) << 20));
lineCurrent++;
lineStartVisibleChars = 0;
}
Expand Down Expand Up @@ -1355,6 +1363,7 @@ void SCI_METHOD LexerHTML::Lex(Sci_PositionU startPos, Sci_Position length, int
inScriptType = eHtml;
scriptLanguage = eScriptNone;
clientScript = eScriptJS;
isLanguageType = false;
i += 2;
visibleChars += 2;
tagClosing = true;
Expand Down Expand Up @@ -1880,6 +1889,7 @@ void SCI_METHOD LexerHTML::Lex(Sci_PositionU startPos, Sci_Position length, int
} else {
scriptLanguage = eScriptNone;
}
isLanguageType = false;
eClass = SCE_H_TAG;
}
if (ch == '>') {
Expand Down Expand Up @@ -1925,14 +1935,7 @@ void SCI_METHOD LexerHTML::Lex(Sci_PositionU startPos, Sci_Position length, int
break;
case SCE_H_ATTRIBUTE:
if (!setAttributeContinue.Contains(ch)) {
if (inScriptType == eNonHtmlScript) {
const int scriptLanguagePrev = scriptLanguage;
clientScript = segIsScriptingIndicator(styler, styler.GetStartSegment(), i - 1, scriptLanguage);
scriptLanguage = clientScript;
if ((scriptLanguagePrev != scriptLanguage) && (scriptLanguage == eScriptNone))
inScriptType = eHtml;
}
classifyAttribHTML(styler.GetStartSegment(), i - 1, keywords, styler);
isLanguageType = classifyAttribHTML(inScriptType, styler.GetStartSegment(), i - 1, keywords, styler);
if (ch == '>') {
styler.ColourTo(i, SCE_H_TAG);
if (inScriptType == eNonHtmlScript) {
Expand Down Expand Up @@ -2007,17 +2010,21 @@ void SCI_METHOD LexerHTML::Lex(Sci_PositionU startPos, Sci_Position length, int
break;
case SCE_H_DOUBLESTRING:
if (ch == '\"') {
if (inScriptType == eNonHtmlScript) {
if (isLanguageType) {
scriptLanguage = segIsScriptingIndicator(styler, styler.GetStartSegment(), i, scriptLanguage);
clientScript = scriptLanguage;
isLanguageType = false;
}
styler.ColourTo(i, SCE_H_DOUBLESTRING);
state = SCE_H_OTHER;
}
break;
case SCE_H_SINGLESTRING:
if (ch == '\'') {
if (inScriptType == eNonHtmlScript) {
if (isLanguageType) {
scriptLanguage = segIsScriptingIndicator(styler, styler.GetStartSegment(), i, scriptLanguage);
clientScript = scriptLanguage;
isLanguageType = false;
}
styler.ColourTo(i, SCE_H_SINGLESTRING);
state = SCE_H_OTHER;
Expand All @@ -2031,7 +2038,7 @@ void SCI_METHOD LexerHTML::Lex(Sci_PositionU startPos, Sci_Position length, int
} else if (ch == '\'' && chPrev == '=') {
state = SCE_H_SINGLESTRING;
} else {
if (IsNumber(styler.GetStartSegment(), styler)) {
if (IsNumberChar(styler[styler.GetStartSegment()])) {
styler.ColourTo(i - 1, SCE_H_NUMBER);
} else {
styler.ColourTo(i - 1, StateToPrint);
Expand Down
Loading

0 comments on commit d9ecb08

Please sign in to comment.