Permalink
Browse files

Merge branch 'scintilla-update'

  • Loading branch information...
b4n committed Oct 25, 2012
2 parents d7e285d + f7f47af commit 318b49ab782b2334ec0f33eb255f23b9a6be3239
View
3 NEWS
@@ -7,7 +7,8 @@ Geany 1.23 (unreleased)
* Fix too aggressive scope caching (#2142789, #2667917, #2868850).
Editor
- * Update Scintilla to version 3.2.2 (#2808638, #3540469).
+ * Update Scintilla to version 3.2.3 (#2808638, #2909124, #3094431,
+ #3233160, #3540469).
Search
* 'Mark All' now also uses the fully-featured PCRE engine (#3564132).
View
@@ -3,13 +3,20 @@
# Edit these in the colorscheme .conf file instead
default=default
comment=comment
+programmer_comment=comment_doc
+reference=comment
+flags=comment
+fuzzy=comment_doc_keyword
msgid=keyword_1
msgid_text=string_1
+msgid_text_eol=string_eol
msgstr=keyword_2
msgstr_text=string_1
+msgstr_text_eol=string_eol
msgctxt=keyword_3
msgctxt_text=string_1
-fuzzy=comment_doc_keyword
+msgctxt_text_eol=string_eol
+error=error
[settings]
# default extension used when saving files
View
@@ -30,6 +30,7 @@ lexers/LexOthers.cxx \
lexers/LexPascal.cxx \
lexers/LexPerl.cxx \
lexers/LexPython.cxx \
+lexers/LexPO.cxx \
lexers/LexR.cxx \
lexers/LexRuby.cxx \
lexers/LexSQL.cxx \
@@ -1213,6 +1213,10 @@ bool ScintillaGTK::ModifyScrollBars(int nMax, int nPage) {
modified = true;
}
#endif
+ if (modified && (paintState == painting)) {
+ paintState = paintAbandoned;
+ }
+
return modified;
}
@@ -1354,6 +1354,13 @@
#define SCE_PO_MSGCTXT 6
#define SCE_PO_MSGCTXT_TEXT 7
#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_IDENTIFIER 1
#define SCE_PAS_COMMENT 2
@@ -3924,6 +3924,13 @@ val SCE_PO_MSGSTR_TEXT=5
val SCE_PO_MSGCTXT=6
val SCE_PO_MSGCTXT_TEXT=7
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
lex Pascal=SCLEX_PASCAL SCE_PAS_
val SCE_PAS_DEFAULT=0
@@ -16,8 +16,8 @@ extern "C" {
#endif
#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 IS_SCINTILLA(obj) GTK_CHECK_TYPE (obj, scintilla_get_type ())
+#define SCINTILLA_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, scintilla_get_type (), ScintillaClass)
+#define IS_SCINTILLA(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, scintilla_get_type ())
typedef struct _ScintillaObject ScintillaObject;
typedef struct _ScintillaClass ScintillaClass;
@@ -2,7 +2,7 @@
/** @file LexBash.cxx
** 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
// The License.txt file describes the conditions under which this software may be distributed.
@@ -49,6 +49,17 @@ using namespace Scintilla;
#define BASH_CMD_ARITH 4
#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) {
if (ch >= '0' && ch <= '9') {
return ch - '0';
@@ -154,6 +165,60 @@ static void ColouriseBashDoc(unsigned int startPos, int length, int initStyle,
};
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 digit;
unsigned int endPos = startPos + length;
@@ -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
// of the previous line (i.e. start of a bash command segment)
int ln = styler.GetLine(startPos);
+ if (ln > 0 && startPos == static_cast<unsigned int>(styler.LineStart(ln)))
+ ln--;
for (;;) {
startPos = styler.LineStart(ln);
if (ln == 0 || styler.GetLineState(ln) == BASH_CMD_START)
@@ -376,7 +443,7 @@ static void ColouriseBashDoc(unsigned int startPos, int length, int initStyle,
sc.ForwardSetState(SCE_SH_DEFAULT);
} else if (sc.ch == '\\') {
// skip escape prefix
- } else {
+ } else if (!HereDoc.Quoted) {
sc.SetState(SCE_SH_DEFAULT);
}
if (HereDoc.DelimiterLength >= HERE_DELIM_MAX - 1) { // force blowup
@@ -401,8 +468,11 @@ static void ColouriseBashDoc(unsigned int startPos, int length, int initStyle,
}
char s[HERE_DELIM_MAX];
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;
+ }
if (s[strlen(s) - 1] == '\r')
s[strlen(s) - 1] = '\0';
if (strcmp(HereDoc.Delimiter, s) == 0) {
@@ -424,9 +494,56 @@ static void ColouriseBashDoc(unsigned int startPos, int length, int initStyle,
}
}
break;
- case SCE_SH_STRING: // delimited styles
+ case SCE_SH_STRING: // delimited styles, can nest
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 != '\\') {
sc.Forward();
} else if (sc.ch == Quote.Down) {
@@ -461,8 +578,14 @@ static void ColouriseBashDoc(unsigned int startPos, int length, int initStyle,
sc.ChangeState(SCE_SH_ERROR);
}
// 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
@@ -497,13 +620,13 @@ static void ColouriseBashDoc(unsigned int startPos, int length, int initStyle,
sc.SetState(SCE_SH_COMMENTLINE);
} else if (sc.ch == '\"') {
sc.SetState(SCE_SH_STRING);
- Quote.Start(sc.ch);
+ QuoteStack.Start(sc.ch, BASH_DELIM_STRING);
} else if (sc.ch == '\'') {
sc.SetState(SCE_SH_CHARACTER);
Quote.Start(sc.ch);
} else if (sc.ch == '`') {
sc.SetState(SCE_SH_BACKTICKS);
- Quote.Start(sc.ch);
+ QuoteStack.Start(sc.ch, BASH_DELIM_BACKTICK);
} else if (sc.ch == '$') {
if (sc.Match("$((")) {
sc.SetState(SCE_SH_OPERATOR); // handle '((' later
@@ -513,17 +636,22 @@ static void ColouriseBashDoc(unsigned int startPos, int length, int initStyle,
sc.Forward();
if (sc.ch == '{') {
sc.ChangeState(SCE_SH_PARAM);
+ Quote.Start(sc.ch);
} else if (sc.ch == '\'') {
sc.ChangeState(SCE_SH_STRING);
+ QuoteStack.Start(sc.ch, BASH_DELIM_CSTRING);
} else if (sc.ch == '"') {
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);
+ QuoteStack.Start(sc.ch, BASH_DELIM_BACKTICK);
} else {
continue; // scalar has no delimiter pair
}
- // fallthrough, open delim for $[{'"(`]
- Quote.Start(sc.ch);
} else if (sc.Match('<', '<')) {
sc.SetState(SCE_SH_HERE_DELIM);
HereDoc.State = 0;
@@ -597,6 +725,10 @@ static void ColouriseBashDoc(unsigned int startPos, int length, int initStyle,
}// sc.state
}
sc.Complete();
+ if (sc.state == SCE_SH_HERE_Q) {
+ styler.ChangeLexerState(sc.currentPos, styler.Length());
+ }
+ sc.Complete();
}
static bool IsCommentLine(int line, Accessor &styler) {
@@ -651,7 +783,7 @@ static void FoldBashDoc(unsigned int startPos, int length, int, WordList *[],
if (ch == '<' && chNext == '<') {
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--;
}
if (atEOL) {
@@ -467,6 +467,7 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle,
int styleBeforeDCKeyword = SCE_C_DEFAULT;
bool continuationLine = false;
bool isIncludePreprocessor = false;
+ bool isStringInPreprocessor = false;
int lineCurrent = styler.GetLine(startPos);
if ((MaskActive(initStyle) == SCE_C_PREPROCESSOR) ||
@@ -578,7 +579,9 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle,
break;
case SCE_C_NUMBER:
// 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);
}
break;
@@ -618,13 +621,17 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle,
sc.SetState(SCE_C_DEFAULT|activitySet);
}
break;
- case SCE_C_PREPROCESSOR:
+ case SCE_C_PREPROCESSOR:
if (options.stylingWithinPreprocessor) {
if (IsASpace(sc.ch)) {
sc.SetState(SCE_C_DEFAULT|activitySet);
}
- } else {
- if (sc.Match('/', '*')) {
+ } else if (isStringInPreprocessor && (sc.Match('>') || 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.Forward(); // Eat the *
} else if (sc.Match('/', '/')) {
Oops, something went wrong.

0 comments on commit 318b49a

Please sign in to comment.