Skip to content

Commit

Permalink
Update Scintilla to version 3.6.4
Browse files Browse the repository at this point in the history
  • Loading branch information
b4n committed Mar 13, 2016
1 parent 3615f5a commit 24f9198
Show file tree
Hide file tree
Showing 13 changed files with 126 additions and 37 deletions.
4 changes: 3 additions & 1 deletion scintilla/gtk/ScintillaGTK.cxx
Expand Up @@ -2485,7 +2485,9 @@ void ScintillaGTK::PreeditChangedInlineThis() {
MoveImeCarets( - (imeCharPos[preeditStr.uniStrLen]) + imeCharPos[preeditStr.cursor_pos]);

if (KoreanIME()) {
#if !PLAT_GTK_WIN32
MoveImeCarets( - imeCharPos[1]); // always 2 bytes for DBCS or 3 bytes for UTF8.
#endif
view.imeCaretBlockOverride = true;
}

Expand Down Expand Up @@ -3053,7 +3055,7 @@ sptr_t scintilla_send_message(ScintillaObject *sci, unsigned int iMessage, uptr_
}

GEANY_API_SYMBOL
sptr_t scintilla_object_send_message(ScintillaObject *sci, unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
gintptr scintilla_object_send_message(ScintillaObject *sci, unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return scintilla_send_message(sci, iMessage, wParam, lParam);
}

Expand Down
2 changes: 1 addition & 1 deletion scintilla/include/ScintillaWidget.h
Expand Up @@ -44,7 +44,7 @@ struct _ScintillaClass {

GType scintilla_object_get_type (void);
GtkWidget* scintilla_object_new (void);
long scintilla_object_send_message (ScintillaObject *sci, unsigned int iMessage, guintptr wParam, gintptr lParam);
gintptr scintilla_object_send_message (ScintillaObject *sci, unsigned int iMessage, guintptr wParam, gintptr lParam);

#ifndef G_IR_SCANNING
/* The legacy names confuse the g-ir-scanner program */
Expand Down
4 changes: 2 additions & 2 deletions scintilla/lexers/LexCPP.cxx
Expand Up @@ -1349,14 +1349,14 @@ void SCI_METHOD LexerCPP::Fold(Sci_PositionU startPos, Sci_Position length, int
}
}
if (options.foldSyntaxBased && (style == SCE_C_OPERATOR)) {
if (ch == '{' || ch == '[') {
if (ch == '{' || ch == '[' || ch == '(') {
// Measure the minimum before a '{' to allow
// folding on "} else {"
if (levelMinCurrent > levelNext) {
levelMinCurrent = levelNext;
}
levelNext++;
} else if (ch == '}' || ch == ']') {
} else if (ch == '}' || ch == ']' || ch == ')') {
levelNext--;
}
}
Expand Down
2 changes: 1 addition & 1 deletion scintilla/lexers/LexHTML.cxx
Expand Up @@ -828,7 +828,7 @@ static void ColouriseHyperTextDoc(Sci_PositionU startPos, Sci_Position length, i
// handle end of Mako comment line
else if (isMako && makoComment && (ch == '\r' || ch == '\n')) {
makoComment = 0;
styler.ColourTo(i, StateToPrint);
styler.ColourTo(i - 1, StateToPrint);
if (scriptLanguage == eScriptPython) {
state = SCE_HP_DEFAULT;
} else {
Expand Down
46 changes: 45 additions & 1 deletion scintilla/lexers/LexRuby.cxx
Expand Up @@ -433,6 +433,32 @@ static bool haveTargetMatch(Sci_Position currPos,
return true;
}

// Finds the start position of the expression containing @p pos
// @p min_pos should be a known expression start, e.g. the start of the line
static Sci_Position findExpressionStart(Sci_Position pos,
Sci_Position min_pos,
Accessor &styler) {
int depth = 0;
for (; pos > min_pos; pos -= 1) {
int style = styler.StyleAt(pos - 1);
if (style == SCE_RB_OPERATOR) {
int ch = styler[pos - 1];
if (ch == '}' || ch == ')' || ch == ']') {
depth += 1;
} else if (ch == '{' || ch == '(' || ch == '[') {
if (depth == 0) {
break;
} else {
depth -= 1;
}
} else if (ch == ';' && depth == 0) {
break;
}
}
}
return pos;
}

// We need a check because the form
// [identifier] <<[target]
// is ambiguous. The Ruby lexer/parser resolves it by
Expand All @@ -458,14 +484,18 @@ static bool sureThisIsNotHeredoc(Sci_Position lt2StartPos,
const bool definitely_not_a_here_doc = true;
const bool looks_like_a_here_doc = false;

// find the expression start rather than the line start
Sci_Position exprStartPosn = findExpressionStart(lt2StartPos, lineStartPosn, styler);

// Find the first word after some whitespace
Sci_Position firstWordPosn = skipWhitespace(lineStartPosn, lt2StartPos, styler);
Sci_Position firstWordPosn = skipWhitespace(exprStartPosn, lt2StartPos, styler);
if (firstWordPosn >= lt2StartPos) {
return definitely_not_a_here_doc;
}
prevStyle = styler.StyleAt(firstWordPosn);
// If we have '<<' following a keyword, it's not a heredoc
if (prevStyle != SCE_RB_IDENTIFIER
&& prevStyle != SCE_RB_SYMBOL
&& prevStyle != SCE_RB_INSTANCE_VAR
&& prevStyle != SCE_RB_CLASS_VAR) {
return definitely_not_a_here_doc;
Expand Down Expand Up @@ -503,6 +533,16 @@ static bool sureThisIsNotHeredoc(Sci_Position lt2StartPos,
}
// Skip next batch of white-space
firstWordPosn = skipWhitespace(firstWordPosn, lt2StartPos, styler);
// possible symbol for an implicit hash argument
if (firstWordPosn < lt2StartPos && styler.StyleAt(firstWordPosn) == SCE_RB_SYMBOL) {
for (; firstWordPosn <= lt2StartPos; firstWordPosn += 1) {
if (styler.StyleAt(firstWordPosn) != SCE_RB_SYMBOL) {
break;
}
}
// Skip next batch of white-space
firstWordPosn = skipWhitespace(firstWordPosn, lt2StartPos, styler);
}
if (firstWordPosn != lt2StartPos) {
// Have [[^ws[identifier]ws[*something_else*]ws<<
return definitely_not_a_here_doc;
Expand Down Expand Up @@ -1088,6 +1128,10 @@ static void ColouriseRbDoc(Sci_PositionU startPos, Sci_Position length, int init
// <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>
} else if (ch == ':'
&& isSafeWordcharOrHigh(chPrev)
&& strchr(" \t\n\r", chNext) != NULL) {
state = SCE_RB_SYMBOL;
} else if ((ch == '?' || ch == '!')
&& isSafeWordcharOrHigh(chPrev)
&& !isSafeWordcharOrHigh(chNext)) {
Expand Down
26 changes: 24 additions & 2 deletions scintilla/lexers/LexRust.cxx
Expand Up @@ -407,7 +407,18 @@ static void ScanCharacterLiteralOrLifetime(Accessor &styler, Sci_Position& pos,
valid_char = ScanNumericEscape(styler, pos, 2, false);
} else if (n == 'u' && !ascii_only) {
pos += 2;
valid_char = ScanNumericEscape(styler, pos, 4, false);
if (styler.SafeGetCharAt(pos, '\0') != '{') {
// old-style
valid_char = ScanNumericEscape(styler, pos, 4, false);
} else {
int n_digits = 0;
while (IsADigit(styler.SafeGetCharAt(++pos, '\0'), 16) && n_digits++ < 6) {
}
if (n_digits > 0 && styler.SafeGetCharAt(pos, '\0') == '}')
pos++;
else
valid_char = false;
}
} else if (n == 'U' && !ascii_only) {
pos += 2;
valid_char = ScanNumericEscape(styler, pos, 8, false);
Expand Down Expand Up @@ -579,7 +590,18 @@ static void ResumeString(Accessor &styler, Sci_Position& pos, Sci_Position max,
error = !ScanNumericEscape(styler, pos, 2, true);
} else if (n == 'u' && !ascii_only) {
pos += 2;
error = !ScanNumericEscape(styler, pos, 4, true);
if (styler.SafeGetCharAt(pos, '\0') != '{') {
// old-style
error = !ScanNumericEscape(styler, pos, 4, true);
} else {
int n_digits = 0;
while (IsADigit(styler.SafeGetCharAt(++pos, '\0'), 16) && n_digits++ < 6) {
}
if (n_digits > 0 && styler.SafeGetCharAt(pos, '\0') == '}')
pos++;
else
error = true;
}
} else if (n == 'U' && !ascii_only) {
pos += 2;
error = !ScanNumericEscape(styler, pos, 8, true);
Expand Down
2 changes: 1 addition & 1 deletion scintilla/scintilla_changes.patch
Expand Up @@ -15,7 +15,7 @@ index 0871ca2..49dc278 100644
}

+GEANY_API_SYMBOL
sptr_t scintilla_object_send_message(ScintillaObject *sci, unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
gintptr scintilla_object_send_message(ScintillaObject *sci, unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return scintilla_send_message(sci, iMessage, wParam, lParam);
}
@@ -3062,6 +3064,7 @@ extern void Platform_Initialise();
Expand Down
36 changes: 18 additions & 18 deletions scintilla/src/Document.cxx
Expand Up @@ -436,12 +436,12 @@ static bool IsSubordinate(int levelStart, int levelTry) {
if (levelTry & SC_FOLDLEVELWHITEFLAG)
return true;
else
return (levelStart & SC_FOLDLEVELNUMBERMASK) < (levelTry & SC_FOLDLEVELNUMBERMASK);
return LevelNumber(levelStart) < LevelNumber(levelTry);
}

int Document::GetLastChild(int lineParent, int level, int lastLine) {
if (level == -1)
level = GetLevel(lineParent) & SC_FOLDLEVELNUMBERMASK;
level = LevelNumber(GetLevel(lineParent));
int maxLine = LinesTotal();
int lookLastLine = (lastLine != -1) ? Platform::Minimum(LinesTotal() - 1, lastLine) : -1;
int lineMaxSubord = lineParent;
Expand All @@ -454,7 +454,7 @@ int Document::GetLastChild(int lineParent, int level, int lastLine) {
lineMaxSubord++;
}
if (lineMaxSubord > lineParent) {
if (level > (GetLevel(lineMaxSubord + 1) & SC_FOLDLEVELNUMBERMASK)) {
if (level > LevelNumber(GetLevel(lineMaxSubord + 1))) {
// Have chewed up some whitespace that belongs to a parent so seek back
if (GetLevel(lineMaxSubord) & SC_FOLDLEVELWHITEFLAG) {
lineMaxSubord--;
Expand All @@ -465,16 +465,16 @@ int Document::GetLastChild(int lineParent, int level, int lastLine) {
}

int Document::GetFoldParent(int line) const {
int level = GetLevel(line) & SC_FOLDLEVELNUMBERMASK;
int level = LevelNumber(GetLevel(line));
int lineLook = line - 1;
while ((lineLook > 0) && (
(!(GetLevel(lineLook) & SC_FOLDLEVELHEADERFLAG)) ||
((GetLevel(lineLook) & SC_FOLDLEVELNUMBERMASK) >= level))
(LevelNumber(GetLevel(lineLook)) >= level))
) {
lineLook--;
}
if ((GetLevel(lineLook) & SC_FOLDLEVELHEADERFLAG) &&
((GetLevel(lineLook) & SC_FOLDLEVELNUMBERMASK) < level)) {
(LevelNumber(GetLevel(lineLook)) < level)) {
return lineLook;
} else {
return -1;
Expand All @@ -487,11 +487,11 @@ void Document::GetHighlightDelimiters(HighlightDelimiter &highlightDelimiter, in

int lookLine = line;
int lookLineLevel = level;
int lookLineLevelNum = lookLineLevel & SC_FOLDLEVELNUMBERMASK;
int lookLineLevelNum = LevelNumber(lookLineLevel);
while ((lookLine > 0) && ((lookLineLevel & SC_FOLDLEVELWHITEFLAG) ||
((lookLineLevel & SC_FOLDLEVELHEADERFLAG) && (lookLineLevelNum >= (GetLevel(lookLine + 1) & SC_FOLDLEVELNUMBERMASK))))) {
((lookLineLevel & SC_FOLDLEVELHEADERFLAG) && (lookLineLevelNum >= LevelNumber(GetLevel(lookLine + 1)))))) {
lookLineLevel = GetLevel(--lookLine);
lookLineLevelNum = lookLineLevel & SC_FOLDLEVELNUMBERMASK;
lookLineLevelNum = LevelNumber(lookLineLevel);
}

int beginFoldBlock = (lookLineLevel & SC_FOLDLEVELHEADERFLAG) ? lookLine : GetFoldParent(lookLine);
Expand All @@ -505,7 +505,7 @@ void Document::GetHighlightDelimiters(HighlightDelimiter &highlightDelimiter, in
if (endFoldBlock < line) {
lookLine = beginFoldBlock - 1;
lookLineLevel = GetLevel(lookLine);
lookLineLevelNum = lookLineLevel & SC_FOLDLEVELNUMBERMASK;
lookLineLevelNum = LevelNumber(lookLineLevel);
while ((lookLine >= 0) && (lookLineLevelNum >= SC_FOLDLEVELBASE)) {
if (lookLineLevel & SC_FOLDLEVELHEADERFLAG) {
if (GetLastChild(lookLine, -1, lookLastLine) == line) {
Expand All @@ -514,17 +514,17 @@ void Document::GetHighlightDelimiters(HighlightDelimiter &highlightDelimiter, in
firstChangeableLineBefore = line - 1;
}
}
if ((lookLine > 0) && (lookLineLevelNum == SC_FOLDLEVELBASE) && ((GetLevel(lookLine - 1) & SC_FOLDLEVELNUMBERMASK) > lookLineLevelNum))
if ((lookLine > 0) && (lookLineLevelNum == SC_FOLDLEVELBASE) && (LevelNumber(GetLevel(lookLine - 1)) > lookLineLevelNum))
break;
lookLineLevel = GetLevel(--lookLine);
lookLineLevelNum = lookLineLevel & SC_FOLDLEVELNUMBERMASK;
lookLineLevelNum = LevelNumber(lookLineLevel);
}
}
if (firstChangeableLineBefore == -1) {
for (lookLine = line - 1, lookLineLevel = GetLevel(lookLine), lookLineLevelNum = lookLineLevel & SC_FOLDLEVELNUMBERMASK;
for (lookLine = line - 1, lookLineLevel = GetLevel(lookLine), lookLineLevelNum = LevelNumber(lookLineLevel);
lookLine >= beginFoldBlock;
lookLineLevel = GetLevel(--lookLine), lookLineLevelNum = lookLineLevel & SC_FOLDLEVELNUMBERMASK) {
if ((lookLineLevel & SC_FOLDLEVELWHITEFLAG) || (lookLineLevelNum > (level & SC_FOLDLEVELNUMBERMASK))) {
lookLineLevel = GetLevel(--lookLine), lookLineLevelNum = LevelNumber(lookLineLevel)) {
if ((lookLineLevel & SC_FOLDLEVELWHITEFLAG) || (lookLineLevelNum > LevelNumber(level))) {
firstChangeableLineBefore = lookLine;
break;
}
Expand All @@ -534,10 +534,10 @@ void Document::GetHighlightDelimiters(HighlightDelimiter &highlightDelimiter, in
firstChangeableLineBefore = beginFoldBlock - 1;

int firstChangeableLineAfter = -1;
for (lookLine = line + 1, lookLineLevel = GetLevel(lookLine), lookLineLevelNum = lookLineLevel & SC_FOLDLEVELNUMBERMASK;
for (lookLine = line + 1, lookLineLevel = GetLevel(lookLine), lookLineLevelNum = LevelNumber(lookLineLevel);
lookLine <= endFoldBlock;
lookLineLevel = GetLevel(++lookLine), lookLineLevelNum = lookLineLevel & SC_FOLDLEVELNUMBERMASK) {
if ((lookLineLevel & SC_FOLDLEVELHEADERFLAG) && (lookLineLevelNum < (GetLevel(lookLine + 1) & SC_FOLDLEVELNUMBERMASK))) {
lookLineLevel = GetLevel(++lookLine), lookLineLevelNum = LevelNumber(lookLineLevel)) {
if ((lookLineLevel & SC_FOLDLEVELHEADERFLAG) && (lookLineLevelNum < LevelNumber(GetLevel(lookLine + 1)))) {
firstChangeableLineAfter = lookLine;
break;
}
Expand Down
4 changes: 4 additions & 0 deletions scintilla/src/Document.h
Expand Up @@ -171,6 +171,10 @@ class HighlightDelimiter {

class Document;

inline int LevelNumber(int level) {
return level & SC_FOLDLEVELNUMBERMASK;
}

class LexInterface {
protected:
Document *pdoc;
Expand Down
2 changes: 1 addition & 1 deletion scintilla/src/EditView.cxx
Expand Up @@ -1744,7 +1744,7 @@ static void DrawFoldLines(Surface *surface, const EditModel &model, const ViewSt
const int level = model.pdoc->GetLevel(line);
const int levelNext = model.pdoc->GetLevel(line + 1);
if ((level & SC_FOLDLEVELHEADERFLAG) &&
((level & SC_FOLDLEVELNUMBERMASK) < (levelNext & SC_FOLDLEVELNUMBERMASK))) {
(LevelNumber(level) < LevelNumber(levelNext))) {
// Paint the line above the fold
if ((expanded && (model.foldFlags & SC_FOLDFLAG_LINEBEFORE_EXPANDED))
||
Expand Down
23 changes: 20 additions & 3 deletions scintilla/src/Editor.cxx
Expand Up @@ -5292,7 +5292,7 @@ void Editor::FoldExpand(int line, int action, int level) {
if (expanding && (cs.HiddenLines() == 0))
// Nothing to do
return;
int lineMaxSubord = pdoc->GetLastChild(line, level & SC_FOLDLEVELNUMBERMASK);
int lineMaxSubord = pdoc->GetLastChild(line, LevelNumber(level));
line++;
cs.SetVisible(line, lineMaxSubord, expanding);
while (line <= lineMaxSubord) {
Expand Down Expand Up @@ -5399,7 +5399,7 @@ void Editor::FoldAll(int action) {
for (int line = 0; line < maxLine; line++) {
int level = pdoc->GetLevel(line);
if ((level & SC_FOLDLEVELHEADERFLAG) &&
(SC_FOLDLEVELBASE == (level & SC_FOLDLEVELNUMBERMASK))) {
(SC_FOLDLEVELBASE == LevelNumber(level))) {
SetFoldExpanded(line, false);
int lineMaxSubord = pdoc->GetLastChild(line, -1);
if (lineMaxSubord > line) {
Expand All @@ -5422,17 +5422,25 @@ void Editor::FoldChanged(int line, int levelNow, int levelPrev) {
FoldExpand(line, SC_FOLDACTION_EXPAND, levelPrev);
}
} else if (levelPrev & SC_FOLDLEVELHEADERFLAG) {
const int prevLine = line - 1;
const int prevLineLevel = pdoc->GetLevel(prevLine);

// Combining two blocks where the first block is collapsed (e.g. by deleting the line(s) which separate(s) the two blocks)
if ((LevelNumber(prevLineLevel) == LevelNumber(levelNow)) && !cs.GetVisible(prevLine))
FoldLine(pdoc->GetFoldParent(prevLine), SC_FOLDACTION_EXPAND);

if (!cs.GetExpanded(line)) {
// Removing the fold from one that has been contracted so should expand
// otherwise lines are left invisible with no way to make them visible
if (cs.SetExpanded(line, true)) {
RedrawSelMargin();
}
// Combining two blocks where the second one is collapsed (e.g. by adding characters in the line which separates the two blocks)
FoldExpand(line, SC_FOLDACTION_EXPAND, levelPrev);
}
}
if (!(levelNow & SC_FOLDLEVELWHITEFLAG) &&
((levelPrev & SC_FOLDLEVELNUMBERMASK) > (levelNow & SC_FOLDLEVELNUMBERMASK))) {
(LevelNumber(levelPrev) > LevelNumber(levelNow))) {
if (cs.HiddenLines()) {
// See if should still be hidden
int parentLine = pdoc->GetFoldParent(line);
Expand All @@ -5443,6 +5451,15 @@ void Editor::FoldChanged(int line, int levelNow, int levelPrev) {
}
}
}

// Combining two blocks where the first one is collapsed (e.g. by adding characters in the line which separates the two blocks)
if (!(levelNow & SC_FOLDLEVELWHITEFLAG) && (LevelNumber(levelPrev) < LevelNumber(levelNow))) {
if (cs.HiddenLines()) {
const int parentLine = pdoc->GetFoldParent(line);
if (!cs.GetExpanded(parentLine) && cs.GetExpanded(line))
FoldLine(parentLine, SC_FOLDACTION_EXPAND);
}
}
}

void Editor::NeedShown(int pos, int len) {
Expand Down

0 comments on commit 24f9198

Please sign in to comment.