[geany/geany] 8ac86c: Update Scintilla to version 3.5.4
Colomban Wendling
git-noreply at xxxxx
Sun Mar 8 13:30:34 UTC 2015
Branch: refs/heads/master
Author: Colomban Wendling <ban at herbesfolles.org>
Committer: Colomban Wendling <ban at herbesfolles.org>
Date: Sun, 08 Mar 2015 13:30:34 UTC
Commit: 8ac86ce42377ee99eacd91ab8737347c0badb12e
https://github.com/geany/geany/commit/8ac86ce42377ee99eacd91ab8737347c0badb12e
Log Message:
-----------
Update Scintilla to version 3.5.4
Modified Paths:
--------------
scintilla/gtk/ScintillaGTK.cxx
scintilla/include/Scintilla.h
scintilla/include/Scintilla.iface
scintilla/lexers/LexCPP.cxx
scintilla/lexers/LexRuby.cxx
scintilla/lexers/LexRust.cxx
scintilla/lexers/LexSQL.cxx
scintilla/lexers/LexTCL.cxx
scintilla/lexers/LexVHDL.cxx
scintilla/lexers/LexVerilog.cxx
scintilla/src/CellBuffer.cxx
scintilla/src/Document.cxx
scintilla/src/Document.h
scintilla/src/EditModel.cxx
scintilla/src/EditModel.h
scintilla/src/EditView.cxx
scintilla/src/Editor.cxx
scintilla/src/Editor.h
scintilla/src/Indicator.cxx
scintilla/src/Indicator.h
scintilla/src/PositionCache.cxx
scintilla/src/PositionCache.h
scintilla/src/RESearch.cxx
scintilla/src/ScintillaBase.cxx
scintilla/src/UniConversion.cxx
scintilla/src/UniConversion.h
scintilla/src/ViewStyle.cxx
scintilla/src/ViewStyle.h
scintilla/version.txt
Modified: scintilla/gtk/ScintillaGTK.cxx
8 lines changed, 5 insertions(+), 3 deletions(-)
===================================================================
@@ -305,8 +305,8 @@ class ScintillaGTK : public ScintillaBase {
static void PreeditChanged(GtkIMContext *context, ScintillaGTK *sciThis);
void MoveImeCarets(int pos);
void DrawImeIndicator(int indicator, int len);
- void GetImeUnderlines(PangoAttrList *attrs, bool *normalInput);
- void GetImeBackgrounds(PangoAttrList *attrs, bool *targetInput);
+ static void GetImeUnderlines(PangoAttrList *attrs, bool *normalInput);
+ static void GetImeBackgrounds(PangoAttrList *attrs, bool *targetInput);
void SetCandidateWindowPos();
static void StyleSetText(GtkWidget *widget, GtkStyle *previous, void*);
@@ -811,8 +811,10 @@ void ScintillaGTK::Initialise() {
if (gtk_check_version(3,9,2) != NULL /* on < 3.9.2 */)
#endif
{
+#if !GTK_CHECK_VERSION(3,14,0)
// Avoid background drawing flash/missing redraws
gtk_widget_set_double_buffered(widtxt, FALSE);
+#endif
}
gtk_widget_set_events(widtxt, GDK_EXPOSURE_MASK);
gtk_widget_set_size_request(widtxt, 100, 100);
@@ -1670,7 +1672,7 @@ void ScintillaGTK::ReceivedDrop(GtkSelectionData *selection_data) {
drop.push_back('\0');
NotifyURIDropped(&drop[0]);
} else if ((TypeOfGSD(selection_data) == GDK_TARGET_STRING) || (TypeOfGSD(selection_data) == atomUTF8)) {
- if (TypeOfGSD(selection_data) > 0) {
+ if (LengthOfGSD(selection_data) > 0) {
SelectionText selText;
GetGtkSelectionText(selection_data, selText);
DropAt(posDrop, selText.Data(), selText.Length(), false, selText.rectangular);
Modified: scintilla/include/Scintilla.h
14 lines changed, 14 insertions(+), 0 deletions(-)
===================================================================
@@ -274,6 +274,9 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define INDIC_DOTBOX 12
#define INDIC_SQUIGGLEPIXMAP 13
#define INDIC_COMPOSITIONTHICK 14
+#define INDIC_COMPOSITIONTHIN 15
+#define INDIC_FULLBOX 16
+#define INDIC_TEXTFORE 17
#define INDIC_IME 32
#define INDIC_IME_MAX 35
#define INDIC_MAX 35
@@ -288,6 +291,15 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SCI_INDICGETFORE 2083
#define SCI_INDICSETUNDER 2510
#define SCI_INDICGETUNDER 2511
+#define SCI_INDICSETHOVERSTYLE 2680
+#define SCI_INDICGETHOVERSTYLE 2681
+#define SCI_INDICSETHOVERFORE 2682
+#define SCI_INDICGETHOVERFORE 2683
+#define SC_INDICVALUEBIT 0x1000000
+#define SC_INDICVALUEMASK 0xFFFFFF
+#define SC_INDICFLAG_VALUEFORE 1
+#define SCI_INDICSETFLAGS 2684
+#define SCI_INDICGETFLAGS 2685
#define SCI_SETWHITESPACEFORE 2084
#define SCI_SETWHITESPACEBACK 2085
#define SCI_SETWHITESPACESIZE 2086
@@ -420,6 +432,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SCI_GETTARGETSTART 2191
#define SCI_SETTARGETEND 2192
#define SCI_GETTARGETEND 2193
+#define SCI_SETTARGETRANGE 2686
+#define SCI_GETTARGETTEXT 2687
#define SCI_REPLACETARGET 2194
#define SCI_REPLACETARGETRE 2195
#define SCI_SEARCHINTARGET 2197
Modified: scintilla/include/Scintilla.iface
33 lines changed, 33 insertions(+), 0 deletions(-)
===================================================================
@@ -605,6 +605,9 @@ val INDIC_SQUIGGLELOW=11
val INDIC_DOTBOX=12
val INDIC_SQUIGGLEPIXMAP=13
val INDIC_COMPOSITIONTHICK=14
+val INDIC_COMPOSITIONTHIN=15
+val INDIC_FULLBOX=16
+val INDIC_TEXTFORE=17
val INDIC_IME=32
val INDIC_IME_MAX=35
val INDIC_MAX=35
@@ -632,6 +635,30 @@ set void IndicSetUnder=2510(int indic, bool under)
# Retrieve whether indicator drawn under or over text.
get bool IndicGetUnder=2511(int indic,)
+# Set a hover indicator to plain, squiggle or TT.
+set void IndicSetHoverStyle=2680(int indic, int style)
+
+# Retrieve the hover style of an indicator.
+get int IndicGetHoverStyle=2681(int indic,)
+
+# Set the foreground hover colour of an indicator.
+set void IndicSetHoverFore=2682(int indic, colour fore)
+
+# Retrieve the foreground hover colour of an indicator.
+get colour IndicGetHoverFore=2683(int indic,)
+
+val SC_INDICVALUEBIT=0x1000000
+val SC_INDICVALUEMASK=0xFFFFFF
+
+enu IndicFlag=SC_INDICFLAG_
+val SC_INDICFLAG_VALUEFORE=1
+
+# Set the attributes of an indicator.
+set void IndicSetFlags=2684(int indic, int flags)
+
+# Retrieve the attributes of an indicator.
+get int IndicGetFlags=2685(int indic,)
+
# Set the foreground colour of all whitespace and whether to use this setting.
fun void SetWhitespaceFore=2084(bool useSetting, colour fore)
@@ -1032,6 +1059,12 @@ set void SetTargetEnd=2192(position pos,)
# Get the position that ends the target.
get position GetTargetEnd=2193(,)
+# Sets both the start and end of the target in one call.
+fun void SetTargetRange=2686(position start, position end)
+
+# Retrieve the text in the target.
+get int GetTargetText=2687(, stringresult characters)
+
# Replace the target text with the argument text.
# Text is counted so it can contain NULs.
# Returns the length of the replacement text.
Modified: scintilla/lexers/LexCPP.cxx
9 lines changed, 8 insertions(+), 1 deletions(-)
===================================================================
@@ -306,6 +306,7 @@ struct OptionsCPP {
bool identifiersAllowDollars;
bool trackPreprocessor;
bool updatePreprocessor;
+ bool verbatimStringsAllowEscapes;
bool triplequotedStrings;
bool hashquotedStrings;
bool backQuotedStrings;
@@ -326,6 +327,7 @@ struct OptionsCPP {
identifiersAllowDollars = true;
trackPreprocessor = true;
updatePreprocessor = true;
+ verbatimStringsAllowEscapes = false;
triplequotedStrings = false;
hashquotedStrings = false;
backQuotedStrings = false;
@@ -370,6 +372,9 @@ struct OptionSetCPP : public OptionSet<OptionsCPP> {
DefineProperty("lexer.cpp.update.preprocessor", &OptionsCPP::updatePreprocessor,
"Set to 1 to update preprocessor definitions when #define found.");
+ DefineProperty("lexer.cpp.verbatim.strings.allow.escapes", &OptionsCPP::verbatimStringsAllowEscapes,
+ "Set to 1 to allow verbatim strings to contain escape sequences.");
+
DefineProperty("lexer.cpp.triplequoted.strings", &OptionsCPP::triplequotedStrings,
"Set to 1 to enable highlighting of triple-quoted strings.");
@@ -1036,7 +1041,9 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle,
}
break;
case SCE_C_VERBATIM:
- if (sc.ch == '\"') {
+ if (options.verbatimStringsAllowEscapes && (sc.ch == '\\')) {
+ sc.Forward(); // Skip all characters after the backslash
+ } else if (sc.ch == '\"') {
if (sc.chNext == '\"') {
sc.Forward();
} else {
Modified: scintilla/lexers/LexRuby.cxx
805 lines changed, 415 insertions(+), 390 deletions(-)
===================================================================
@@ -29,7 +29,7 @@ using namespace Scintilla;
//XXX Identical to Perl, put in common area
static inline bool isEOLChar(char ch) {
- return (ch == '\r') || (ch == '\n');
+ return (ch == '\r') || (ch == '\n');
}
#define isSafeASCII(ch) ((unsigned int)(ch) <= 127)
@@ -60,7 +60,7 @@ static inline bool isSafeWordcharOrHigh(char ch) {
}
static bool inline iswhitespace(char ch) {
- return ch == ' ' || ch == '\t';
+ return ch == ' ' || ch == '\t';
}
#define MAX_KEYWORD_LENGTH 200
@@ -74,20 +74,20 @@ static bool followsDot(unsigned int pos, Accessor &styler) {
int style = actual_style(styler.StyleAt(pos));
char ch;
switch (style) {
- case SCE_RB_DEFAULT:
- ch = styler[pos];
- if (ch == ' ' || ch == '\t') {
- //continue
- } else {
- return false;
- }
- break;
+ case SCE_RB_DEFAULT:
+ ch = styler[pos];
+ if (ch == ' ' || ch == '\t') {
+ //continue
+ } else {
+ return false;
+ }
+ break;
- case SCE_RB_OPERATOR:
- return styler[pos] == '.';
+ case SCE_RB_OPERATOR:
+ return styler[pos] == '.';
- default:
- return false;
+ default:
+ return false;
}
}
return false;
@@ -102,26 +102,26 @@ static bool keywordIsModifier(const char *word,
Accessor &styler);
static int ClassifyWordRb(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler, char *prevWord) {
- char s[MAX_KEYWORD_LENGTH];
+ char s[MAX_KEYWORD_LENGTH];
unsigned int i, j;
- unsigned int lim = end - start + 1; // num chars to copy
- if (lim >= MAX_KEYWORD_LENGTH) {
- lim = MAX_KEYWORD_LENGTH - 1;
- }
- for (i = start, j = 0; j < lim; i++, j++) {
- s[j] = styler[i];
- }
+ unsigned int lim = end - start + 1; // num chars to copy
+ if (lim >= MAX_KEYWORD_LENGTH) {
+ lim = MAX_KEYWORD_LENGTH - 1;
+ }
+ for (i = start, j = 0; j < lim; i++, j++) {
+ s[j] = styler[i];
+ }
s[j] = '\0';
- int chAttr;
- if (0 == strcmp(prevWord, "class"))
- chAttr = SCE_RB_CLASSNAME;
- else if (0 == strcmp(prevWord, "module"))
- chAttr = SCE_RB_MODULE_NAME;
- else if (0 == strcmp(prevWord, "def"))
- chAttr = SCE_RB_DEFNAME;
+ int chAttr;
+ if (0 == strcmp(prevWord, "class"))
+ chAttr = SCE_RB_CLASSNAME;
+ else if (0 == strcmp(prevWord, "module"))
+ chAttr = SCE_RB_MODULE_NAME;
+ else if (0 == strcmp(prevWord, "def"))
+ chAttr = SCE_RB_DEFNAME;
else if (keywords.InList(s) && ((start == 0) || !followsDot(start - 1, styler))) {
if (keywordIsAmbiguous(s)
- && keywordIsModifier(s, start, styler)) {
+ && keywordIsModifier(s, start, styler)) {
// Demoted keywords are colored as keywords,
// but do not affect changes in indentation.
@@ -136,37 +136,37 @@ static int ClassifyWordRb(unsigned int start, unsigned int end, WordList &keywor
} else {
chAttr = SCE_RB_WORD;
}
- } else
+ } else
chAttr = SCE_RB_IDENTIFIER;
- styler.ColourTo(end, chAttr);
- if (chAttr == SCE_RB_WORD) {
- strcpy(prevWord, s);
- } else {
- prevWord[0] = 0;
- }
+ styler.ColourTo(end, chAttr);
+ if (chAttr == SCE_RB_WORD) {
+ strcpy(prevWord, s);
+ } else {
+ prevWord[0] = 0;
+ }
return chAttr;
}
//XXX Identical to Perl, put in common area
static bool isMatch(Accessor &styler, int lengthDoc, int pos, const char *val) {
- if ((pos + static_cast<int>(strlen(val))) >= lengthDoc) {
- return false;
- }
- while (*val) {
- if (*val != styler[pos++]) {
- return false;
- }
- val++;
- }
- return true;
+ if ((pos + static_cast<int>(strlen(val))) >= lengthDoc) {
+ return false;
+ }
+ while (*val) {
+ if (*val != styler[pos++]) {
+ return false;
+ }
+ val++;
+ }
+ return true;
}
// Do Ruby better -- find the end of the line, work back,
// and then check for leading white space
// Precondition: the here-doc target can be indented
-static bool lookingAtHereDocDelim(Accessor &styler,
+static bool lookingAtHereDocDelim(Accessor &styler,
int pos,
int lengthDoc,
const char *HereDocDelim)
@@ -187,15 +187,15 @@ static bool lookingAtHereDocDelim(Accessor &styler,
//XXX Identical to Perl, put in common area
static char opposite(char ch) {
- if (ch == '(')
- return ')';
- if (ch == '[')
- return ']';
- if (ch == '{')
- return '}';
- if (ch == '<')
- return '>';
- return ch;
+ if (ch == '(')
+ return ')';
+ if (ch == '[')
+ return ']';
+ if (ch == '{')
+ return '}';
+ if (ch == '<')
+ return '>';
+ return ch;
}
// Null transitions when we see we've reached the end
@@ -216,7 +216,7 @@ static void advance_char(int &i, char &ch, char &chNext, char &chNext2) {
}
// precondition: startPos points to one after the EOL char
-static bool currLineContainsHereDelims(int& startPos,
+static bool currLineContainsHereDelims(int &startPos,
Accessor &styler) {
if (startPos <= 1)
return false;
@@ -249,7 +249,7 @@ static bool currLineContainsHereDelims(int& startPos,
// to be hoisted out of the function.
class QuoteCls {
- public:
+public:
int Count;
char Up;
char Down;
@@ -266,19 +266,19 @@ class QuoteCls {
Up = u;
Down = opposite(Up);
}
- QuoteCls(const QuoteCls& q) {
+ QuoteCls(const QuoteCls &q) {
// copy constructor -- use this for copying in
Count = q.Count;
Up = q.Up;
Down = q.Down;
}
- QuoteCls& operator=(const QuoteCls& q) { // assignment constructor
+ QuoteCls &operator=(const QuoteCls &q) { // assignment constructor
if (this != &q) {
Count = q.Count;
Up = q.Up;
Down = q.Down;
}
- return *this;
+ return *this;
}
};
@@ -287,11 +287,11 @@ class QuoteCls {
static void enterInnerExpression(int *p_inner_string_types,
int *p_inner_expn_brace_counts,
QuoteCls *p_inner_quotes,
- int& inner_string_count,
- int& state,
- int& brace_counts,
+ int &inner_string_count,
+ int &state,
+ int &brace_counts,
QuoteCls curr_quote
- ) {
+ ) {
p_inner_string_types[inner_string_count] = state;
state = SCE_RB_DEFAULT;
p_inner_expn_brace_counts[inner_string_count] = brace_counts;
@@ -301,13 +301,13 @@ static void enterInnerExpression(int *p_inner_string_types,
}
static void exitInnerExpression(int *p_inner_string_types,
- int *p_inner_expn_brace_counts,
- QuoteCls *p_inner_quotes,
- int& inner_string_count,
- int& state,
- int& brace_counts,
- QuoteCls& curr_quote
- ) {
+ int *p_inner_expn_brace_counts,
+ QuoteCls *p_inner_quotes,
+ int &inner_string_count,
+ int &state,
+ int &brace_counts,
+ QuoteCls &curr_quote
+ ) {
--inner_string_count;
state = p_inner_string_types[inner_string_count];
brace_counts = p_inner_expn_brace_counts[inner_string_count];
@@ -316,28 +316,28 @@ static void exitInnerExpression(int *p_inner_string_types,
static bool isEmptyLine(int pos,
Accessor &styler) {
- int spaceFlags = 0;
- int lineCurrent = styler.GetLine(pos);
- int indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, NULL);
+ int spaceFlags = 0;
+ int lineCurrent = styler.GetLine(pos);
+ int indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, NULL);
return (indentCurrent & SC_FOLDLEVELWHITEFLAG) != 0;
}
static bool RE_CanFollowKeyword(const char *keyword) {
if (!strcmp(keyword, "and")
- || !strcmp(keyword, "begin")
- || !strcmp(keyword, "break")
- || !strcmp(keyword, "case")
- || !strcmp(keyword, "do")
- || !strcmp(keyword, "else")
- || !strcmp(keyword, "elsif")
- || !strcmp(keyword, "if")
- || !strcmp(keyword, "next")
- || !strcmp(keyword, "return")
- || !strcmp(keyword, "when")
- || !strcmp(keyword, "unless")
- || !strcmp(keyword, "until")
- || !strcmp(keyword, "not")
- || !strcmp(keyword, "or")) {
+ || !strcmp(keyword, "begin")
+ || !strcmp(keyword, "break")
+ || !strcmp(keyword, "case")
+ || !strcmp(keyword, "do")
+ || !strcmp(keyword, "else")
+ || !strcmp(keyword, "elsif")
+ || !strcmp(keyword, "if")
+ || !strcmp(keyword, "next")
+ || !strcmp(keyword, "return")
+ || !strcmp(keyword, "when")
+ || !strcmp(keyword, "unless")
+ || !strcmp(keyword, "until")
+ || !strcmp(keyword, "not")
+ || !strcmp(keyword, "or")) {
return true;
}
return false;
@@ -347,8 +347,8 @@ static bool RE_CanFollowKeyword(const char *keyword) {
// Don't look at styles in case we're looking forward
static int skipWhitespace(int startPos,
- int endPos,
- Accessor &styler) {
+ int endPos,
+ Accessor &styler) {
for (int i = startPos; i < endPos; i++) {
if (!iswhitespace(styler[i])) {
return i;
@@ -378,8 +378,8 @@ static bool sureThisIsHeredoc(int iPrev,
int firstWordPosn = skipWhitespace(lineStartPosn, iPrev, styler);
if (firstWordPosn >= iPrev) {
// Have something like {^ <<}
- //XXX Look at the first previous non-comment non-white line
- // to establish the context. Not too likely though.
+ //XXX Look at the first previous non-comment non-white line
+ // to establish the context. Not too likely though.
return true;
} else {
switch (prevStyle = styler.StyleAt(firstWordPosn)) {
@@ -395,7 +395,7 @@ static bool sureThisIsHeredoc(int iPrev,
char *dst = prevWord;
for (;;) {
if (firstWordEndPosn >= iPrev ||
- styler.StyleAt(firstWordEndPosn) != prevStyle) {
+ styler.StyleAt(firstWordEndPosn) != prevStyle) {
*dst = 0;
break;
}
@@ -404,8 +404,8 @@ static bool sureThisIsHeredoc(int iPrev,
}
//XXX Write a style-aware thing to regex scintilla buffer objects
if (!strcmp(prevWord, "undef")
- || !strcmp(prevWord, "def")
- || !strcmp(prevWord, "alias")) {
+ || !strcmp(prevWord, "def")
+ || !strcmp(prevWord, "alias")) {
// These keywords are what we were looking for
return false;
}
@@ -424,8 +424,8 @@ static bool haveTargetMatch(int currPos,
}
int i, j;
for (i = targetStartPos, j = currPos;
- i < targetEndPos && j < lengthDoc;
- i++, j++) {
+ i < targetEndPos && j < lengthDoc;
+ i++, j++) {
if (styler[i] != styler[j]) {
return false;
}
@@ -450,7 +450,7 @@ static bool haveTargetMatch(int currPos,
static bool sureThisIsNotHeredoc(int lt2StartPos,
Accessor &styler) {
int prevStyle;
- // Use full document, not just part we're styling
+ // Use full document, not just part we're styling
int lengthDoc = styler.Length();
int lineStart = styler.GetLine(lt2StartPos);
int lineStartPosn = styler.LineStart(lineStart);
@@ -466,8 +466,8 @@ static bool sureThisIsNotHeredoc(int lt2StartPos,
prevStyle = styler.StyleAt(firstWordPosn);
// If we have '<<' following a keyword, it's not a heredoc
if (prevStyle != SCE_RB_IDENTIFIER
- && prevStyle != SCE_RB_INSTANCE_VAR
- && prevStyle != SCE_RB_CLASS_VAR) {
+ && prevStyle != SCE_RB_INSTANCE_VAR
+ && prevStyle != SCE_RB_CLASS_VAR) {
return definitely_not_a_here_doc;
}
int newStyle = prevStyle;
@@ -508,7 +508,7 @@ static bool sureThisIsNotHeredoc(int lt2StartPos,
return definitely_not_a_here_doc;
}
// OK, now 'j' will point to the current spot moving ahead
- int j = firstWordPosn + 1;
+ int j = firstWordPosn + 1;
if (styler.StyleAt(j) != SCE_RB_OPERATOR || styler[j] != '<') {
// This shouldn't happen
return definitely_not_a_here_doc;
@@ -560,10 +560,10 @@ static bool sureThisIsNotHeredoc(int lt2StartPos,
// don't handle arbitrary expressions yet
target_end = j;
- if (target_quote) {
- // Now we can move to the character after the string delimiter.
- j += 1;
- }
+ if (target_quote) {
+ // Now we can move to the character after the string delimiter.
+ j += 1;
+ }
j = skipWhitespace(j, lengthDoc, styler);
if (j >= lengthDoc) {
return definitely_not_a_here_doc;
@@ -604,7 +604,7 @@ static bool sureThisIsNotHeredoc(int lt2StartPos,
// move to the start of the first line that is not in a
// multi-line construct
-static void synchronizeDocStart(unsigned int& startPos,
+static void synchronizeDocStart(unsigned int &startPos,
int &length,
int &initStyle,
Accessor &styler,
@@ -613,11 +613,11 @@ static void synchronizeDocStart(unsigned int& startPos,
styler.Flush();
int style = actual_style(styler.StyleAt(startPos));
switch (style) {
- case SCE_RB_STDIN:
- case SCE_RB_STDOUT:
- case SCE_RB_STDERR:
- // Don't do anything else with these.
- return;
+ case SCE_RB_STDIN:
+ case SCE_RB_STDOUT:
+ case SCE_RB_STDERR:
+ // Don't do anything else with these.
+ return;
}
int pos = startPos;
@@ -655,66 +655,67 @@ static void synchronizeDocStart(unsigned int& startPos,
}
static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle,
- WordList *keywordlists[], Accessor &styler) {
+ WordList *keywordlists[], Accessor &styler) {
- // Lexer for Ruby often has to backtrack to start of current style to determine
- // which characters are being used as quotes, how deeply nested is the
- // start position and what the termination string is for here documents
+ // Lexer for Ruby often has to backtrack to start of current style to determine
+ // which characters are being used as quotes, how deeply nested is the
+ // start position and what the termination string is for here documents
- WordList &keywords = *keywordlists[0];
+ WordList &keywords = *keywordlists[0];
- class HereDocCls {
- public:
- int State;
+ class HereDocCls {
+ public:
+ int State;
// States
// 0: '<<' encountered
- // 1: collect the delimiter
+ // 1: collect the delimiter
// 1b: text between the end of the delimiter and the EOL
- // 2: here doc text (lines after the delimiter)
- char Quote; // the char after '<<'
- bool Quoted; // true if Quote in ('\'','"','`')
- int DelimiterLength; // strlen(Delimiter)
- char Delimiter[256]; // the Delimiter, limit of 256: from Perl
+ // 2: here doc text (lines after the delimiter)
+ char Quote; // the char after '<<'
+ bool Quoted; // true if Quote in ('\'','"','`')
+ int DelimiterLength; // strlen(Delimiter)
+ char Delimiter[256]; // the Delimiter, limit of 256: from Perl
bool CanBeIndented;
- HereDocCls() {
- State = 0;
- DelimiterLength = 0;
- Delimiter[0] = '\0';
+ HereDocCls() {
+ State = 0;
+ DelimiterLength = 0;
+ Delimiter[0] = '\0';
CanBeIndented = false;
- }
- };
- HereDocCls HereDoc;
+ }
+ };
+ HereDocCls HereDoc;
- QuoteCls Quote;
+ QuoteCls Quote;
int numDots = 0; // For numbers --
- // Don't start lexing in the middle of a num
+ // Don't start lexing in the middle of a num
synchronizeDocStart(startPos, length, initStyle, styler, // ref args
false);
- bool preferRE = true;
+ bool preferRE = true;
int state = initStyle;
- int lengthDoc = startPos + length;
+ int lengthDoc = startPos + length;
- char prevWord[MAX_KEYWORD_LENGTH + 1]; // 1 byte for zero
- prevWord[0] = '\0';
- if (length == 0)
- return;
+ char prevWord[MAX_KEYWORD_LENGTH + 1]; // 1 byte for zero
+ prevWord[0] = '\0';
+ if (length == 0)
+ return;
- char chPrev = styler.SafeGetCharAt(startPos - 1);
- char chNext = styler.SafeGetCharAt(startPos);
- bool is_real_number = true; // Differentiate between constants and ?-sequences.
- styler.StartAt(startPos);
- styler.StartSegment(startPos);
+ char chPrev = styler.SafeGetCharAt(startPos - 1);
+ char chNext = styler.SafeGetCharAt(startPos);
+ bool is_real_number = true; // Differentiate between constants and ?-sequences.
+ styler.StartAt(startPos);
+ styler.StartSegment(startPos);
static int q_states[] = {SCE_RB_STRING_Q,
SCE_RB_STRING_QQ,
SCE_RB_STRING_QR,
SCE_RB_STRING_QW,
SCE_RB_STRING_QW,
- SCE_RB_STRING_QX};
- static const char* q_chars = "qQrwWx";
+ SCE_RB_STRING_QX
+ };
+ static const char *q_chars = "qQrwWx";
// In most cases a value of 2 should be ample for the code in the
// Ruby library, and the code the user is likely to enter.
@@ -743,113 +744,113 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle,
int brace_counts = 0; // Number of #{ ... } things within an expression
int i;
- for (i = 0; i < INNER_STRINGS_MAX_COUNT; i++) {
+ for (i = 0; i < INNER_STRINGS_MAX_COUNT; i++) {
inner_string_types[i] = 0;
inner_expn_brace_counts[i] = 0;
}
- for (i = startPos; i < lengthDoc; i++) {
- char ch = chNext;
- chNext = styler.SafeGetCharAt(i + 1);
- char chNext2 = styler.SafeGetCharAt(i + 2);
+ for (i = startPos; i < lengthDoc; i++) {
+ char ch = chNext;
+ chNext = styler.SafeGetCharAt(i + 1);
+ char chNext2 = styler.SafeGetCharAt(i + 2);
if (styler.IsLeadByte(ch)) {
- chNext = chNext2;
- chPrev = ' ';
- i += 1;
- continue;
- }
+ chNext = chNext2;
+ chPrev = ' ';
+ i += 1;
+ continue;
+ }
// skip on DOS/Windows
//No, don't, because some things will get tagged on,
// so we won't recognize keywords, for example
#if 0
- if (ch == '\r' && chNext == '\n') {
- continue;
+ if (ch == '\r' && chNext == '\n') {
+ continue;
}
#endif
if (HereDoc.State == 1 && isEOLChar(ch)) {
- // Begin of here-doc (the line after the here-doc delimiter):
- HereDoc.State = 2;
- styler.ColourTo(i-1, state);
+ // Begin of here-doc (the line after the here-doc delimiter):
+ HereDoc.State = 2;
+ styler.ColourTo(i-1, state);
// Don't check for a missing quote, just jump into
// the here-doc state
state = SCE_RB_HERE_Q;
}
// Regular transitions
- if (state == SCE_RB_DEFAULT) {
+ if (state == SCE_RB_DEFAULT) {
if (isSafeDigit(ch)) {
- styler.ColourTo(i - 1, state);
- state = SCE_RB_NUMBER;
+ styler.ColourTo(i - 1, state);
+ state = SCE_RB_NUMBER;
is_real_number = true;
numDots = 0;
} else if (isHighBitChar(ch) || iswordstart(ch)) {
- styler.ColourTo(i - 1, state);
- state = SCE_RB_WORD;
- } else if (ch == '#') {
- styler.ColourTo(i - 1, state);
- state = SCE_RB_COMMENTLINE;
- } else if (ch == '=') {
- // =begin indicates the start of a comment (doc) block
+ styler.ColourTo(i - 1, state);
+ state = SCE_RB_WORD;
+ } else if (ch == '#') {
+ styler.ColourTo(i - 1, state);
+ state = SCE_RB_COMMENTLINE;
+ } else if (ch == '=') {
+ // =begin indicates the start of a comment (doc) block
if ((i == 0 || isEOLChar(chPrev))
- && chNext == 'b'
- && styler.SafeGetCharAt(i + 2) == 'e'
- && styler.SafeGetCharAt(i + 3) == 'g'
- && styler.SafeGetCharAt(i + 4) == 'i'
- && styler.SafeGetCharAt(i + 5) == 'n'
- && !isSafeWordcharOrHigh(styler.SafeGetCharAt(i + 6))) {
+ && chNext == 'b'
+ && styler.SafeGetCharAt(i + 2) == 'e'
+ && styler.SafeGetCharAt(i + 3) == 'g'
+ && styler.SafeGetCharAt(i + 4) == 'i'
+ && styler.SafeGetCharAt(i + 5) == 'n'
+ && !isSafeWordcharOrHigh(styler.SafeGetCharAt(i + 6))) {
styler.ColourTo(i - 1, state);
state = SCE_RB_POD;
- } else {
- styler.ColourTo(i - 1, state);
- styler.ColourTo(i, SCE_RB_OPERATOR);
- preferRE = true;
- }
- } else if (ch == '"') {
- styler.ColourTo(i - 1, state);
- state = SCE_RB_STRING;
- Quote.New();
- Quote.Open(ch);
- } else if (ch == '\'') {
+ } else {
+ styler.ColourTo(i - 1, state);
+ styler.ColourTo(i, SCE_RB_OPERATOR);
+ preferRE = true;
+ }
+ } else if (ch == '"') {
+ styler.ColourTo(i - 1, state);
+ state = SCE_RB_STRING;
+ Quote.New();
+ Quote.Open(ch);
+ } else if (ch == '\'') {
styler.ColourTo(i - 1, state);
state = SCE_RB_CHARACTER;
Quote.New();
Quote.Open(ch);
- } else if (ch == '`') {
- styler.ColourTo(i - 1, state);
- state = SCE_RB_BACKTICKS;
- Quote.New();
- Quote.Open(ch);
- } else if (ch == '@') {
+ } else if (ch == '`') {
+ styler.ColourTo(i - 1, state);
+ state = SCE_RB_BACKTICKS;
+ Quote.New();
+ Quote.Open(ch);
+ } else if (ch == '@') {
// Instance or class var
- styler.ColourTo(i - 1, state);
+ styler.ColourTo(i - 1, state);
if (chNext == '@') {
state = SCE_RB_CLASS_VAR;
advance_char(i, ch, chNext, chNext2); // pass by ref
} else {
state = SCE_RB_INSTANCE_VAR;
}
- } else if (ch == '$') {
+ } else if (ch == '$') {
// Check for a builtin global
- styler.ColourTo(i - 1, state);
+ styler.ColourTo(i - 1, state);
// Recognize it bit by bit
state = SCE_RB_GLOBAL;
} else if (ch == '/' && preferRE) {
// Ambigous operator
- styler.ColourTo(i - 1, state);
- state = SCE_RB_REGEX;
+ styler.ColourTo(i - 1, state);
+ state = SCE_RB_REGEX;
Quote.New();
Quote.Open(ch);
- } else if (ch == '<' && chNext == '<' && chNext2 != '=') {
+ } else if (ch == '<' && chNext == '<' && chNext2 != '=') {
// Recognise the '<<' symbol - either a here document or a binary op
- styler.ColourTo(i - 1, state);
+ styler.ColourTo(i - 1, state);
i++;
chNext = chNext2;
- styler.ColourTo(i, SCE_RB_OPERATOR);
+ styler.ColourTo(i, SCE_RB_OPERATOR);
- if (! (strchr("\"\'`_-", chNext2) || isSafeAlpha(chNext2))) {
+ if (!(strchr("\"\'`_-", chNext2) || isSafeAlpha(chNext2))) {
// It's definitely not a here-doc,
// based on Ruby's lexer/parser in the
// heredoc_identifier routine.
@@ -873,17 +874,17 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle,
}
preferRE = (state != SCE_RB_HERE_DELIM);
} else if (ch == ':') {
- styler.ColourTo(i - 1, state);
+ styler.ColourTo(i - 1, state);
if (chNext == ':') {
// Mark "::" as an operator, not symbol start
styler.ColourTo(i + 1, SCE_RB_OPERATOR);
advance_char(i, ch, chNext, chNext2); // pass by ref
state = SCE_RB_DEFAULT;
- preferRE = false;
+ preferRE = false;
} else if (isSafeWordcharOrHigh(chNext)) {
- state = SCE_RB_SYMBOL;
+ state = SCE_RB_SYMBOL;
} else if ((chNext == '@' || chNext == '$') &&
- isSafeWordcharOrHigh(chNext2)) {
+ isSafeWordcharOrHigh(chNext2)) {
// instance and global variable followed by an identifier
advance_char(i, ch, chNext, chNext2);
state = SCE_RB_SYMBOL;
@@ -913,7 +914,7 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle,
bool doColoring = true;
switch (chNext) {
case '[':
- if (chNext2 == ']' ) {
+ if (chNext2 == ']') {
char ch_tmp = styler.SafeGetCharAt(i + 3);
if (ch_tmp == '=') {
i += 3;
@@ -979,11 +980,11 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle,
styler.ColourTo(i, SCE_RB_SYMBOL);
state = SCE_RB_DEFAULT;
}
- } else if (!preferRE) {
- // Don't color symbol strings (yet)
- // Just color the ":" and color rest as string
- styler.ColourTo(i, SCE_RB_SYMBOL);
- state = SCE_RB_DEFAULT;
+ } else if (!preferRE) {
+ // Don't color symbol strings (yet)
+ // Just color the ":" and color rest as string
+ styler.ColourTo(i, SCE_RB_SYMBOL);
+ state = SCE_RB_DEFAULT;
} else {
styler.ColourTo(i, SCE_RB_OPERATOR);
state = SCE_RB_DEFAULT;
@@ -1000,7 +1001,7 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle,
Quote.Open(chNext2);
i += 2;
ch = chNext2;
- chNext = styler.SafeGetCharAt(i + 1);
+ chNext = styler.SafeGetCharAt(i + 1);
have_string = true;
}
} else if (preferRE && !isSafeWordcharOrHigh(chNext)) {
@@ -1036,8 +1037,8 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle,
is_real_number = false;
}
} else if (isoperator(ch) || ch == '.') {
- styler.ColourTo(i - 1, state);
- styler.ColourTo(i, SCE_RB_OPERATOR);
+ styler.ColourTo(i - 1, state);
+ styler.ColourTo(i, SCE_RB_OPERATOR);
// If we're ending an expression or block,
// assume it ends an object, and the ambivalent
// constructs are binary operators
@@ -1064,7 +1065,7 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle,
} else if (isEOLChar(ch)) {
// Make sure it's a true line-end, with no backslash
if ((ch == '\r' || (ch == '\n' && chPrev != '\r'))
- && chPrev != '\\') {
+ && chPrev != '\\') {
// Assume we've hit the end of the statement.
preferRE = true;
}
@@ -1079,11 +1080,11 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle,
// but we don't for now.
if (ch == '='
- && isSafeWordcharOrHigh(chPrev)
- && (chNext == '('
- || strchr(" \t\n\r", chNext) != NULL)
- && (!strcmp(prevWord, "def")
- || followsDot(styler.GetStartSegment(), styler))) {
+ && isSafeWordcharOrHigh(chPrev)
+ && (chNext == '('
+ || strchr(" \t\n\r", chNext) != NULL)
+ && (!strcmp(prevWord, "def")
+ || followsDot(styler.GetStartSegment(), styler))) {
// <name>= is a name only when being def'd -- Get it the next time
// This means that <name>=<name> is always lexed as
// <name>, (op, =), <name>
@@ -1102,28 +1103,28 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle,
// No need to handle this state -- we'll just move to the end
preferRE = false;
} else {
- int wordStartPos = styler.GetStartSegment();
+ int wordStartPos = styler.GetStartSegment();
int word_style = ClassifyWordRb(wordStartPos, i - 1, keywords, styler, prevWord);
switch (word_style) {
- case SCE_RB_WORD:
- preferRE = RE_CanFollowKeyword(prevWord);
- break;
+ case SCE_RB_WORD:
+ preferRE = RE_CanFollowKeyword(prevWord);
+ break;
- case SCE_RB_WORD_DEMOTED:
- preferRE = true;
- break;
+ case SCE_RB_WORD_DEMOTED:
+ preferRE = true;
+ break;
- case SCE_RB_IDENTIFIER:
- if (isMatch(styler, lengthDoc, wordStartPos, "print")) {
- preferRE = true;
- } else if (isEOLChar(ch)) {
- preferRE = true;
- } else {
- preferRE = false;
- }
- break;
- default:
+ case SCE_RB_IDENTIFIER:
+ if (isMatch(styler, lengthDoc, wordStartPos, "print")) {
+ preferRE = true;
+ } else if (isEOLChar(ch)) {
+ preferRE = true;
+ } else {
preferRE = false;
+ }
+ break;
+ default:
+ preferRE = false;
}
if (ch == '.') {
// We might be redefining an operator-method
@@ -1178,7 +1179,7 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle,
preferRE = false;
}
} else if (state == SCE_RB_COMMENTLINE) {
- if (isEOLChar(ch)) {
+ if (isEOLChar(ch)) {
styler.ColourTo(i - 1, state);
state = SCE_RB_DEFAULT;
// Use whatever setting we had going into the comment
@@ -1188,8 +1189,8 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle,
// Slightly different: if we find an immediate '-',
// the target can appear indented.
- if (HereDoc.State == 0) { // '<<' encountered
- HereDoc.State = 1;
+ if (HereDoc.State == 0) { // '<<' encountered
+ HereDoc.State = 1;
HereDoc.DelimiterLength = 0;
if (ch == '-') {
HereDoc.CanBeIndented = true;
@@ -1214,7 +1215,7 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle,
HereDoc.DelimiterLength = 1;
}
}
- } else if (HereDoc.State == 1) { // collect the delimiter
+ } else if (HereDoc.State == 1) { // collect the delimiter
if (isEOLChar(ch)) {
// End the quote now, and go back for more
styler.ColourTo(i - 1, state);
@@ -1223,32 +1224,32 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle,
chNext = ch;
preferRE = false;
} else if (HereDoc.Quoted) {
- if (ch == HereDoc.Quote) { // closing quote => end of delimiter
- styler.ColourTo(i, state);
- state = SCE_RB_DEFAULT;
+ if (ch == HereDoc.Quote) { // closing quote => end of delimiter
+ styler.ColourTo(i, state);
+ state = SCE_RB_DEFAULT;
preferRE = false;
} else {
- if (ch == '\\' && !isEOLChar(chNext)) {
+ if (ch == '\\' && !isEOLChar(chNext)) {
advance_char(i, ch, chNext, chNext2);
- }
- HereDoc.Delimiter[HereDoc.DelimiterLength++] = ch;
- HereDoc.Delimiter[HereDoc.DelimiterLength] = '\0';
+ }
+ HereDoc.Delimiter[HereDoc.DelimiterLength++] = ch;
+ HereDoc.Delimiter[HereDoc.DelimiterLength] = '\0';
}
} else { // an unquoted here-doc delimiter
- if (isSafeAlnumOrHigh(ch) || ch == '_') {
- HereDoc.Delimiter[HereDoc.DelimiterLength++] = ch;
- HereDoc.Delimiter[HereDoc.DelimiterLength] = '\0';
- } else {
- styler.ColourTo(i - 1, state);
+ if (isSafeAlnumOrHigh(ch) || ch == '_') {
+ HereDoc.Delimiter[HereDoc.DelimiterLength++] = ch;
+ HereDoc.Delimiter[HereDoc.DelimiterLength] = '\0';
+ } else {
+ styler.ColourTo(i - 1, state);
redo_char(i, ch, chNext, chNext2, state);
preferRE = false;
- }
+ }
}
- if (HereDoc.DelimiterLength >= static_cast<int>(sizeof(HereDoc.Delimiter)) - 1) {
- styler.ColourTo(i - 1, state);
- state = SCE_RB_ERROR;
+ if (HereDoc.DelimiterLength >= static_cast<int>(sizeof(HereDoc.Delimiter)) - 1) {
+ styler.ColourTo(i - 1, state);
+ state = SCE_RB_ERROR;
preferRE = false;
- }
+ }
}
} else if (state == SCE_RB_HERE_Q) {
// Not needed: HereDoc.State == 2
@@ -1259,7 +1260,7 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle,
if (!HereDoc.CanBeIndented) {
if (isEOLChar(chPrev)
- && isMatch(styler, lengthDoc, i, HereDoc.Delimiter)) {
+ && isMatch(styler, lengthDoc, i, HereDoc.Delimiter)) {
styler.ColourTo(i - 1, state);
i += HereDoc.DelimiterLength - 1;
chNext = styler.SafeGetCharAt(i + 1);
@@ -1286,11 +1287,11 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle,
|| state == SCE_RB_INSTANCE_VAR
|| state == SCE_RB_SYMBOL) {
if (state == SCE_RB_SYMBOL &&
- // FIDs suffices '?' and '!'
- (((ch == '!' || ch == '?') && chNext != '=') ||
- // identifier suffix '='
- (ch == '=' && (chNext != '~' && chNext != '>' &&
- (chNext != '=' || chNext2 == '>'))))) {
+ // FIDs suffices '?' and '!'
+ (((ch == '!' || ch == '?') && chNext != '=') ||
+ // identifier suffix '='
+ (ch == '=' && (chNext != '~' && chNext != '>' &&
+ (chNext != '=' || chNext2 == '>'))))) {
styler.ColourTo(i, state);
state = SCE_RB_DEFAULT;
preferRE = false;
@@ -1318,9 +1319,9 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle,
} else if (state == SCE_RB_POD) {
// PODs end with ^=end\s, -- any whitespace can follow =end
if (strchr(" \t\n\r", ch) != NULL
- && i > 5
- && isEOLChar(styler[i - 5])
- && isMatch(styler, lengthDoc, i - 4, "=end")) {
+ && i > 5
+ && isEOLChar(styler[i - 5])
+ && isMatch(styler, lengthDoc, i - 4, "=end")) {
styler.ColourTo(i - 1, state);
state = SCE_RB_DEFAULT;
preferRE = false;
@@ -1335,7 +1336,7 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle,
// Include the options
while (isSafeAlpha(chNext)) {
i++;
- ch = chNext;
+ ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
}
styler.ColourTo(i, state);
@@ -1346,9 +1347,9 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle,
// Only if close quoter != open quoter
Quote.Count++;
- } else if (ch == '#' ) {
+ } else if (ch == '#') {
if (chNext == '{'
- && inner_string_count < INNER_STRINGS_MAX_COUNT) {
+ && inner_string_count < INNER_STRINGS_MAX_COUNT) {
// process #{ ... }
styler.ColourTo(i - 1, state);
styler.ColourTo(i + 1, SCE_RB_OPERATOR);
@@ -1388,7 +1389,7 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle,
chNext = styler.SafeGetCharAt(i + 1);
}
}
- // Quotes of all kinds...
+ // Quotes of all kinds...
} else if (state == SCE_RB_STRING_Q || state == SCE_RB_STRING_QQ ||
state == SCE_RB_STRING_QX || state == SCE_RB_STRING_QW ||
state == SCE_RB_STRING || state == SCE_RB_CHARACTER ||
@@ -1463,7 +1464,7 @@ static void getPrevWord(int pos,
for (; i <= pos; i++) {
*dst++ = styler[i];
}
- *dst = 0;
+ *dst = 0;
}
static bool keywordIsAmbiguous(const char *prevWord)
@@ -1471,11 +1472,11 @@ static bool keywordIsAmbiguous(const char *prevWord)
// Order from most likely used to least likely
// Lots of ways to do a loop in Ruby besides 'while/until'
if (!strcmp(prevWord, "if")
- || !strcmp(prevWord, "do")
- || !strcmp(prevWord, "while")
- || !strcmp(prevWord, "unless")
- || !strcmp(prevWord, "until")
- || !strcmp(prevWord, "for")) {
+ || !strcmp(prevWord, "do")
+ || !strcmp(prevWord, "while")
+ || !strcmp(prevWord, "unless")
+ || !strcmp(prevWord, "until")
+ || !strcmp(prevWord, "for")) {
return true;
} else {
return false;
@@ -1495,7 +1496,7 @@ static bool keywordIsModifier(const char *word,
}
char ch, chPrev, chPrev2;
int style = SCE_RB_DEFAULT;
- int lineStart = styler.GetLine(pos);
+ int lineStart = styler.GetLine(pos);
int lineStartPosn = styler.LineStart(lineStart);
// We want to step backwards until we don't care about the current
// position. But first move lineStartPosn back behind any
@@ -1515,20 +1516,20 @@ static bool keywordIsModifier(const char *word,
break;
}
} else {
- break;
+ break;
}
}
styler.Flush();
while (--pos >= lineStartPosn) {
style = actual_style(styler.StyleAt(pos));
- if (style == SCE_RB_DEFAULT) {
- if (iswhitespace(ch = styler[pos])) {
- //continue
- } else if (ch == '\r' || ch == '\n') {
- // Scintilla's LineStart() and GetLine() routines aren't
- // platform-independent, so if we have text prepared with
- // a different system we can't rely on it.
+ if (style == SCE_RB_DEFAULT) {
+ if (iswhitespace(ch = styler[pos])) {
+ //continue
+ } else if (ch == '\r' || ch == '\n') {
+ // Scintilla's LineStart() and GetLine() routines aren't
+ // platform-independent, so if we have text prepared with
+ // a different system we can't rely on it.
// Also, lineStartPosn may have been moved to more than one
// line above word's line while pushing past continuations.
@@ -1541,40 +1542,40 @@ static bool keywordIsModifier(const char *word,
pos-=2; // gloss over the "\\\r"
//continue
} else {
- return false;
+ return false;
}
- }
- } else {
+ }
+ } else {
break;
- }
+ }
}
if (pos < lineStartPosn) {
return false;
}
// First things where the action is unambiguous
switch (style) {
- case SCE_RB_DEFAULT:
- case SCE_RB_COMMENTLINE:
- case SCE_RB_POD:
- case SCE_RB_CLASSNAME:
- case SCE_RB_DEFNAME:
- case SCE_RB_MODULE_NAME:
- return false;
- case SCE_RB_OPERATOR:
- break;
- case SCE_RB_WORD:
- // Watch out for uses of 'else if'
- //XXX: Make a list of other keywords where 'if' isn't a modifier
- // and can appear legitimately
- // Formulate this to avoid warnings from most compilers
- if (strcmp(word, "if") == 0) {
- char prevWord[MAX_KEYWORD_LENGTH + 1];
- getPrevWord(pos, prevWord, styler, SCE_RB_WORD);
- return strcmp(prevWord, "else") != 0;
- }
- return true;
- default:
- return true;
+ case SCE_RB_DEFAULT:
+ case SCE_RB_COMMENTLINE:
+ case SCE_RB_POD:
+ case SCE_RB_CLASSNAME:
+ case SCE_RB_DEFNAME:
+ case SCE_RB_MODULE_NAME:
+ return false;
+ case SCE_RB_OPERATOR:
+ break;
+ case SCE_RB_WORD:
+ // Watch out for uses of 'else if'
+ //XXX: Make a list of other keywords where 'if' isn't a modifier
+ // and can appear legitimately
+ // Formulate this to avoid warnings from most compilers
+ if (strcmp(word, "if") == 0) {
+ char prevWord[MAX_KEYWORD_LENGTH + 1];
+ getPrevWord(pos, prevWord, styler, SCE_RB_WORD);
+ return strcmp(prevWord, "else") != 0;
+ }
+ return true;
+ default:
+ return true;
}
// Assume that if the keyword follows an operator,
// usually it's a block assignment, like
@@ -1582,12 +1583,12 @@ static bool keywordIsModifier(const char *word,
ch = styler[pos];
switch (ch) {
- case ')':
- case ']':
- case '}':
- return true;
- default:
- return false;
+ case ')':
+ case ']':
+ case '}':
+ return true;
+ default:
+ return false;
}
}
@@ -1603,27 +1604,27 @@ static bool keywordDoStartsLoop(int pos,
{
char ch;
int style;
- int lineStart = styler.GetLine(pos);
+ int lineStart = styler.GetLine(pos);
int lineStartPosn = styler.LineStart(lineStart);
styler.Flush();
while (--pos >= lineStartPosn) {
style = actual_style(styler.StyleAt(pos));
- if (style == SCE_RB_DEFAULT) {
- if ((ch = styler[pos]) == '\r' || ch == '\n') {
- // Scintilla's LineStart() and GetLine() routines aren't
- // platform-independent, so if we have text prepared with
- // a different system we can't rely on it.
- return false;
- }
- } else if (style == SCE_RB_WORD) {
+ if (style == SCE_RB_DEFAULT) {
+ if ((ch = styler[pos]) == '\r' || ch == '\n') {
+ // Scintilla's LineStart() and GetLine() routines aren't
+ // platform-independent, so if we have text prepared with
+ // a different system we can't rely on it.
+ return false;
+ }
+ } else if (style == SCE_RB_WORD) {
// Check for while or until, but write the word in backwards
char prevWord[MAX_KEYWORD_LENGTH + 1]; // 1 byte for zero
char *dst = prevWord;
int wordLen = 0;
int start_word;
for (start_word = pos;
- start_word >= lineStartPosn && actual_style(styler.StyleAt(start_word)) == SCE_RB_WORD;
- start_word--) {
+ start_word >= lineStartPosn && actual_style(styler.StyleAt(start_word)) == SCE_RB_WORD;
+ start_word--) {
if (++wordLen < MAX_KEYWORD_LENGTH) {
*dst++ = styler[start_word];
}
@@ -1631,8 +1632,8 @@ static bool keywordDoStartsLoop(int pos,
*dst = 0;
// Did we see our keyword?
if (!strcmp(prevWord, WHILE_BACKWARDS)
- || !strcmp(prevWord, UNTIL_BACKWARDS)
- || !strcmp(prevWord, FOR_BACKWARDS)) {
+ || !strcmp(prevWord, UNTIL_BACKWARDS)
+ || !strcmp(prevWord, FOR_BACKWARDS)) {
return true;
}
// We can move pos to the beginning of the keyword, and then
@@ -1650,6 +1651,19 @@ static bool keywordDoStartsLoop(int pos,
return false;
}
+static bool IsCommentLine(int line, Accessor &styler) {
+ int pos = styler.LineStart(line);
+ int eol_pos = styler.LineStart(line + 1) - 1;
+ for (int i = pos; i < eol_pos; i++) {
+ char ch = styler[i];
+ if (ch == '#')
+ return true;
+ else if (ch != ' ' && ch != '\t')
+ return false;
+ }
+ return false;
+}
+
/*
* Folding Ruby
*
@@ -1706,44 +1720,55 @@ static bool keywordDoStartsLoop(int pos,
static void FoldRbDoc(unsigned int startPos, int length, int initStyle,
WordList *[], Accessor &styler) {
- const bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
- bool foldComment = styler.GetPropertyInt("fold.comment") != 0;
+ const bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
+ bool foldComment = styler.GetPropertyInt("fold.comment") != 0;
synchronizeDocStart(startPos, length, initStyle, styler, // ref args
false);
- unsigned int endPos = startPos + length;
- int visibleChars = 0;
- int lineCurrent = styler.GetLine(startPos);
- int levelPrev = startPos == 0 ? 0 : (styler.LevelAt(lineCurrent)
+ unsigned int endPos = startPos + length;
+ int visibleChars = 0;
+ int lineCurrent = styler.GetLine(startPos);
+ int levelPrev = startPos == 0 ? 0 : (styler.LevelAt(lineCurrent)
& SC_FOLDLEVELNUMBERMASK
& ~SC_FOLDLEVELBASE);
- int levelCurrent = levelPrev;
- char chNext = styler[startPos];
- int styleNext = styler.StyleAt(startPos);
- int stylePrev = startPos <= 1 ? SCE_RB_DEFAULT : styler.StyleAt(startPos - 1);
+ int levelCurrent = levelPrev;
+ char chNext = styler[startPos];
+ int styleNext = styler.StyleAt(startPos);
+ int stylePrev = startPos <= 1 ? SCE_RB_DEFAULT : styler.StyleAt(startPos - 1);
bool buffer_ends_with_eol = false;
- for (unsigned int i = startPos; i < endPos; i++) {
- char ch = chNext;
- chNext = styler.SafeGetCharAt(i + 1);
- int style = styleNext;
- styleNext = styler.StyleAt(i + 1);
- bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
+ for (unsigned int i = startPos; i < endPos; i++) {
+ char ch = chNext;
+ chNext = styler.SafeGetCharAt(i + 1);
+ int style = styleNext;
+ styleNext = styler.StyleAt(i + 1);
+ bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
+
+ /*Mutiline comment patch*/
+ if (foldComment && atEOL && IsCommentLine(lineCurrent, styler)) {
+ if (!IsCommentLine(lineCurrent - 1, styler)
+ && IsCommentLine(lineCurrent + 1, styler))
+ levelCurrent++;
+ else if (IsCommentLine(lineCurrent - 1, styler)
+ && !IsCommentLine(lineCurrent + 1, styler))
+ levelCurrent--;
+ }
+
if (style == SCE_RB_COMMENTLINE) {
if (foldComment && stylePrev != SCE_RB_COMMENTLINE) {
if (chNext == '{') {
- levelCurrent++;
- } else if (chNext == '}' && levelCurrent > 0) {
- levelCurrent--;
- }
+ levelCurrent++;
+ } else if (chNext == '}' && levelCurrent > 0) {
+ levelCurrent--;
+ }
}
} else if (style == SCE_RB_OPERATOR) {
- if (strchr("[{(", ch)) {
- levelCurrent++;
- } else if (strchr(")}]", ch)) {
+ if (strchr("[{(", ch)) {
+ levelCurrent++;
+ } else if (strchr(")}]", ch)) {
// Don't decrement below 0
if (levelCurrent > 0)
levelCurrent--;
- }
+ }
} else if (style == SCE_RB_WORD && styleNext != SCE_RB_WORD) {
// Look at the keyword on the left and decide what to do
char prevWord[MAX_KEYWORD_LENGTH + 1]; // 1 byte for zero
@@ -1753,7 +1778,7 @@ static void FoldRbDoc(unsigned int startPos, int length, int initStyle,
// Don't decrement below 0
if (levelCurrent > 0)
levelCurrent--;
- } else if ( !strcmp(prevWord, "if")
+ } else if (!strcmp(prevWord, "if")
|| !strcmp(prevWord, "def")
|| !strcmp(prevWord, "class")
|| !strcmp(prevWord, "module")
@@ -1764,49 +1789,49 @@ static void FoldRbDoc(unsigned int startPos, int length, int initStyle,
|| !strcmp(prevWord, "unless")
|| !strcmp(prevWord, "until")
|| !strcmp(prevWord, "for")
- ) {
- levelCurrent++;
+ ) {
+ levelCurrent++;
+ }
+ } else if (style == SCE_RB_HERE_DELIM) {
+ if (styler.SafeGetCharAt(i-2) == '<' && styler.SafeGetCharAt(i-1) == '<') {
+ levelCurrent++;
+ } else if (styleNext == SCE_RB_DEFAULT) {
+ levelCurrent--;
}
- } else if (style == SCE_RB_HERE_DELIM) {
- if (styler.SafeGetCharAt(i-2) == '<' && styler.SafeGetCharAt(i-1) == '<') {
- levelCurrent++;
- } else if (styleNext == SCE_RB_DEFAULT) {
- levelCurrent--;
- }
- }
- if (atEOL) {
- int lev = levelPrev;
- if (visibleChars == 0 && foldCompact)
- lev |= SC_FOLDLEVELWHITEFLAG;
- if ((levelCurrent > levelPrev) && (visibleChars > 0))
- lev |= SC_FOLDLEVELHEADERFLAG;
+ }
+ if (atEOL) {
+ int lev = levelPrev;
+ if (visibleChars == 0 && foldCompact)
+ lev |= SC_FOLDLEVELWHITEFLAG;
+ if ((levelCurrent > levelPrev) && (visibleChars > 0))
+ lev |= SC_FOLDLEVELHEADERFLAG;
styler.SetLevel(lineCurrent, lev|SC_FOLDLEVELBASE);
- lineCurrent++;
- levelPrev = levelCurrent;
- visibleChars = 0;
+ lineCurrent++;
+ levelPrev = levelCurrent;
+ visibleChars = 0;
buffer_ends_with_eol = true;
- } else if (!isspacechar(ch)) {
- visibleChars++;
+ } else if (!isspacechar(ch)) {
+ visibleChars++;
buffer_ends_with_eol = false;
}
- stylePrev = style;
+ stylePrev = style;
}
- // Fill in the real level of the next line, keeping the current flags as they will be filled in later
+ // Fill in the real level of the next line, keeping the current flags as they will be filled in later
if (!buffer_ends_with_eol) {
lineCurrent++;
int new_lev = levelCurrent;
if (visibleChars == 0 && foldCompact)
new_lev |= SC_FOLDLEVELWHITEFLAG;
- if ((levelCurrent > levelPrev) && (visibleChars > 0))
- new_lev |= SC_FOLDLEVELHEADERFLAG;
- levelCurrent = new_lev;
+ if ((levelCurrent > levelPrev) && (visibleChars > 0))
+ new_lev |= SC_FOLDLEVELHEADERFLAG;
+ levelCurrent = new_lev;
}
- styler.SetLevel(lineCurrent, levelCurrent|SC_FOLDLEVELBASE);
+ styler.SetLevel(lineCurrent, levelCurrent|SC_FOLDLEVELBASE);
}
-static const char * const rubyWordListDesc[] = {
- "Keywords",
- 0
+static const char *const rubyWordListDesc[] = {
+ "Keywords",
+ 0
};
LexerModule lmRuby(SCLEX_RUBY, ColouriseRbDoc, "ruby", FoldRbDoc, rubyWordListDesc);
Modified: scintilla/lexers/LexRust.cxx
4 lines changed, 3 insertions(+), 1 deletions(-)
===================================================================
@@ -271,7 +271,7 @@ static void ScanNumber(Accessor& styler, int& pos) {
pos++;
c = styler.SafeGetCharAt(pos, '\0');
n = styler.SafeGetCharAt(pos + 1, '\0');
- if (c == '8') {
+ if (c == '8' || c == 's') {
pos++;
} else if (c == '1' && n == '6') {
pos += 2;
@@ -279,6 +279,8 @@ static void ScanNumber(Accessor& styler, int& pos) {
pos += 2;
} else if (c == '6' && n == '4') {
pos += 2;
+ } else {
+ error = true;
}
/* See if it's a floating point literal. These literals have to be base 10.
*/
Modified: scintilla/lexers/LexSQL.cxx
50 lines changed, 27 insertions(+), 23 deletions(-)
===================================================================
@@ -444,7 +444,6 @@ void SCI_METHOD LexerSQL::Lex(unsigned int startPos, int length, int initStyle,
StyleContext sc(startPos, length, initStyle, styler);
int styleBeforeDCKeyword = SCE_SQL_DEFAULT;
int offset = 0;
- char qOperator = 0x00;
for (; sc.More(); sc.Forward(), offset++) {
// Determine if the current state should terminate.
@@ -559,29 +558,34 @@ void SCI_METHOD LexerSQL::Lex(unsigned int startPos, int length, int initStyle,
}
break;
case SCE_SQL_QOPERATOR:
- if (qOperator == 0x00) {
- qOperator = sc.ch;
- } else {
- char qComplement = 0x00;
-
- if (qOperator == '<') {
- qComplement = '>';
- } else if (qOperator == '(') {
- qComplement = ')';
- } else if (qOperator == '{') {
- qComplement = '}';
- } else if (qOperator == '[') {
- qComplement = ']';
- } else {
- qComplement = qOperator;
- }
-
- if (sc.Match(qComplement, '\'')) {
- sc.Forward();
- sc.ForwardSetState(SCE_SQL_DEFAULT);
- qOperator = 0x00;
+ // Locate the unique Q operator character
+ sc.Complete();
+ char qOperator = 0x00;
+ for (int styleStartPos = sc.currentPos; styleStartPos > 0; --styleStartPos) {
+ if (styler.StyleAt(styleStartPos - 1) != SCE_SQL_QOPERATOR) {
+ qOperator = styler.SafeGetCharAt(styleStartPos + 2);
+ break;
}
- }
+ }
+
+ char qComplement = 0x00;
+
+ if (qOperator == '<') {
+ qComplement = '>';
+ } else if (qOperator == '(') {
+ qComplement = ')';
+ } else if (qOperator == '{') {
+ qComplement = '}';
+ } else if (qOperator == '[') {
+ qComplement = ']';
+ } else {
+ qComplement = qOperator;
+ }
+
+ if (sc.Match(qComplement, '\'')) {
+ sc.Forward();
+ sc.ForwardSetState(SCE_SQL_DEFAULT);
+ }
break;
}
Modified: scintilla/lexers/LexTCL.cxx
370 lines changed, 186 insertions(+), 184 deletions(-)
===================================================================
@@ -30,7 +30,7 @@ using namespace Scintilla;
// Extended to accept accented characters
static inline bool IsAWordChar(int ch) {
return ch >= 0x80 ||
- (isalnum(ch) || ch == '_' || ch ==':' || ch=='.'); // : name space separator
+ (isalnum(ch) || ch == '_' || ch ==':' || ch=='.'); // : name space separator
}
static inline bool IsAWordStart(int ch) {
@@ -49,17 +49,18 @@ static void ColouriseTCLDoc(unsigned int startPos, int length, int , WordList *k
#define isComment(s) (s==SCE_TCL_COMMENT || s==SCE_TCL_COMMENTLINE || s==SCE_TCL_COMMENT_BOX || s==SCE_TCL_BLOCK_COMMENT)
bool foldComment = styler.GetPropertyInt("fold.comment") != 0;
bool commentLevel = false;
- bool subBrace = false; // substitution begin with a brace ${.....}
+ bool subBrace = false; // substitution begin with a brace ${.....}
enum tLineState {LS_DEFAULT, LS_OPEN_COMMENT, LS_OPEN_DOUBLE_QUOTE, LS_COMMENT_BOX, LS_MASK_STATE = 0xf,
- LS_COMMAND_EXPECTED = 16, LS_BRACE_ONLY = 32 } lineState = LS_DEFAULT;
+ LS_COMMAND_EXPECTED = 16, LS_BRACE_ONLY = 32
+ } lineState = LS_DEFAULT;
bool prevSlash = false;
int currentLevel = 0;
- bool expected = 0;
- bool subParen = 0;
+ bool expected = 0;
+ bool subParen = 0;
int currentLine = styler.GetLine(startPos);
- if (currentLine > 0)
- currentLine--;
+ if (currentLine > 0)
+ currentLine--;
length += startPos - styler.LineStart(currentLine);
// make sure lines overlap
startPos = styler.LineStart(currentLine);
@@ -71,14 +72,14 @@ static void ColouriseTCLDoc(unsigned int startPos, int length, int , WordList *k
WordList &keywords5 = *keywordlists[4];
WordList &keywords6 = *keywordlists[5];
WordList &keywords7 = *keywordlists[6];
- WordList &keywords8 = *keywordlists[7];
- WordList &keywords9 = *keywordlists[8];
+ WordList &keywords8 = *keywordlists[7];
+ WordList &keywords9 = *keywordlists[8];
if (currentLine > 0) {
- int ls = styler.GetLineState(currentLine - 1);
+ int ls = styler.GetLineState(currentLine - 1);
lineState = tLineState(ls & LS_MASK_STATE);
expected = LS_COMMAND_EXPECTED == tLineState(ls & LS_COMMAND_EXPECTED);
- subBrace = LS_BRACE_ONLY == tLineState(ls & LS_BRACE_ONLY);
+ subBrace = LS_BRACE_ONLY == tLineState(ls & LS_BRACE_ONLY);
currentLevel = styler.LevelAt(currentLine - 1) >> 17;
commentLevel = (styler.LevelAt(currentLine - 1) >> 16) & 1;
} else
@@ -86,105 +87,104 @@ static void ColouriseTCLDoc(unsigned int startPos, int length, int , WordList *k
bool visibleChars = false;
int previousLevel = currentLevel;
- StyleContext sc(startPos, length, SCE_TCL_DEFAULT, styler);
+ StyleContext sc(startPos, length, SCE_TCL_DEFAULT, styler);
for (; ; sc.Forward()) {
next:
- if (sc.ch=='\r' && sc.chNext == '\n') // only ignore \r on PC process on the mac
- continue;
- bool atEnd = !sc.More(); // make sure we coloured the last word
- if (lineState != LS_DEFAULT) {
- sc.SetState(SCE_TCL_DEFAULT);
- if (lineState == LS_OPEN_COMMENT)
- sc.SetState(SCE_TCL_COMMENTLINE);
- else if (lineState == LS_OPEN_DOUBLE_QUOTE)
- sc.SetState(SCE_TCL_IN_QUOTE);
- else if (lineState == LS_COMMENT_BOX && (sc.ch == '#' || (sc.ch == ' ' && sc.chNext=='#')))
- sc.SetState(SCE_TCL_COMMENT_BOX);
- lineState = LS_DEFAULT;
- }
- if (subBrace) { // ${ overrides every thing even \ except }
- if (sc.ch == '}') {
- subBrace = false;
- sc.SetState(SCE_TCL_OPERATOR);
- sc.ForwardSetState(SCE_TCL_DEFAULT);
- goto next;
- }
- else
- sc.SetState(SCE_TCL_SUB_BRACE);
- if (!sc.atLineEnd)
- continue;
- } else if (sc.state == SCE_TCL_DEFAULT || sc.state ==SCE_TCL_OPERATOR) {
- expected &= isspacechar(static_cast<unsigned char>(sc.ch)) || IsAWordStart(sc.ch) || sc.ch =='#';
- } else if (sc.state == SCE_TCL_SUBSTITUTION) {
- switch(sc.ch) {
- case '(':
- subParen=true;
- sc.SetState(SCE_TCL_OPERATOR);
- sc.ForwardSetState(SCE_TCL_SUBSTITUTION);
- continue;
- case ')':
- sc.SetState(SCE_TCL_OPERATOR);
- subParen=false;
- continue;
- case '$':
- continue;
- case ',':
- sc.SetState(SCE_TCL_OPERATOR);
- if (subParen)
- sc.ForwardSetState(SCE_TCL_SUBSTITUTION);
- continue;
- default :
- // maybe spaces should be allowed ???
- if (!IsAWordChar(sc.ch)) { // probably the code is wrong
- sc.SetState(SCE_TCL_DEFAULT);
- subParen = 0;
- }
- break;
- }
- } else if (isComment(sc.state)) {
- } else if (!IsAWordChar(sc.ch)) {
- if ((sc.state == SCE_TCL_IDENTIFIER && expected) || sc.state == SCE_TCL_MODIFIER) {
- char w[100];
- char *s=w;
- sc.GetCurrent(w, sizeof(w));
- if (w[strlen(w)-1]=='\r')
- w[strlen(w)-1]=0;
- while(*s == ':') // ignore leading : like in ::set a 10
- ++s;
- bool quote = sc.state == SCE_TCL_IN_QUOTE;
- if (commentLevel || expected) {
- if (keywords.InList(s)) {
- sc.ChangeState(quote ? SCE_TCL_WORD_IN_QUOTE : SCE_TCL_WORD);
- } else if (keywords2.InList(s)) {
- sc.ChangeState(quote ? SCE_TCL_WORD_IN_QUOTE : SCE_TCL_WORD2);
- } else if (keywords3.InList(s)) {
- sc.ChangeState(quote ? SCE_TCL_WORD_IN_QUOTE : SCE_TCL_WORD3);
- } else if (keywords4.InList(s)) {
- sc.ChangeState(quote ? SCE_TCL_WORD_IN_QUOTE : SCE_TCL_WORD4);
- } else if (sc.GetRelative(-static_cast<int>(strlen(s))-1) == '{' &&
- keywords5.InList(s) && sc.ch == '}') { // {keyword} exactly no spaces
- sc.ChangeState(SCE_TCL_EXPAND);
- }
- if (keywords6.InList(s)) {
- sc.ChangeState(SCE_TCL_WORD5);
- } else if (keywords7.InList(s)) {
- sc.ChangeState(SCE_TCL_WORD6);
- } else if (keywords8.InList(s)) {
- sc.ChangeState(SCE_TCL_WORD7);
- } else if (keywords9.InList(s)) {
- sc.ChangeState(SCE_TCL_WORD8);
- }
- }
- expected = false;
- sc.SetState(quote ? SCE_TCL_IN_QUOTE : SCE_TCL_DEFAULT);
- } else if (sc.state == SCE_TCL_MODIFIER || sc.state == SCE_TCL_IDENTIFIER) {
- sc.SetState(SCE_TCL_DEFAULT);
- }
- }
+ if (sc.ch=='\r' && sc.chNext == '\n') // only ignore \r on PC process on the mac
+ continue;
+ bool atEnd = !sc.More(); // make sure we coloured the last word
+ if (lineState != LS_DEFAULT) {
+ sc.SetState(SCE_TCL_DEFAULT);
+ if (lineState == LS_OPEN_COMMENT)
+ sc.SetState(SCE_TCL_COMMENTLINE);
+ else if (lineState == LS_OPEN_DOUBLE_QUOTE)
+ sc.SetState(SCE_TCL_IN_QUOTE);
+ else if (lineState == LS_COMMENT_BOX && (sc.ch == '#' || (sc.ch == ' ' && sc.chNext=='#')))
+ sc.SetState(SCE_TCL_COMMENT_BOX);
+ lineState = LS_DEFAULT;
+ }
+ if (subBrace) { // ${ overrides every thing even \ except }
+ if (sc.ch == '}') {
+ subBrace = false;
+ sc.SetState(SCE_TCL_OPERATOR);
+ sc.ForwardSetState(SCE_TCL_DEFAULT);
+ goto next;
+ } else
+ sc.SetState(SCE_TCL_SUB_BRACE);
+ if (!sc.atLineEnd)
+ continue;
+ } else if (sc.state == SCE_TCL_DEFAULT || sc.state ==SCE_TCL_OPERATOR) {
+ expected &= isspacechar(static_cast<unsigned char>(sc.ch)) || IsAWordStart(sc.ch) || sc.ch =='#';
+ } else if (sc.state == SCE_TCL_SUBSTITUTION) {
+ switch (sc.ch) {
+ case '(':
+ subParen=true;
+ sc.SetState(SCE_TCL_OPERATOR);
+ sc.ForwardSetState(SCE_TCL_SUBSTITUTION);
+ continue;
+ case ')':
+ sc.SetState(SCE_TCL_OPERATOR);
+ subParen=false;
+ continue;
+ case '$':
+ continue;
+ case ',':
+ sc.SetState(SCE_TCL_OPERATOR);
+ if (subParen)
+ sc.ForwardSetState(SCE_TCL_SUBSTITUTION);
+ continue;
+ default :
+ // maybe spaces should be allowed ???
+ if (!IsAWordChar(sc.ch)) { // probably the code is wrong
+ sc.SetState(SCE_TCL_DEFAULT);
+ subParen = 0;
+ }
+ break;
+ }
+ } else if (isComment(sc.state)) {
+ } else if (!IsAWordChar(sc.ch)) {
+ if ((sc.state == SCE_TCL_IDENTIFIER && expected) || sc.state == SCE_TCL_MODIFIER) {
+ char w[100];
+ char *s=w;
+ sc.GetCurrent(w, sizeof(w));
+ if (w[strlen(w)-1]=='\r')
+ w[strlen(w)-1]=0;
+ while (*s == ':') // ignore leading : like in ::set a 10
+ ++s;
+ bool quote = sc.state == SCE_TCL_IN_QUOTE;
+ if (commentLevel || expected) {
+ if (keywords.InList(s)) {
+ sc.ChangeState(quote ? SCE_TCL_WORD_IN_QUOTE : SCE_TCL_WORD);
+ } else if (keywords2.InList(s)) {
+ sc.ChangeState(quote ? SCE_TCL_WORD_IN_QUOTE : SCE_TCL_WORD2);
+ } else if (keywords3.InList(s)) {
+ sc.ChangeState(quote ? SCE_TCL_WORD_IN_QUOTE : SCE_TCL_WORD3);
+ } else if (keywords4.InList(s)) {
+ sc.ChangeState(quote ? SCE_TCL_WORD_IN_QUOTE : SCE_TCL_WORD4);
+ } else if (sc.GetRelative(-static_cast<int>(strlen(s))-1) == '{' &&
+ keywords5.InList(s) && sc.ch == '}') { // {keyword} exactly no spaces
+ sc.ChangeState(SCE_TCL_EXPAND);
+ }
+ if (keywords6.InList(s)) {
+ sc.ChangeState(SCE_TCL_WORD5);
+ } else if (keywords7.InList(s)) {
+ sc.ChangeState(SCE_TCL_WORD6);
+ } else if (keywords8.InList(s)) {
+ sc.ChangeState(SCE_TCL_WORD7);
+ } else if (keywords9.InList(s)) {
+ sc.ChangeState(SCE_TCL_WORD8);
+ }
+ }
+ expected = false;
+ sc.SetState(quote ? SCE_TCL_IN_QUOTE : SCE_TCL_DEFAULT);
+ } else if (sc.state == SCE_TCL_MODIFIER || sc.state == SCE_TCL_IDENTIFIER) {
+ sc.SetState(SCE_TCL_DEFAULT);
+ }
+ }
if (atEnd)
break;
- if (sc.atLineEnd) {
- lineState = LS_DEFAULT;
+ if (sc.atLineEnd) {
+ lineState = LS_DEFAULT;
currentLine = styler.GetLine(sc.currentPos);
if (foldComment && sc.state!=SCE_TCL_COMMENT && isComment(sc.state)) {
if (currentLevel == 0) {
@@ -206,45 +206,45 @@ static void ColouriseTCLDoc(unsigned int startPos, int length, int , WordList *k
styler.SetLevel(currentLine, flag + previousLevel + SC_FOLDLEVELBASE + (currentLevel << 17) + (commentLevel << 16));
// Update the line state, so it can be seen by next line
- if (sc.state == SCE_TCL_IN_QUOTE)
+ if (sc.state == SCE_TCL_IN_QUOTE) {
lineState = LS_OPEN_DOUBLE_QUOTE;
- else {
- if (prevSlash) {
- if (isComment(sc.state))
- lineState = LS_OPEN_COMMENT;
- } else if (sc.state == SCE_TCL_COMMENT_BOX)
- lineState = LS_COMMENT_BOX;
+ } else {
+ if (prevSlash) {
+ if (isComment(sc.state))
+ lineState = LS_OPEN_COMMENT;
+ } else if (sc.state == SCE_TCL_COMMENT_BOX)
+ lineState = LS_COMMENT_BOX;
}
- styler.SetLineState(currentLine,
- (subBrace ? LS_BRACE_ONLY : 0) |
- (expected ? LS_COMMAND_EXPECTED : 0) | lineState);
- if (lineState == LS_COMMENT_BOX)
- sc.ForwardSetState(SCE_TCL_COMMENT_BOX);
- else if (lineState == LS_OPEN_DOUBLE_QUOTE)
- sc.ForwardSetState(SCE_TCL_IN_QUOTE);
- else
- sc.ForwardSetState(SCE_TCL_DEFAULT);
+ styler.SetLineState(currentLine,
+ (subBrace ? LS_BRACE_ONLY : 0) |
+ (expected ? LS_COMMAND_EXPECTED : 0) | lineState);
+ if (lineState == LS_COMMENT_BOX)
+ sc.ForwardSetState(SCE_TCL_COMMENT_BOX);
+ else if (lineState == LS_OPEN_DOUBLE_QUOTE)
+ sc.ForwardSetState(SCE_TCL_IN_QUOTE);
+ else
+ sc.ForwardSetState(SCE_TCL_DEFAULT);
prevSlash = false;
previousLevel = currentLevel;
goto next;
}
if (prevSlash) {
- prevSlash = false;
- if (sc.ch == '#' && IsANumberChar(sc.chNext))
- sc.ForwardSetState(SCE_TCL_NUMBER);
- continue;
+ prevSlash = false;
+ if (sc.ch == '#' && IsANumberChar(sc.chNext))
+ sc.ForwardSetState(SCE_TCL_NUMBER);
+ continue;
}
- prevSlash = sc.ch == '\\';
- if (isComment(sc.state))
- continue;
+ prevSlash = sc.ch == '\\';
+ if (isComment(sc.state))
+ continue;
if (sc.atLineStart) {
visibleChars = false;
if (sc.state!=SCE_TCL_IN_QUOTE && !isComment(sc.state))
- {
+ {
sc.SetState(SCE_TCL_DEFAULT);
- expected = IsAWordStart(sc.ch)|| isspacechar(static_cast<unsigned char>(sc.ch));
- }
+ expected = IsAWordStart(sc.ch)|| isspacechar(static_cast<unsigned char>(sc.ch));
+ }
}
switch (sc.state) {
@@ -257,30 +257,30 @@ static void ColouriseTCLDoc(unsigned int startPos, int length, int , WordList *k
sc.ForwardSetState(SCE_TCL_DEFAULT);
visibleChars = true; // necessary if a " is the first and only character on a line
goto next;
- } else if (sc.ch == '[' || sc.ch == ']' || sc.ch == '$') {
+ } else if (sc.ch == '[' || sc.ch == ']' || sc.ch == '$' || sc.ch == '(') {
sc.SetState(SCE_TCL_OPERATOR);
- expected = sc.ch == '[';
- sc.ForwardSetState(SCE_TCL_IN_QUOTE);
+ expected = sc.ch == '[';
+ sc.ForwardSetState(SCE_TCL_IN_QUOTE);
goto next;
}
- continue;
- case SCE_TCL_OPERATOR:
+ continue;
+ case SCE_TCL_OPERATOR:
sc.SetState(SCE_TCL_DEFAULT);
break;
}
if (sc.ch == '#') {
if (visibleChars) {
- if (sc.state != SCE_TCL_IN_QUOTE && expected)
+ if (sc.state != SCE_TCL_IN_QUOTE && expected)
sc.SetState(SCE_TCL_COMMENT);
} else {
- sc.SetState(SCE_TCL_COMMENTLINE);
- if (sc.chNext == '~')
- sc.SetState(SCE_TCL_BLOCK_COMMENT);
- if (sc.atLineStart && (sc.chNext == '#' || sc.chNext == '-'))
- sc.SetState(SCE_TCL_COMMENT_BOX);
- }
- }
+ sc.SetState(SCE_TCL_COMMENTLINE);
+ if (sc.chNext == '~')
+ sc.SetState(SCE_TCL_BLOCK_COMMENT);
+ if (sc.atLineStart && (sc.chNext == '#' || sc.chNext == '-'))
+ sc.SetState(SCE_TCL_COMMENT_BOX);
+ }
+ }
if (!isspacechar(static_cast<unsigned char>(sc.ch))) {
visibleChars = true;
@@ -293,7 +293,7 @@ static void ColouriseTCLDoc(unsigned int startPos, int length, int , WordList *k
// Determine if a new state should be entered.
if (sc.state == SCE_TCL_DEFAULT) {
- if (IsAWordStart(sc.ch)) {
+ if (IsAWordStart(sc.ch)) {
sc.SetState(SCE_TCL_IDENTIFIER);
} else if (IsADigit(sc.ch) && !IsAWordChar(sc.chPrev)) {
sc.SetState(SCE_TCL_NUMBER);
@@ -313,39 +313,41 @@ static void ColouriseTCLDoc(unsigned int startPos, int length, int , WordList *k
--currentLevel;
break;
case '[':
- expected = true;
+ expected = true;
case ']':
case '(':
case ')':
sc.SetState(SCE_TCL_OPERATOR);
break;
case ';':
- expected = true;
+ expected = true;
+ break;
+ case '$':
+ subParen = 0;
+ if (sc.chNext == '(') {
+ //$("") jquery selector?!
+ sc.SetState(SCE_TCL_OPERATOR);
+ } else if (sc.chNext != '{') {
+ sc.SetState(SCE_TCL_SUBSTITUTION);
+ } else {
+ sc.SetState(SCE_TCL_OPERATOR); // $
+ sc.Forward(); // {
+ sc.ForwardSetState(SCE_TCL_SUB_BRACE);
+ subBrace = true;
+ }
+ break;
+ case '#':
+ if ((isspacechar(static_cast<unsigned char>(sc.chPrev))||
+ isoperator(static_cast<char>(sc.chPrev))) && IsADigit(sc.chNext,0x10))
+ sc.SetState(SCE_TCL_NUMBER);
+ break;
+ case '-':
+ sc.SetState(IsADigit(sc.chNext)? SCE_TCL_NUMBER: SCE_TCL_MODIFIER);
break;
- case '$':
- subParen = 0;
- if (sc.chNext != '{') {
- sc.SetState(SCE_TCL_SUBSTITUTION);
- }
- else {
- sc.SetState(SCE_TCL_OPERATOR); // $
- sc.Forward(); // {
- sc.ForwardSetState(SCE_TCL_SUB_BRACE);
- subBrace = true;
- }
- break;
- case '#':
- if ((isspacechar(static_cast<unsigned char>(sc.chPrev))||
- isoperator(static_cast<char>(sc.chPrev))) && IsADigit(sc.chNext,0x10))
- sc.SetState(SCE_TCL_NUMBER);
- break;
- case '-':
- sc.SetState(IsADigit(sc.chNext)? SCE_TCL_NUMBER: SCE_TCL_MODIFIER);
- break;
- default:
- if (isoperator(static_cast<char>(sc.ch))) {
- sc.SetState(SCE_TCL_OPERATOR);
- }
+ default:
+ if (isoperator(static_cast<char>(sc.ch))) {
+ sc.SetState(SCE_TCL_OPERATOR);
+ }
}
}
}
@@ -353,18 +355,18 @@ static void ColouriseTCLDoc(unsigned int startPos, int length, int , WordList *k
sc.Complete();
}
-static const char * const tclWordListDesc[] = {
- "TCL Keywords",
- "TK Keywords",
- "iTCL Keywords",
- "tkCommands",
- "expand",
- "user1",
- "user2",
- "user3",
- "user4",
- 0
- };
+static const char *const tclWordListDesc[] = {
+ "TCL Keywords",
+ "TK Keywords",
+ "iTCL Keywords",
+ "tkCommands",
+ "expand",
+ "user1",
+ "user2",
+ "user3",
+ "user4",
+ 0
+};
// this code supports folding in the colourizer
LexerModule lmTCL(SCLEX_TCL, ColouriseTCLDoc, "tcl", 0, tclWordListDesc);
Modified: scintilla/lexers/LexVHDL.cxx
7 lines changed, 4 insertions(+), 3 deletions(-)
===================================================================
@@ -388,13 +388,14 @@ static void FoldNoBoxVHDLDoc(
strcmp(s, "entity") == 0 ||
strcmp(s, "configuration") == 0 )
{
- if (strcmp(prevWord, "end") != 0)
+ if (strcmp(prevWord, "end") != 0 && lastStart)
{ // check for instantiated unit by backward searching for the colon.
- unsigned pos = lastStart-1;
+ unsigned pos = lastStart;
char chAtPos, styleAtPos;
do{// skip white spaces
+ pos--;
styleAtPos = styler.StyleAt(pos);
- chAtPos = styler.SafeGetCharAt(pos--);
+ chAtPos = styler.SafeGetCharAt(pos);
}while(pos>0 &&
(chAtPos == ' ' || chAtPos == '\t' ||
chAtPos == '\n' || chAtPos == '\r' ||
Modified: scintilla/lexers/LexVerilog.cxx
95 lines changed, 91 insertions(+), 4 deletions(-)
===================================================================
@@ -198,6 +198,15 @@ class LexerVerilog : public ILexerWithSubStyles {
OptionSetVerilog osVerilog;
enum { activeFlag = 0x40 };
SubStyles subStyles;
+
+ // states at end of line (EOL) during fold operations:
+ // foldExternFlag: EOL while parsing an extern function/task declaration terminated by ';'
+ // foldWaitDisableFlag: EOL while parsing wait or disable statement, terminated by "fork" or '('
+ // typdefFlag: EOL while parsing typedef statement, terminated by ';'
+ enum {foldExternFlag = 0x01, foldWaitDisableFlag = 0x02, typedefFlag = 0x04};
+ // map using line number as key to store fold state information
+ std::map<int, int> foldState;
+
public:
LexerVerilog() :
setWord(CharacterSet::setAlphaNum, "._", 0x80, true),
@@ -431,6 +440,7 @@ void SCI_METHOD LexerVerilog::Lex(unsigned int startPos, int length, int initSty
int activitySet = preproc.IsInactive() ? activeFlag : 0;
int lineEndNext = styler.LineEnd(curLine);
+ bool isEscapedId = false; // true when parsing an escaped Identifier
for (; sc.More(); sc.Forward()) {
if (sc.atLineStart) {
@@ -453,6 +463,7 @@ void SCI_METHOD LexerVerilog::Lex(unsigned int startPos, int length, int initSty
vlls.Add(curLine, preproc);
// Update the line state, so it can be seen by next line
styler.SetLineState(curLine, lineState);
+ isEscapedId = false; // EOL terminates an escaped Identifier
}
// Handle line continuation generically.
@@ -500,7 +511,7 @@ void SCI_METHOD LexerVerilog::Lex(unsigned int startPos, int length, int initSty
}
break;
case SCE_V_IDENTIFIER:
- if (!IsAWordChar(sc.ch) || (sc.ch == '.')) {
+ if (!isEscapedId &&(!IsAWordChar(sc.ch) || (sc.ch == '.'))) {
char s[100];
lineState &= 0xff00;
sc.GetCurrent(s, sizeof(s));
@@ -581,6 +592,7 @@ void SCI_METHOD LexerVerilog::Lex(unsigned int startPos, int length, int initSty
vlls.Add(curLine, preproc);
// Update the line state, so it can be seen by next line
styler.SetLineState(curLine, lineState);
+ isEscapedId = false; // EOL terminates an escaped Identifier
}
// Determine if a new state should be entered.
@@ -713,12 +725,19 @@ void SCI_METHOD LexerVerilog::Lex(unsigned int startPos, int length, int initSty
}
}
}
+ } else if (sc.ch == '\\') {
+ // escaped identifier, everything is ok up to whitespace
+ isEscapedId = true;
+ sc.SetState(SCE_V_IDENTIFIER|activitySet);
} else if (isoperator(static_cast<char>(sc.ch)) || sc.ch == '@' || sc.ch == '#') {
sc.SetState(SCE_V_OPERATOR|activitySet);
if (sc.ch == '.') lineState = kwDot;
if (sc.ch == ';') lineState = kwOther;
}
}
+ if (isEscapedId && isspacechar(sc.ch)) {
+ isEscapedId = false;
+ }
}
if (definitionsChanged) {
styler.ChangeLexerState(startPos, startPos + length);
@@ -756,9 +775,20 @@ void SCI_METHOD LexerVerilog::Fold(unsigned int startPos, int length, int initSt
bool foldAtBrace = 1;
bool foldAtParenthese = 1;
+ int lineCurrent = styler.GetLine(startPos);
+ // Move back one line to be compatible with LexerModule::Fold behavior, fixes problem with foldComment behavior
+ if (lineCurrent > 0) {
+ lineCurrent--;
+ int newStartPos = styler.LineStart(lineCurrent);
+ length += startPos - newStartPos;
+ startPos = newStartPos;
+ initStyle = 0;
+ if (startPos > 0) {
+ initStyle = styler.StyleAt(startPos - 1);
+ }
+ }
unsigned int endPos = startPos + length;
int visibleChars = 0;
- int lineCurrent = styler.GetLine(startPos);
int levelCurrent = SC_FOLDLEVELBASE;
if (lineCurrent > 0)
levelCurrent = styler.LevelAt(lineCurrent-1) >> 16;
@@ -767,6 +797,20 @@ void SCI_METHOD LexerVerilog::Fold(unsigned int startPos, int length, int initSt
char chNext = styler[startPos];
int styleNext = MaskActive(styler.StyleAt(startPos));
int style = MaskActive(initStyle);
+
+ // restore fold state (if it exists) for prior line
+ int stateCurrent = 0;
+ std::map<int,int>::iterator foldStateIterator = foldState.find(lineCurrent-1);
+ if (foldStateIterator != foldState.end()) {
+ stateCurrent = foldStateIterator->second;
+ }
+
+ // remove all foldState entries after lineCurrent-1
+ foldStateIterator = foldState.upper_bound(lineCurrent-1);
+ if (foldStateIterator != foldState.end()) {
+ foldState.erase(foldStateIterator, foldState.end());
+ }
+
for (unsigned int i = startPos; i < endPos; i++) {
char ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
@@ -822,6 +866,28 @@ void SCI_METHOD LexerVerilog::Fold(unsigned int startPos, int length, int initSt
levelNext--;
}
}
+ // semicolons terminate external declarations
+ if (ch == ';') {
+ // extern and pure virtual declarations terminated by semicolon
+ if (stateCurrent & foldExternFlag) {
+ levelNext--;
+ stateCurrent &= ~foldExternFlag;
+ }
+ // wait and disable statements terminated by semicolon
+ if (stateCurrent & foldWaitDisableFlag) {
+ stateCurrent &= ~foldWaitDisableFlag;
+ }
+ // typedef statements terminated by semicolon
+ if (stateCurrent & typedefFlag) {
+ stateCurrent &= ~typedefFlag;
+ }
+ }
+ // wait and disable statements containing '(' will not contain "fork" keyword, special processing is not needed
+ if (ch == '(') {
+ if (stateCurrent & foldWaitDisableFlag) {
+ stateCurrent &= ~foldWaitDisableFlag;
+ }
+ }
}
if (style == SCE_V_OPERATOR) {
if (foldAtBrace) {
@@ -837,7 +903,6 @@ void SCI_METHOD LexerVerilog::Fold(unsigned int startPos, int length, int initSt
if (styler.Match(j, "case") ||
styler.Match(j, "casex") ||
styler.Match(j, "casez") ||
- styler.Match(j, "class") ||
styler.Match(j, "function") ||
styler.Match(j, "generate") ||
styler.Match(j, "covergroup") ||
@@ -848,10 +913,19 @@ void SCI_METHOD LexerVerilog::Fold(unsigned int startPos, int length, int initSt
styler.Match(j, "specify") ||
styler.Match(j, "table") ||
styler.Match(j, "task") ||
- styler.Match(j, "fork") ||
(styler.Match(j, "module") && options.foldAtModule) ||
styler.Match(j, "begin")) {
levelNext++;
+ } else if (styler.Match(j, "class")) {
+ // class does not introduce a block when used in a typedef statement
+ if (!(stateCurrent & typedefFlag))
+ levelNext++;
+ } else if (styler.Match(j, "fork")) {
+ // fork does not introduce a block when used in a wait or disable statement
+ if (stateCurrent & foldWaitDisableFlag) {
+ stateCurrent &= ~foldWaitDisableFlag;
+ } else
+ levelNext++;
} else if (styler.Match(j, "endcase") ||
styler.Match(j, "endclass") ||
styler.Match(j, "endfunction") ||
@@ -870,6 +944,16 @@ void SCI_METHOD LexerVerilog::Fold(unsigned int startPos, int length, int initSt
(styler.Match(j, "endmodule") && options.foldAtModule) ||
(styler.Match(j, "end") && !IsAWordChar(styler.SafeGetCharAt(j + 3)))) {
levelNext--;
+ } else if (styler.Match(j, "extern") ||
+ styler.Match(j, "pure")) {
+ // extern and pure virtual functions/tasks are terminated by ';' not endfunction/endtask
+ stateCurrent |= foldExternFlag;
+ } else if (styler.Match(j, "disable") ||
+ styler.Match(j, "wait")) {
+ // fork does not introduce a block when used in a wait or disable statement
+ stateCurrent |= foldWaitDisableFlag;
+ } else if (styler.Match(j, "typedef")) {
+ stateCurrent |= typedefFlag;
}
}
if (atEOL) {
@@ -882,6 +966,9 @@ void SCI_METHOD LexerVerilog::Fold(unsigned int startPos, int length, int initSt
lev |= SC_FOLDLEVELWHITEFLAG;
if (levelUse < levelNext)
lev |= SC_FOLDLEVELHEADERFLAG;
+ if (stateCurrent) {
+ foldState[lineCurrent] = stateCurrent;
+ }
if (lev != styler.LevelAt(lineCurrent)) {
styler.SetLevel(lineCurrent, lev);
}
Modified: scintilla/src/CellBuffer.cxx
5 lines changed, 5 insertions(+), 0 deletions(-)
===================================================================
@@ -10,6 +10,7 @@
#include <stdio.h>
#include <stdarg.h>
+#include <stdexcept>
#include <algorithm>
#include "Platform.h"
@@ -786,6 +787,10 @@ const Action &CellBuffer::GetUndoStep() const {
void CellBuffer::PerformUndoStep() {
const Action &actionStep = uh.GetUndoStep();
if (actionStep.at == insertAction) {
+ if (substance.Length() < actionStep.lenData) {
+ throw std::runtime_error(
+ "CellBuffer::PerformUndoStep: deletion must be less than document length.");
+ }
BasicDeleteChars(actionStep.position, actionStep.lenData);
} else if (actionStep.at == removeAction) {
BasicInsertString(actionStep.position, actionStep.data, actionStep.lenData);
Modified: scintilla/src/Document.cxx
45 lines changed, 41 insertions(+), 4 deletions(-)
===================================================================
@@ -787,6 +787,27 @@ int SCI_METHOD Document::GetRelativePosition(int positionStart, int characterOff
return pos;
}
+int Document::GetRelativePositionUTF16(int positionStart, int characterOffset) const {
+ int pos = positionStart;
+ if (dbcsCodePage) {
+ const int increment = (characterOffset > 0) ? 1 : -1;
+ while (characterOffset != 0) {
+ const int posNext = NextPosition(pos, increment);
+ if (posNext == pos)
+ return INVALID_POSITION;
+ if (abs(pos-posNext) > 3) // 4 byte character = 2*UTF16.
+ characterOffset -= increment;
+ pos = posNext;
+ characterOffset -= increment;
+ }
+ } else {
+ pos = positionStart + characterOffset;
+ if ((pos < 0) || (pos > Length()))
+ return INVALID_POSITION;
+ }
+ return pos;
+}
+
int SCI_METHOD Document::GetCharacterAndWidth(int position, int *pWidth) const {
int character;
int bytesInCharacter = 1;
@@ -1308,6 +1329,21 @@ int Document::CountCharacters(int startPos, int endPos) const {
return count;
}
+int Document::CountUTF16(int startPos, int endPos) const {
+ startPos = MovePositionOutsideChar(startPos, 1, false);
+ endPos = MovePositionOutsideChar(endPos, -1, false);
+ int count = 0;
+ int i = startPos;
+ while (i < endPos) {
+ count++;
+ const int next = NextPosition(i, 1);
+ if ((next - i) > 3)
+ count++;
+ i = next;
+ }
+ return count;
+}
+
int Document::FindColumn(int line, int column) {
int position = LineStart(line);
if ((line >= 0) && (line < LinesTotal())) {
@@ -2347,6 +2383,9 @@ class UTF8Iterator : public std::iterator<std::bidirectional_iterator_tag, wchar
doc(doc_), position(position_), characterIndex(0), lenBytes(0), lenCharacters(0) {
buffered[0] = 0;
buffered[1] = 0;
+ if (doc) {
+ ReadCharacter();
+ }
}
UTF8Iterator(const UTF8Iterator &other) {
doc = other.doc;
@@ -2369,10 +2408,8 @@ class UTF8Iterator : public std::iterator<std::bidirectional_iterator_tag, wchar
}
return *this;
}
- wchar_t operator*() {
- if (lenCharacters == 0) {
- ReadCharacter();
- }
+ wchar_t operator*() const {
+ assert(lenCharacters != 0);
return buffered[characterIndex];
}
UTF8Iterator &operator++() {
Modified: scintilla/src/Document.h
2 lines changed, 2 insertions(+), 0 deletions(-)
===================================================================
@@ -279,6 +279,7 @@ class Document : PerLine, public IDocumentWithLineEnd, public ILoader {
int NextPosition(int pos, int moveDir) const;
bool NextCharacter(int &pos, int moveDir) const; // Returns true if pos changed
int SCI_METHOD GetRelativePosition(int positionStart, int characterOffset) const;
+ int GetRelativePositionUTF16(int positionStart, int characterOffset) const;
int SCI_METHOD GetCharacterAndWidth(int position, int *pWidth) const;
int SCI_METHOD CodePage() const;
bool SCI_METHOD IsDBCSLeadByte(char ch) const;
@@ -322,6 +323,7 @@ class Document : PerLine, public IDocumentWithLineEnd, public ILoader {
int GetLineIndentPosition(int line) const;
int GetColumn(int position);
int CountCharacters(int startPos, int endPos) const;
+ int CountUTF16(int startPos, int endPos) const;
int FindColumn(int line, int column);
void Indent(bool forwards, int lineBottom, int lineTop);
static std::string TransformLineEnds(const char *s, size_t len, int eolModeWanted);
Modified: scintilla/src/EditModel.cxx
1 lines changed, 1 insertions(+), 0 deletions(-)
===================================================================
@@ -65,6 +65,7 @@ EditModel::EditModel() {
imeInteraction = imeWindowed;
foldFlags = 0;
hotspot = Range(invalidPosition);
+ hoverIndicatorPos = invalidPosition;
wrapWidth = LineLayout::wrapWidthInfinite;
pdoc = new Document();
pdoc->AddRef();
Modified: scintilla/src/EditModel.h
1 lines changed, 1 insertions(+), 0 deletions(-)
===================================================================
@@ -48,6 +48,7 @@ class EditModel {
ContractionState cs;
// Hotspot support
Range hotspot;
+ int hoverIndicatorPos;
// Wrapping support
int wrapWidth;
Modified: scintilla/src/EditView.cxx
58 lines changed, 43 insertions(+), 15 deletions(-)
===================================================================
@@ -445,7 +445,7 @@ void EditView::LayoutLine(const EditModel &model, int line, Surface *surface, co
ll->positions[0] = 0;
bool lastSegItalics = false;
- BreakFinder bfLayout(ll, NULL, Range(0, numCharsInLine), posLineStart, 0, false, model.pdoc, &model.reprs);
+ BreakFinder bfLayout(ll, NULL, Range(0, numCharsInLine), posLineStart, 0, false, model.pdoc, &model.reprs, NULL);
while (bfLayout.More()) {
const TextSegment ts = bfLayout.Next();
@@ -793,7 +793,7 @@ void EditView::DrawEOL(Surface *surface, const EditModel &model, const ViewStyle
XYPOSITION xEol = static_cast<XYPOSITION>(ll->positions[lineEnd] - subLineStart);
// Fill the virtual space and show selections within it
- if (virtualSpace) {
+ if (virtualSpace > 0.0f) {
rcSegment.left = xEol + xStart;
rcSegment.right = xEol + xStart + virtualSpace;
surface->FillRectangle(rcSegment, background.isSet ? background : vsDraw.styles[ll->styles[ll->numCharsInLine]].back);
@@ -940,18 +940,18 @@ void EditView::DrawEOL(Surface *surface, const EditModel &model, const ViewStyle
}
static void DrawIndicator(int indicNum, int startPos, int endPos, Surface *surface, const ViewStyle &vsDraw,
- const LineLayout *ll, int xStart, PRectangle rcLine, int subLine) {
+ const LineLayout *ll, int xStart, PRectangle rcLine, int subLine, Indicator::DrawState drawState, int value) {
const XYPOSITION subLineStart = ll->positions[ll->LineStart(subLine)];
PRectangle rcIndic(
ll->positions[startPos] + xStart - subLineStart,
rcLine.top + vsDraw.maxAscent,
ll->positions[endPos] + xStart - subLineStart,
rcLine.top + vsDraw.maxAscent + 3);
- vsDraw.indicators[indicNum].Draw(surface, rcIndic, rcLine);
+ vsDraw.indicators[indicNum].Draw(surface, rcIndic, rcLine, drawState, value);
}
static void DrawIndicators(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll,
- int line, int xStart, PRectangle rcLine, int subLine, int lineEnd, bool under) {
+ int line, int xStart, PRectangle rcLine, int subLine, int lineEnd, bool under, int hoverIndicatorPos) {
// Draw decorators
const int posLineStart = model.pdoc->LineStart(line);
const int lineStart = ll->LineStart(subLine);
@@ -967,8 +967,12 @@ static void DrawIndicators(Surface *surface, const EditModel &model, const ViewS
int endPos = deco->rs.EndRun(startPos);
if (endPos > posLineEnd)
endPos = posLineEnd;
+ const bool hover = vsDraw.indicators[deco->indicator].IsDynamic() &&
+ ((hoverIndicatorPos >= startPos) && (hoverIndicatorPos <= endPos));
+ const int value = deco->rs.ValueAt(startPos);
+ Indicator::DrawState drawState = hover ? Indicator::drawHover : Indicator::drawNormal;
DrawIndicator(deco->indicator, startPos - posLineStart, endPos - posLineStart,
- surface, vsDraw, ll, xStart, rcLine, subLine);
+ surface, vsDraw, ll, xStart, rcLine, subLine, drawState, value);
startPos = endPos;
if (!deco->rs.ValueAt(startPos)) {
startPos = deco->rs.EndRun(startPos);
@@ -986,13 +990,13 @@ static void DrawIndicators(Surface *surface, const EditModel &model, const ViewS
if (rangeLine.ContainsCharacter(model.braces[0])) {
int braceOffset = model.braces[0] - posLineStar@@ Diff output truncated at 100000 characters. @@
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
More information about the Commits
mailing list