Skip to content

Commit

Permalink
Update Scintilla to version 3.2.3
Browse files Browse the repository at this point in the history
Closes #2909124, #3094431 and #3233160.
  • Loading branch information
b4n committed Oct 25, 2012
1 parent d7e285d commit 4d16754
Show file tree
Hide file tree
Showing 18 changed files with 402 additions and 143 deletions.
4 changes: 4 additions & 0 deletions scintilla/gtk/ScintillaGTK.cxx
Expand Up @@ -1213,6 +1213,10 @@ bool ScintillaGTK::ModifyScrollBars(int nMax, int nPage) {
modified = true; modified = true;
} }
#endif #endif
if (modified && (paintState == painting)) {
paintState = paintAbandoned;
}

return modified; return modified;
} }


Expand Down
7 changes: 7 additions & 0 deletions scintilla/include/SciLexer.h
Expand Up @@ -1354,6 +1354,13 @@
#define SCE_PO_MSGCTXT 6 #define SCE_PO_MSGCTXT 6
#define SCE_PO_MSGCTXT_TEXT 7 #define SCE_PO_MSGCTXT_TEXT 7
#define SCE_PO_FUZZY 8 #define SCE_PO_FUZZY 8
#define SCE_PO_PROGRAMMER_COMMENT 9
#define SCE_PO_REFERENCE 10
#define SCE_PO_FLAGS 11
#define SCE_PO_MSGID_TEXT_EOL 12
#define SCE_PO_MSGSTR_TEXT_EOL 13
#define SCE_PO_MSGCTXT_TEXT_EOL 14
#define SCE_PO_ERROR 15
#define SCE_PAS_DEFAULT 0 #define SCE_PAS_DEFAULT 0
#define SCE_PAS_IDENTIFIER 1 #define SCE_PAS_IDENTIFIER 1
#define SCE_PAS_COMMENT 2 #define SCE_PAS_COMMENT 2
Expand Down
7 changes: 7 additions & 0 deletions scintilla/include/Scintilla.iface
Expand Up @@ -3924,6 +3924,13 @@ val SCE_PO_MSGSTR_TEXT=5
val SCE_PO_MSGCTXT=6 val SCE_PO_MSGCTXT=6
val SCE_PO_MSGCTXT_TEXT=7 val SCE_PO_MSGCTXT_TEXT=7
val SCE_PO_FUZZY=8 val SCE_PO_FUZZY=8
val SCE_PO_PROGRAMMER_COMMENT=9
val SCE_PO_REFERENCE=10
val SCE_PO_FLAGS=11
val SCE_PO_MSGID_TEXT_EOL=12
val SCE_PO_MSGSTR_TEXT_EOL=13
val SCE_PO_MSGCTXT_TEXT_EOL=14
val SCE_PO_ERROR=15
# Lexical states for SCLEX_PASCAL # Lexical states for SCLEX_PASCAL
lex Pascal=SCLEX_PASCAL SCE_PAS_ lex Pascal=SCLEX_PASCAL SCE_PAS_
val SCE_PAS_DEFAULT=0 val SCE_PAS_DEFAULT=0
Expand Down
4 changes: 2 additions & 2 deletions scintilla/include/ScintillaWidget.h
Expand Up @@ -16,8 +16,8 @@ extern "C" {
#endif #endif


#define SCINTILLA(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, scintilla_get_type (), ScintillaObject) #define SCINTILLA(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, scintilla_get_type (), ScintillaObject)
#define SCINTILLA_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, scintilla_get_type (), ScintillaClass) #define SCINTILLA_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, scintilla_get_type (), ScintillaClass)
#define IS_SCINTILLA(obj) GTK_CHECK_TYPE (obj, scintilla_get_type ()) #define IS_SCINTILLA(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, scintilla_get_type ())


typedef struct _ScintillaObject ScintillaObject; typedef struct _ScintillaObject ScintillaObject;
typedef struct _ScintillaClass ScintillaClass; typedef struct _ScintillaClass ScintillaClass;
Expand Down
156 changes: 144 additions & 12 deletions scintilla/lexers/LexBash.cxx
Expand Up @@ -2,7 +2,7 @@
/** @file LexBash.cxx /** @file LexBash.cxx
** Lexer for Bash. ** Lexer for Bash.
**/ **/
// Copyright 2004-2010 by Neil Hodgson <neilh@scintilla.org> // Copyright 2004-2012 by Neil Hodgson <neilh@scintilla.org>
// Adapted from LexPerl by Kein-Hong Man 2004 // Adapted from LexPerl by Kein-Hong Man 2004
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.


Expand Down Expand Up @@ -49,6 +49,17 @@ using namespace Scintilla;
#define BASH_CMD_ARITH 4 #define BASH_CMD_ARITH 4
#define BASH_CMD_DELIM 5 #define BASH_CMD_DELIM 5


// state constants for nested delimiter pairs, used by
// SCE_SH_STRING and SCE_SH_BACKTICKS processing
#define BASH_DELIM_LITERAL 0
#define BASH_DELIM_STRING 1
#define BASH_DELIM_CSTRING 2
#define BASH_DELIM_LSTRING 3
#define BASH_DELIM_COMMAND 4
#define BASH_DELIM_BACKTICK 5

#define BASH_DELIM_STACK_MAX 7

static inline int translateBashDigit(int ch) { static inline int translateBashDigit(int ch) {
if (ch >= '0' && ch <= '9') { if (ch >= '0' && ch <= '9') {
return ch - '0'; return ch - '0';
Expand Down Expand Up @@ -154,6 +165,60 @@ static void ColouriseBashDoc(unsigned int startPos, int length, int initStyle,
}; };
QuoteCls Quote; QuoteCls Quote;


class QuoteStackCls { // Class to manage quote pairs that nest
public:
int Count;
int Up, Down;
int Style;
int Depth; // levels pushed
int *CountStack;
int *UpStack;
int *StyleStack;
QuoteStackCls() {
Count = 0;
Up = '\0';
Down = '\0';
Style = 0;
Depth = 0;
CountStack = new int[BASH_DELIM_STACK_MAX];
UpStack = new int[BASH_DELIM_STACK_MAX];
StyleStack = new int[BASH_DELIM_STACK_MAX];
}
void Start(int u, int s) {
Count = 1;
Up = u;
Down = opposite(Up);
Style = s;
}
void Push(int u, int s) {
if (Depth >= BASH_DELIM_STACK_MAX)
return;
CountStack[Depth] = Count;
UpStack [Depth] = Up;
StyleStack[Depth] = Style;
Depth++;
Count = 1;
Up = u;
Down = opposite(Up);
Style = s;
}
void Pop(void) {
if (Depth <= 0)
return;
Depth--;
Count = CountStack[Depth];
Up = UpStack [Depth];
Style = StyleStack[Depth];
Down = opposite(Up);
}
~QuoteStackCls() {
delete []CountStack;
delete []UpStack;
delete []StyleStack;
}
};
QuoteStackCls QuoteStack;

int numBase = 0; int numBase = 0;
int digit; int digit;
unsigned int endPos = startPos + length; unsigned int endPos = startPos + length;
Expand All @@ -163,6 +228,8 @@ static void ColouriseBashDoc(unsigned int startPos, int length, int initStyle,
// Always backtracks to the start of a line that is not a continuation // Always backtracks to the start of a line that is not a continuation
// of the previous line (i.e. start of a bash command segment) // of the previous line (i.e. start of a bash command segment)
int ln = styler.GetLine(startPos); int ln = styler.GetLine(startPos);
if (ln > 0 && startPos == static_cast<unsigned int>(styler.LineStart(ln)))
ln--;
for (;;) { for (;;) {
startPos = styler.LineStart(ln); startPos = styler.LineStart(ln);
if (ln == 0 || styler.GetLineState(ln) == BASH_CMD_START) if (ln == 0 || styler.GetLineState(ln) == BASH_CMD_START)
Expand Down Expand Up @@ -376,7 +443,7 @@ static void ColouriseBashDoc(unsigned int startPos, int length, int initStyle,
sc.ForwardSetState(SCE_SH_DEFAULT); sc.ForwardSetState(SCE_SH_DEFAULT);
} else if (sc.ch == '\\') { } else if (sc.ch == '\\') {
// skip escape prefix // skip escape prefix
} else { } else if (!HereDoc.Quoted) {
sc.SetState(SCE_SH_DEFAULT); sc.SetState(SCE_SH_DEFAULT);
} }
if (HereDoc.DelimiterLength >= HERE_DELIM_MAX - 1) { // force blowup if (HereDoc.DelimiterLength >= HERE_DELIM_MAX - 1) { // force blowup
Expand All @@ -401,8 +468,11 @@ static void ColouriseBashDoc(unsigned int startPos, int length, int initStyle,
} }
char s[HERE_DELIM_MAX]; char s[HERE_DELIM_MAX];
sc.GetCurrent(s, sizeof(s)); sc.GetCurrent(s, sizeof(s));
if (sc.LengthCurrent() == 0) if (sc.LengthCurrent() == 0) { // '' or "" delimiters
if (prefixws == 0 && HereDoc.Quoted && HereDoc.DelimiterLength == 0)
sc.SetState(SCE_SH_DEFAULT);
break; break;
}
if (s[strlen(s) - 1] == '\r') if (s[strlen(s) - 1] == '\r')
s[strlen(s) - 1] = '\0'; s[strlen(s) - 1] = '\0';
if (strcmp(HereDoc.Delimiter, s) == 0) { if (strcmp(HereDoc.Delimiter, s) == 0) {
Expand All @@ -424,9 +494,56 @@ static void ColouriseBashDoc(unsigned int startPos, int length, int initStyle,
} }
} }
break; break;
case SCE_SH_STRING: // delimited styles case SCE_SH_STRING: // delimited styles, can nest
case SCE_SH_BACKTICKS: case SCE_SH_BACKTICKS:
case SCE_SH_PARAM: if (sc.ch == '\\' && QuoteStack.Up != '\\') {
if (QuoteStack.Style != BASH_DELIM_LITERAL)
sc.Forward();
} else if (sc.ch == QuoteStack.Down) {
QuoteStack.Count--;
if (QuoteStack.Count == 0) {
if (QuoteStack.Depth > 0) {
QuoteStack.Pop();
} else
sc.ForwardSetState(SCE_SH_DEFAULT);
}
} else if (sc.ch == QuoteStack.Up) {
QuoteStack.Count++;
} else {
if (QuoteStack.Style == BASH_DELIM_STRING ||
QuoteStack.Style == BASH_DELIM_LSTRING
) { // do nesting for "string", $"locale-string"
if (sc.ch == '`') {
QuoteStack.Push(sc.ch, BASH_DELIM_BACKTICK);
} else if (sc.ch == '$' && sc.chNext == '(') {
sc.Forward();
QuoteStack.Push(sc.ch, BASH_DELIM_COMMAND);
}
} else if (QuoteStack.Style == BASH_DELIM_COMMAND ||
QuoteStack.Style == BASH_DELIM_BACKTICK
) { // do nesting for $(command), `command`
if (sc.ch == '\'') {
QuoteStack.Push(sc.ch, BASH_DELIM_LITERAL);
} else if (sc.ch == '\"') {
QuoteStack.Push(sc.ch, BASH_DELIM_STRING);
} else if (sc.ch == '`') {
QuoteStack.Push(sc.ch, BASH_DELIM_BACKTICK);
} else if (sc.ch == '$') {
if (sc.chNext == '\'') {
sc.Forward();
QuoteStack.Push(sc.ch, BASH_DELIM_CSTRING);
} else if (sc.chNext == '\"') {
sc.Forward();
QuoteStack.Push(sc.ch, BASH_DELIM_LSTRING);
} else if (sc.chNext == '(') {
sc.Forward();
QuoteStack.Push(sc.ch, BASH_DELIM_COMMAND);
}
}
}
}
break;
case SCE_SH_PARAM: // ${parameter}
if (sc.ch == '\\' && Quote.Up != '\\') { if (sc.ch == '\\' && Quote.Up != '\\') {
sc.Forward(); sc.Forward();
} else if (sc.ch == Quote.Down) { } else if (sc.ch == Quote.Down) {
Expand Down Expand Up @@ -461,8 +578,14 @@ static void ColouriseBashDoc(unsigned int startPos, int length, int initStyle,
sc.ChangeState(SCE_SH_ERROR); sc.ChangeState(SCE_SH_ERROR);
} }
// HereDoc.Quote always == '\'' // HereDoc.Quote always == '\''
sc.SetState(SCE_SH_HERE_Q);
} else if (HereDoc.DelimiterLength == 0) {
// no delimiter, illegal (but '' and "" are legal)
sc.ChangeState(SCE_SH_ERROR);
sc.SetState(SCE_SH_DEFAULT);
} else {
sc.SetState(SCE_SH_HERE_Q);
} }
sc.SetState(SCE_SH_HERE_Q);
} }


// update cmdState about the current command segment // update cmdState about the current command segment
Expand Down Expand Up @@ -497,13 +620,13 @@ static void ColouriseBashDoc(unsigned int startPos, int length, int initStyle,
sc.SetState(SCE_SH_COMMENTLINE); sc.SetState(SCE_SH_COMMENTLINE);
} else if (sc.ch == '\"') { } else if (sc.ch == '\"') {
sc.SetState(SCE_SH_STRING); sc.SetState(SCE_SH_STRING);
Quote.Start(sc.ch); QuoteStack.Start(sc.ch, BASH_DELIM_STRING);
} else if (sc.ch == '\'') { } else if (sc.ch == '\'') {
sc.SetState(SCE_SH_CHARACTER); sc.SetState(SCE_SH_CHARACTER);
Quote.Start(sc.ch); Quote.Start(sc.ch);
} else if (sc.ch == '`') { } else if (sc.ch == '`') {
sc.SetState(SCE_SH_BACKTICKS); sc.SetState(SCE_SH_BACKTICKS);
Quote.Start(sc.ch); QuoteStack.Start(sc.ch, BASH_DELIM_BACKTICK);
} else if (sc.ch == '$') { } else if (sc.ch == '$') {
if (sc.Match("$((")) { if (sc.Match("$((")) {
sc.SetState(SCE_SH_OPERATOR); // handle '((' later sc.SetState(SCE_SH_OPERATOR); // handle '((' later
Expand All @@ -513,17 +636,22 @@ static void ColouriseBashDoc(unsigned int startPos, int length, int initStyle,
sc.Forward(); sc.Forward();
if (sc.ch == '{') { if (sc.ch == '{') {
sc.ChangeState(SCE_SH_PARAM); sc.ChangeState(SCE_SH_PARAM);
Quote.Start(sc.ch);
} else if (sc.ch == '\'') { } else if (sc.ch == '\'') {
sc.ChangeState(SCE_SH_STRING); sc.ChangeState(SCE_SH_STRING);
QuoteStack.Start(sc.ch, BASH_DELIM_CSTRING);
} else if (sc.ch == '"') { } else if (sc.ch == '"') {
sc.ChangeState(SCE_SH_STRING); sc.ChangeState(SCE_SH_STRING);
} else if (sc.ch == '(' || sc.ch == '`') { QuoteStack.Start(sc.ch, BASH_DELIM_LSTRING);
} else if (sc.ch == '(') {
sc.ChangeState(SCE_SH_BACKTICKS);
QuoteStack.Start(sc.ch, BASH_DELIM_COMMAND);
} else if (sc.ch == '`') { // $` seen in a configure script, valid?
sc.ChangeState(SCE_SH_BACKTICKS); sc.ChangeState(SCE_SH_BACKTICKS);
QuoteStack.Start(sc.ch, BASH_DELIM_BACKTICK);
} else { } else {
continue; // scalar has no delimiter pair continue; // scalar has no delimiter pair
} }
// fallthrough, open delim for $[{'"(`]
Quote.Start(sc.ch);
} else if (sc.Match('<', '<')) { } else if (sc.Match('<', '<')) {
sc.SetState(SCE_SH_HERE_DELIM); sc.SetState(SCE_SH_HERE_DELIM);
HereDoc.State = 0; HereDoc.State = 0;
Expand Down Expand Up @@ -597,6 +725,10 @@ static void ColouriseBashDoc(unsigned int startPos, int length, int initStyle,
}// sc.state }// sc.state
} }
sc.Complete(); sc.Complete();
if (sc.state == SCE_SH_HERE_Q) {
styler.ChangeLexerState(sc.currentPos, styler.Length());
}
sc.Complete();
} }


static bool IsCommentLine(int line, Accessor &styler) { static bool IsCommentLine(int line, Accessor &styler) {
Expand Down Expand Up @@ -651,7 +783,7 @@ static void FoldBashDoc(unsigned int startPos, int length, int, WordList *[],
if (ch == '<' && chNext == '<') { if (ch == '<' && chNext == '<') {
levelCurrent++; levelCurrent++;
} }
} else if (style == SCE_SH_HERE_Q && styler.StyleAt(i+1) == SCE_PL_DEFAULT) { } else if (style == SCE_SH_HERE_Q && styler.StyleAt(i+1) == SCE_SH_DEFAULT) {
levelCurrent--; levelCurrent--;
} }
if (atEOL) { if (atEOL) {
Expand Down
15 changes: 11 additions & 4 deletions scintilla/lexers/LexCPP.cxx
Expand Up @@ -467,6 +467,7 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle,
int styleBeforeDCKeyword = SCE_C_DEFAULT; int styleBeforeDCKeyword = SCE_C_DEFAULT;
bool continuationLine = false; bool continuationLine = false;
bool isIncludePreprocessor = false; bool isIncludePreprocessor = false;
bool isStringInPreprocessor = false;


int lineCurrent = styler.GetLine(startPos); int lineCurrent = styler.GetLine(startPos);
if ((MaskActive(initStyle) == SCE_C_PREPROCESSOR) || if ((MaskActive(initStyle) == SCE_C_PREPROCESSOR) ||
Expand Down Expand Up @@ -578,7 +579,9 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle,
break; break;
case SCE_C_NUMBER: case SCE_C_NUMBER:
// We accept almost anything because of hex. and number suffixes // We accept almost anything because of hex. and number suffixes
if (!(setWord.Contains(sc.ch) || ((sc.ch == '+' || sc.ch == '-') && (sc.chPrev == 'e' || sc.chPrev == 'E')))) { if (!(setWord.Contains(sc.ch)
|| ((sc.ch == '+' || sc.ch == '-') && (sc.chPrev == 'e' || sc.chPrev == 'E' ||
sc.chPrev == 'p' || sc.chPrev == 'P')))) {
sc.SetState(SCE_C_DEFAULT|activitySet); sc.SetState(SCE_C_DEFAULT|activitySet);
} }
break; break;
Expand Down Expand Up @@ -618,13 +621,17 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle,
sc.SetState(SCE_C_DEFAULT|activitySet); sc.SetState(SCE_C_DEFAULT|activitySet);
} }
break; break;
case SCE_C_PREPROCESSOR: case SCE_C_PREPROCESSOR:
if (options.stylingWithinPreprocessor) { if (options.stylingWithinPreprocessor) {
if (IsASpace(sc.ch)) { if (IsASpace(sc.ch)) {
sc.SetState(SCE_C_DEFAULT|activitySet); sc.SetState(SCE_C_DEFAULT|activitySet);
} }
} else { } else if (isStringInPreprocessor && (sc.Match('>') || sc.Match('\"'))) {
if (sc.Match('/', '*')) { isStringInPreprocessor = false;
} else if (!isStringInPreprocessor) {
if ((isIncludePreprocessor && sc.Match('<')) || sc.Match('\"')) {
isStringInPreprocessor = true;
} else if (sc.Match('/', '*')) {
sc.SetState(SCE_C_PREPROCESSORCOMMENT|activitySet); sc.SetState(SCE_C_PREPROCESSORCOMMENT|activitySet);
sc.Forward(); // Eat the * sc.Forward(); // Eat the *
} else if (sc.Match('/', '/')) { } else if (sc.Match('/', '/')) {
Expand Down

0 comments on commit 4d16754

Please sign in to comment.