diff options
-rw-r--r-- | scintilla/include/Platform.h | 6 | ||||
-rw-r--r-- | scintilla/lexers/LexPython.cxx | 51 | ||||
-rw-r--r-- | scintilla/src/Document.cxx | 23 | ||||
-rw-r--r-- | scintilla/src/Document.h | 2 | ||||
-rw-r--r-- | scintilla/src/KeyMap.h | 1 | ||||
-rw-r--r-- | scintilla/src/PositionCache.cxx | 8 | ||||
-rw-r--r-- | scintilla/src/PositionCache.h | 2 | ||||
-rw-r--r-- | scintilla/src/ScintillaBase.cxx | 3 |
8 files changed, 50 insertions, 46 deletions
diff --git a/scintilla/include/Platform.h b/scintilla/include/Platform.h index e96c194..99a2302 100644 --- a/scintilla/include/Platform.h +++ b/scintilla/include/Platform.h @@ -16,6 +16,7 @@ #define PLAT_GTK 0
#define PLAT_GTK_WIN32 0
+#define PLAT_GTK_MACOSX 0
#define PLAT_MACOSX 0
#define PLAT_WIN 0
#define PLAT_WX 0
@@ -38,6 +39,11 @@ #define PLAT_GTK_WIN32 1
#endif
+#if defined(__APPLE__)
+#undef PLAT_GTK_MACOSX
+#define PLAT_GTK_MACOSX 1
+#endif
+
#elif defined(__APPLE__)
#undef PLAT_MACOSX
diff --git a/scintilla/lexers/LexPython.cxx b/scintilla/lexers/LexPython.cxx index 37c5422..ecd00f9 100644 --- a/scintilla/lexers/LexPython.cxx +++ b/scintilla/lexers/LexPython.cxx @@ -165,6 +165,11 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle, // Set to 1 to allow strings to span newline characters.
bool stringsOverNewline = styler.GetPropertyInt("lexer.python.strings.over.newline") != 0;
+ // property lexer.python.keywords2.no.sub.identifiers
+ // When enabled, it will not style keywords2 items that are used as a sub-identifier.
+ // Example: when set, will not highlight "foo.open" when "open" is a keywords2 item.
+ const bool keywords2NoSubIdentifiers = styler.GetPropertyInt("lexer.python.keywords2.no.sub.identifiers") != 0;
+
initStyle = initStyle & 31;
if (initStyle == SCE_P_STRINGEOL) {
initStyle = SCE_P_DEFAULT;
@@ -264,12 +269,16 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle, }
}
} else if (keywords2.InList(s)) {
- // We don't want to highlight keywords2
- // that are used as a sub-identifier,
- // i.e. not open in "foo.open".
- int pos = styler.GetStartSegment() - 1;
- if (pos < 0 || (styler.SafeGetCharAt(pos, '\0') != '.'))
+ if (keywords2NoSubIdentifiers) {
+ // We don't want to highlight keywords2
+ // that are used as a sub-identifier,
+ // i.e. not open in "foo.open".
+ int pos = styler.GetStartSegment() - 1;
+ if (pos < 0 || (styler.SafeGetCharAt(pos, '\0') != '.'))
+ style = SCE_P_WORD2;
+ } else {
style = SCE_P_WORD2;
+ }
}
sc.ChangeState(style);
sc.SetState(SCE_P_DEFAULT);
@@ -422,10 +431,6 @@ static void FoldPyDoc(unsigned int startPos, int length, int /*initStyle - unuse const int maxLines = (maxPos == styler.Length()) ? styler.GetLine(maxPos) : styler.GetLine(maxPos - 1); // Requested last line
const int docLines = styler.GetLine(styler.Length()); // Available last line
- // property fold.comment.python
- // This option enables folding multi-line comments when using the Python lexer.
- const bool foldComment = styler.GetPropertyInt("fold.comment.python") != 0;
-
// property fold.quotes.python
// This option enables folding multi-line quoted strings when using the Python lexer.
const bool foldQuotes = styler.GetPropertyInt("fold.quotes.python") != 0;
@@ -455,14 +460,11 @@ static void FoldPyDoc(unsigned int startPos, int length, int /*initStyle - unuse if (lineCurrent >= 1)
prev_state = styler.StyleAt(startPos - 1) & 31;
int prevQuote = foldQuotes && ((prev_state == SCE_P_TRIPLE) || (prev_state == SCE_P_TRIPLEDOUBLE));
- int prevComment = 0;
- if (lineCurrent >= 1)
- prevComment = foldComment && IsCommentLine(lineCurrent - 1, styler);
// Process all characters to end of requested range or end of any triple quote
- // or comment that hangs over the end of the range. Cap processing in all cases
- // to end of document (in case of unclosed quote or comment at end).
- while ((lineCurrent <= docLines) && ((lineCurrent <= maxLines) || prevQuote || prevComment)) {
+ //that hangs over the end of the range. Cap processing in all cases
+ // to end of document (in case of unclosed quote at end).
+ while ((lineCurrent <= docLines) && ((lineCurrent <= maxLines) || prevQuote)) {
// Gather info
int lev = indentCurrent;
@@ -478,11 +480,7 @@ static void FoldPyDoc(unsigned int startPos, int length, int /*initStyle - unuse }
const int quote_start = (quote && !prevQuote);
const int quote_continue = (quote && prevQuote);
- const int comment = foldComment && IsCommentLine(lineCurrent, styler);
- const int comment_start = (comment && !prevComment && (lineNext <= docLines) &&
- IsCommentLine(lineNext, styler) && ((lev & SC_FOLDLEVELNUMBERMASK) > SC_FOLDLEVELBASE));
- const int comment_continue = (comment && prevComment);
- if ((!quote || !prevQuote) && !comment)
+ if (!quote || !prevQuote)
indentCurrentLevel = indentCurrent & SC_FOLDLEVELNUMBERMASK;
if (quote)
indentNext = indentCurrentLevel;
@@ -495,12 +493,6 @@ static void FoldPyDoc(unsigned int startPos, int length, int /*initStyle - unuse } else if (quote_continue || prevQuote) {
// Add level to rest of lines in the string
lev = lev + 1;
- } else if (comment_start) {
- // Place fold point at start of a block of comments
- lev |= SC_FOLDLEVELHEADERFLAG;
- } else if (comment_continue) {
- // Add level to rest of lines in the block
- lev = lev + 1;
}
// Skip past any blank lines for next indent level info; we skip also
@@ -548,15 +540,14 @@ static void FoldPyDoc(unsigned int startPos, int length, int /*initStyle - unuse }
}
- // Set fold header on non-quote/non-comment line
- if (!quote && !comment && !(indentCurrent & SC_FOLDLEVELWHITEFLAG)) {
+ // Set fold header on non-quote line
+ if (!quote && !(indentCurrent & SC_FOLDLEVELWHITEFLAG)) {
if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext & SC_FOLDLEVELNUMBERMASK))
lev |= SC_FOLDLEVELHEADERFLAG;
}
- // Keep track of triple quote and block comment state of previous line
+ // Keep track of triple quote state of previous line
prevQuote = quote;
- prevComment = comment_start || comment_continue;
// Set fold level for this line and move to next line
styler.SetLevel(lineCurrent, foldCompact ? lev : lev & ~SC_FOLDLEVELWHITEFLAG);
diff --git a/scintilla/src/Document.cxx b/scintilla/src/Document.cxx index c45b582..ee621bf 100644 --- a/scintilla/src/Document.cxx +++ b/scintilla/src/Document.cxx @@ -662,7 +662,8 @@ bool SCI_METHOD Document::IsDBCSLeadByte(char ch) const { case 932:
// Shift_jis
return ((uch >= 0x81) && (uch <= 0x9F)) ||
- ((uch >= 0xE0) && (uch <= 0xEF));
+ ((uch >= 0xE0) && (uch <= 0xFC));
+ // Lead bytes F0 to FC may be a Microsoft addition.
case 936:
// GBK
return (uch >= 0x81) && (uch <= 0xFE);
@@ -1112,17 +1113,17 @@ void Document::Indent(bool forwards, int lineBottom, int lineTop) { // Convert line endings for a piece of text to a particular mode.
// Stop at len or when a NUL is found.
// Caller must delete the returned pointer.
-char *Document::TransformLineEnds(int *pLenOut, const char *s, size_t len, int eolMode) {
+char *Document::TransformLineEnds(int *pLenOut, const char *s, size_t len, int eolModeWanted) {
char *dest = new char[2 * len + 1];
const char *sptr = s;
char *dptr = dest;
for (size_t i = 0; (i < len) && (*sptr != '\0'); i++) {
if (*sptr == '\n' || *sptr == '\r') {
- if (eolMode == SC_EOL_CR) {
+ if (eolModeWanted == SC_EOL_CR) {
*dptr++ = '\r';
- } else if (eolMode == SC_EOL_LF) {
+ } else if (eolModeWanted == SC_EOL_LF) {
*dptr++ = '\n';
- } else { // eolMode == SC_EOL_CRLF
+ } else { // eolModeWanted == SC_EOL_CRLF
*dptr++ = '\r';
*dptr++ = '\n';
}
@@ -1427,7 +1428,6 @@ long Document::FindText(int minPos, int maxPos, const char *search, // Compute actual search ranges needed
const int lengthFind = (*length == -1) ? static_cast<int>(strlen(search)) : *length;
- const int endSearch = (startPos <= endPos) ? endPos - lengthFind + 1 : endPos;
//Platform::DebugPrintf("Find %d %d %s %d\n", startPos, endPos, ft->lpstrText, lengthFind);
const int limitPos = Platform::Maximum(startPos, endPos);
@@ -1437,6 +1437,7 @@ long Document::FindText(int minPos, int maxPos, const char *search, pos = NextPosition(pos, increment);
}
if (caseSensitive) {
+ const int endSearch = (startPos <= endPos) ? endPos - lengthFind + 1 : endPos;
while (forward ? (pos < endSearch) : (pos >= endSearch)) {
bool found = (pos + lengthFind) <= limitPos;
for (int indexSearch = 0; (indexSearch < lengthFind) && found; indexSearch++) {
@@ -1454,7 +1455,7 @@ long Document::FindText(int minPos, int maxPos, const char *search, std::vector<char> searchThing(lengthFind * maxBytesCharacter * maxFoldingExpansion + 1);
const int lenSearch = static_cast<int>(
pcf->Fold(&searchThing[0], searchThing.size(), search, lengthFind));
- while (forward ? (pos < endSearch) : (pos >= endSearch)) {
+ while (forward ? (pos < endPos) : (pos >= endPos)) {
int widthFirstCharacter = 0;
int indexDocument = 0;
int indexSearch = 0;
@@ -1467,6 +1468,8 @@ long Document::FindText(int minPos, int maxPos, const char *search, const int widthChar = static_cast<int>(ExtractChar(pos + indexDocument, bytes));
if (!widthFirstCharacter)
widthFirstCharacter = widthChar;
+ if ((pos + indexDocument + widthChar) > limitPos)
+ break;
char folded[maxBytesCharacter * maxFoldingExpansion + 1];
const int lenFlat = static_cast<int>(pcf->Fold(folded, sizeof(folded), bytes, widthChar));
folded[lenFlat] = 0;
@@ -1494,7 +1497,7 @@ long Document::FindText(int minPos, int maxPos, const char *search, std::vector<char> searchThing(lengthFind * maxBytesCharacter * maxFoldingExpansion + 1);
const int lenSearch = static_cast<int>(
pcf->Fold(&searchThing[0], searchThing.size(), search, lengthFind));
- while (forward ? (pos < endSearch) : (pos >= endSearch)) {
+ while (forward ? (pos < endPos) : (pos >= endPos)) {
int indexDocument = 0;
int indexSearch = 0;
bool characterMatches = true;
@@ -1506,6 +1509,8 @@ long Document::FindText(int minPos, int maxPos, const char *search, const int widthChar = IsDBCSLeadByte(bytes[0]) ? 2 : 1;
if (widthChar == 2)
bytes[1] = cb.CharAt(pos + indexDocument + 1);
+ if ((pos + indexDocument + widthChar) > limitPos)
+ break;
char folded[maxBytesCharacter * maxFoldingExpansion + 1];
const int lenFlat = static_cast<int>(pcf->Fold(folded, sizeof(folded), bytes, widthChar));
folded[lenFlat] = 0;
@@ -1524,7 +1529,7 @@ long Document::FindText(int minPos, int maxPos, const char *search, break;
}
} else {
- CaseFolderTable caseFolder;
+ const int endSearch = (startPos <= endPos) ? endPos - lengthFind + 1 : endPos;
std::vector<char> searchThing(lengthFind + 1);
pcf->Fold(&searchThing[0], searchThing.size(), search, lengthFind);
while (forward ? (pos < endSearch) : (pos >= endSearch)) {
diff --git a/scintilla/src/Document.h b/scintilla/src/Document.h index 29adf33..1816bea 100644 --- a/scintilla/src/Document.h +++ b/scintilla/src/Document.h @@ -303,7 +303,7 @@ public: int GetColumn(int position);
int FindColumn(int line, int column);
void Indent(bool forwards, int lineBottom, int lineTop);
- static char *TransformLineEnds(int *pLenOut, const char *s, size_t len, int eolMode);
+ static char *TransformLineEnds(int *pLenOut, const char *s, size_t len, int eolModeWanted);
void ConvertLineEnds(int eolModeSet);
void SetReadOnly(bool set) { cb.SetReadOnly(set); }
bool IsReadOnly() { return cb.IsReadOnly(); }
diff --git a/scintilla/src/KeyMap.h b/scintilla/src/KeyMap.h index c1b1a10..6584b29 100644 --- a/scintilla/src/KeyMap.h +++ b/scintilla/src/KeyMap.h @@ -16,6 +16,7 @@ namespace Scintilla { #define SCI_SHIFT SCMOD_SHIFT
#define SCI_CTRL SCMOD_CTRL
#define SCI_ALT SCMOD_ALT
+#define SCI_META SCMOD_META
#define SCI_CSHIFT (SCI_CTRL | SCI_SHIFT)
#define SCI_ASHIFT (SCI_ALT | SCI_SHIFT)
diff --git a/scintilla/src/PositionCache.cxx b/scintilla/src/PositionCache.cxx index 50d964d..bc0d353 100644 --- a/scintilla/src/PositionCache.cxx +++ b/scintilla/src/PositionCache.cxx @@ -542,16 +542,16 @@ bool PositionCacheEntry::Retrieve(unsigned int styleNumber_, const char *s_, }
}
-int PositionCacheEntry::Hash(unsigned int styleNumber, const char *s, unsigned int len) {
+int PositionCacheEntry::Hash(unsigned int styleNumber_, const char *s, unsigned int len_) {
unsigned int ret = s[0] << 7;
- for (unsigned int i=0; i<len; i++) {
+ for (unsigned int i=0; i<len_; i++) {
ret *= 1000003;
ret ^= s[i];
}
ret *= 1000003;
- ret ^= len;
+ ret ^= len_;
ret *= 1000003;
- ret ^= styleNumber;
+ ret ^= styleNumber_;
return ret;
}
diff --git a/scintilla/src/PositionCache.h b/scintilla/src/PositionCache.h index 45c09ea..13436cb 100644 --- a/scintilla/src/PositionCache.h +++ b/scintilla/src/PositionCache.h @@ -110,7 +110,7 @@ public: void Set(unsigned int styleNumber_, const char *s_, unsigned int len_, int *positions_, unsigned int clock);
void Clear();
bool Retrieve(unsigned int styleNumber_, const char *s_, unsigned int len_, int *positions_) const;
- static int Hash(unsigned int styleNumber, const char *s, unsigned int len);
+ static int Hash(unsigned int styleNumber_, const char *s, unsigned int len);
bool NewerThan(const PositionCacheEntry &other) const;
void ResetClock();
};
diff --git a/scintilla/src/ScintillaBase.cxx b/scintilla/src/ScintillaBase.cxx index 4cec34a..8afa6e7 100644 --- a/scintilla/src/ScintillaBase.cxx +++ b/scintilla/src/ScintillaBase.cxx @@ -205,7 +205,8 @@ void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) { if (ac.chooseSingle && (listType == 0)) {
if (list && !strchr(list, ac.GetSeparator())) {
const char *typeSep = strchr(list, ac.GetTypesep());
- int lenInsert = static_cast<int>((typeSep) ? (typeSep-list) : strlen(list));
+ int lenInsert = typeSep ?
+ static_cast<int>(typeSep-list) : static_cast<int>(strlen(list));
if (ac.ignoreCase) {
SetEmptySelection(sel.MainCaret() - lenEntered);
pdoc->DeleteChars(sel.MainCaret(), lenEntered);
|