Update Scintilla to version 3.6.7

Fixes #1143.
This commit is contained in:
Colomban Wendling 2016-09-05 22:14:48 +02:00
parent b7688b04b2
commit 18db459632
15 changed files with 76 additions and 38 deletions

View File

@ -1747,7 +1747,7 @@ void ScintillaGTK::Resize(int width, int height) {
minVScrollBarHeight = minimum.height; minVScrollBarHeight = minimum.height;
verticalScrollBarWidth = requisition.width; verticalScrollBarWidth = requisition.width;
gtk_widget_get_preferred_size(PWidget(scrollbarh), &minimum, &requisition); gtk_widget_get_preferred_size(PWidget(scrollbarh), &minimum, &requisition);
minHScrollBarWidth = minimum.height; minHScrollBarWidth = minimum.width;
horizontalScrollBarHeight = requisition.height; horizontalScrollBarHeight = requisition.height;
#else #else
minVScrollBarHeight = minHScrollBarWidth = 1; minVScrollBarHeight = minHScrollBarWidth = 1;

View File

@ -895,6 +895,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SCVS_NONE 0 #define SCVS_NONE 0
#define SCVS_RECTANGULARSELECTION 1 #define SCVS_RECTANGULARSELECTION 1
#define SCVS_USERACCESSIBLE 2 #define SCVS_USERACCESSIBLE 2
#define SCVS_NOWRAPLINESTART 4
#define SCI_SETVIRTUALSPACEOPTIONS 2596 #define SCI_SETVIRTUALSPACEOPTIONS 2596
#define SCI_GETVIRTUALSPACEOPTIONS 2597 #define SCI_GETVIRTUALSPACEOPTIONS 2597
#define SCI_SETRECTANGULARSELECTIONMODIFIER 2598 #define SCI_SETRECTANGULARSELECTIONMODIFIER 2598

View File

@ -2331,6 +2331,7 @@ enu VirtualSpace=SCVS_
val SCVS_NONE=0 val SCVS_NONE=0
val SCVS_RECTANGULARSELECTION=1 val SCVS_RECTANGULARSELECTION=1
val SCVS_USERACCESSIBLE=2 val SCVS_USERACCESSIBLE=2
val SCVS_NOWRAPLINESTART=4
set void SetVirtualSpaceOptions=2596(int virtualSpaceOptions,) set void SetVirtualSpaceOptions=2596(int virtualSpaceOptions,)
get int GetVirtualSpaceOptions=2597(,) get int GetVirtualSpaceOptions=2597(,)

View File

@ -229,7 +229,7 @@ struct PPDefinition {
std::string value; std::string value;
bool isUndef; bool isUndef;
std::string arguments; std::string arguments;
PPDefinition(Sci_Position line_, const std::string &key_, const std::string &value_, bool isUndef_ = false, std::string arguments_="") : PPDefinition(Sci_Position line_, const std::string &key_, const std::string &value_, bool isUndef_ = false, const std::string &arguments_="") :
line(line_), key(key_), value(value_), isUndef(isUndef_), arguments(arguments_) { line(line_), key(key_), value(value_), isUndef(isUndef_), arguments(arguments_) {
} }
}; };
@ -320,6 +320,7 @@ struct OptionsCPP {
std::string foldExplicitEnd; std::string foldExplicitEnd;
bool foldExplicitAnywhere; bool foldExplicitAnywhere;
bool foldPreprocessor; bool foldPreprocessor;
bool foldPreprocessorAtElse;
bool foldCompact; bool foldCompact;
bool foldAtElse; bool foldAtElse;
OptionsCPP() { OptionsCPP() {
@ -341,6 +342,7 @@ struct OptionsCPP {
foldExplicitEnd = ""; foldExplicitEnd = "";
foldExplicitAnywhere = false; foldExplicitAnywhere = false;
foldPreprocessor = false; foldPreprocessor = false;
foldPreprocessorAtElse = false;
foldCompact = false; foldCompact = false;
foldAtElse = false; foldAtElse = false;
} }
@ -412,6 +414,9 @@ struct OptionSetCPP : public OptionSet<OptionsCPP> {
DefineProperty("fold.cpp.explicit.anywhere", &OptionsCPP::foldExplicitAnywhere, DefineProperty("fold.cpp.explicit.anywhere", &OptionsCPP::foldExplicitAnywhere,
"Set this property to 1 to enable explicit fold points anywhere, not just in line comments."); "Set this property to 1 to enable explicit fold points anywhere, not just in line comments.");
DefineProperty("fold.cpp.preprocessor.at.else", &OptionsCPP::foldPreprocessorAtElse,
"This option enables folding on a preprocessor #else or #endif line of an #if statement.");
DefineProperty("fold.preprocessor", &OptionsCPP::foldPreprocessor, DefineProperty("fold.preprocessor", &OptionsCPP::foldPreprocessor,
"This option enables folding preprocessor directives when using the C++ lexer. " "This option enables folding preprocessor directives when using the C++ lexer. "
"Includes C#'s explicit #region and #endregion folding directives."); "Includes C#'s explicit #region and #endregion folding directives.");
@ -1349,13 +1354,17 @@ void SCI_METHOD LexerCPP::Fold(Sci_PositionU startPos, Sci_Position length, int
} else if (styler.Match(j, "end")) { } else if (styler.Match(j, "end")) {
levelNext--; levelNext--;
} }
if (options.foldPreprocessorAtElse && (styler.Match(j, "else") || styler.Match(j, "elif"))) {
levelMinCurrent--;
}
} }
} }
if (options.foldSyntaxBased && (style == SCE_C_OPERATOR)) { if (options.foldSyntaxBased && (style == SCE_C_OPERATOR)) {
if (ch == '{' || ch == '[' || ch == '(') { if (ch == '{' || ch == '[' || ch == '(') {
// Measure the minimum before a '{' to allow // Measure the minimum before a '{' to allow
// folding on "} else {" // folding on "} else {"
if (levelMinCurrent > levelNext) { if (options.foldAtElse && levelMinCurrent > levelNext) {
levelMinCurrent = levelNext; levelMinCurrent = levelNext;
} }
levelNext++; levelNext++;
@ -1367,7 +1376,9 @@ void SCI_METHOD LexerCPP::Fold(Sci_PositionU startPos, Sci_Position length, int
visibleChars++; visibleChars++;
if (atEOL || (i == endPos-1)) { if (atEOL || (i == endPos-1)) {
int levelUse = levelCurrent; int levelUse = levelCurrent;
if (options.foldSyntaxBased && options.foldAtElse) { if ((options.foldSyntaxBased && options.foldAtElse) ||
(options.foldPreprocessor && options.foldPreprocessorAtElse)
) {
levelUse = levelMinCurrent; levelUse = levelMinCurrent;
} }
int lev = levelUse | levelNext << 16; int lev = levelUse | levelNext << 16;

View File

@ -610,6 +610,17 @@ static void ColouriseHyperTextDoc(Sci_PositionU startPos, Sci_Position length, i
} }
styler.StartAt(startPos); styler.StartAt(startPos);
/* Nothing handles getting out of these, so we need not start in any of them.
* As we're at line start and they can't span lines, we'll re-detect them anyway */
switch (state) {
case SCE_H_QUESTION:
case SCE_H_XMLSTART:
case SCE_H_XMLEND:
case SCE_H_ASP:
state = SCE_H_DEFAULT;
break;
}
Sci_Position lineCurrent = styler.GetLine(startPos); Sci_Position lineCurrent = styler.GetLine(startPos);
int lineState; int lineState;
if (lineCurrent > 0) { if (lineCurrent > 0) {
@ -898,7 +909,7 @@ static void ColouriseHyperTextDoc(Sci_PositionU startPos, Sci_Position length, i
///////////////////////////////////// /////////////////////////////////////
// handle the start of PHP pre-processor = Non-HTML // handle the start of PHP pre-processor = Non-HTML
else if ((state != SCE_H_ASPAT) && else if ((state != SCE_H_ASPAT) &&
!isPHPStringState(state) && !isStringState(state) &&
(state != SCE_HPHP_COMMENT) && (state != SCE_HPHP_COMMENT) &&
(state != SCE_HPHP_COMMENTLINE) && (state != SCE_HPHP_COMMENTLINE) &&
(ch == '<') && (ch == '<') &&

View File

@ -44,7 +44,7 @@ void CharClassify::SetCharClasses(const unsigned char *chars, cc newCharClass) {
} }
} }
int CharClassify::GetCharsOfClass(cc characterClass, unsigned char *buffer) { int CharClassify::GetCharsOfClass(cc characterClass, unsigned char *buffer) const {
// Get characters belonging to the given char class; return the number // Get characters belonging to the given char class; return the number
// of characters (if the buffer is NULL, don't write to it). // of characters (if the buffer is NULL, don't write to it).
int count = 0; int count = 0;

View File

@ -19,7 +19,7 @@ public:
enum cc { ccSpace, ccNewLine, ccWord, ccPunctuation }; enum cc { ccSpace, ccNewLine, ccWord, ccPunctuation };
void SetDefaultCharClasses(bool includeWordClass); void SetDefaultCharClasses(bool includeWordClass);
void SetCharClasses(const unsigned char *chars, cc newCharClass); void SetCharClasses(const unsigned char *chars, cc newCharClass);
int GetCharsOfClass(cc charClass, unsigned char *buffer); int GetCharsOfClass(cc charClass, unsigned char *buffer) const;
cc GetClass(unsigned char ch) const { return static_cast<cc>(charClass[ch]);} cc GetClass(unsigned char ch) const { return static_cast<cc>(charClass[ch]);}
bool IsWord(unsigned char ch) const { return static_cast<cc>(charClass[ch]) == ccWord;} bool IsWord(unsigned char ch) const { return static_cast<cc>(charClass[ch]) == ccWord;}

View File

@ -1823,7 +1823,7 @@ void Document::SetCharClasses(const unsigned char *chars, CharClassify::cc newCh
charClass.SetCharClasses(chars, newCharClass); charClass.SetCharClasses(chars, newCharClass);
} }
int Document::GetCharsOfClass(CharClassify::cc characterClass, unsigned char *buffer) { int Document::GetCharsOfClass(CharClassify::cc characterClass, unsigned char *buffer) const {
return charClass.GetCharsOfClass(characterClass, buffer); return charClass.GetCharsOfClass(characterClass, buffer);
} }

View File

@ -401,7 +401,7 @@ public:
void SetDefaultCharClasses(bool includeWordClass); void SetDefaultCharClasses(bool includeWordClass);
void SetCharClasses(const unsigned char *chars, CharClassify::cc newCharClass); void SetCharClasses(const unsigned char *chars, CharClassify::cc newCharClass);
int GetCharsOfClass(CharClassify::cc characterClass, unsigned char *buffer); int GetCharsOfClass(CharClassify::cc characterClass, unsigned char *buffer) const;
void SCI_METHOD StartStyling(Sci_Position position, char mask); void SCI_METHOD StartStyling(Sci_Position position, char mask);
bool SCI_METHOD SetStyleFor(Sci_Position length, char style); bool SCI_METHOD SetStyleFor(Sci_Position length, char style);
bool SCI_METHOD SetStyles(Sci_Position length, const char *styles); bool SCI_METHOD SetStyles(Sci_Position length, const char *styles);

View File

@ -1837,15 +1837,26 @@ void Editor::ChangeSize() {
} }
} }
int Editor::InsertSpace(int position, unsigned int spaces) { int Editor::RealizeVirtualSpace(int position, unsigned int virtualSpace) {
if (spaces > 0) { if (virtualSpace > 0) {
std::string spaceText(spaces, ' '); const int line = pdoc->LineFromPosition(position);
const int lengthInserted = pdoc->InsertString(position, spaceText.c_str(), spaces); const int indent = pdoc->GetLineIndentPosition(line);
if (indent == position) {
return pdoc->SetLineIndentation(line, pdoc->GetLineIndentation(line) + virtualSpace);
} else {
std::string spaceText(virtualSpace, ' ');
const int lengthInserted = pdoc->InsertString(position, spaceText.c_str(), virtualSpace);
position += lengthInserted; position += lengthInserted;
} }
}
return position; return position;
} }
SelectionPosition Editor::RealizeVirtualSpace(const SelectionPosition &position) {
// Return the new position with no virtual space
return SelectionPosition(RealizeVirtualSpace(position.Position(), position.VirtualSpace()));
}
void Editor::AddChar(char ch) { void Editor::AddChar(char ch) {
char s[2]; char s[2];
s[0] = ch; s[0] = ch;
@ -1901,7 +1912,7 @@ void Editor::AddCharUTF(const char *s, unsigned int len, bool treatAsDBCS) {
} }
} }
} }
positionInsert = InsertSpace(positionInsert, currentSel->caret.VirtualSpace()); positionInsert = RealizeVirtualSpace(positionInsert, currentSel->caret.VirtualSpace());
const int lengthInserted = pdoc->InsertString(positionInsert, s, len); const int lengthInserted = pdoc->InsertString(positionInsert, s, len);
if (lengthInserted > 0) { if (lengthInserted > 0) {
currentSel->caret.SetPosition(positionInsert + lengthInserted); currentSel->caret.SetPosition(positionInsert + lengthInserted);
@ -1975,7 +1986,7 @@ void Editor::ClearBeforeTentativeStart() {
sel.Range(r).MinimizeVirtualSpace(); sel.Range(r).MinimizeVirtualSpace();
} }
} }
InsertSpace(positionInsert, sel.Range(r).caret.VirtualSpace()); RealizeVirtualSpace(positionInsert, sel.Range(r).caret.VirtualSpace());
sel.Range(r).ClearVirtualSpace(); sel.Range(r).ClearVirtualSpace();
} }
} }
@ -1984,7 +1995,7 @@ void Editor::ClearBeforeTentativeStart() {
void Editor::InsertPaste(const char *text, int len) { void Editor::InsertPaste(const char *text, int len) {
if (multiPasteMode == SC_MULTIPASTE_ONCE) { if (multiPasteMode == SC_MULTIPASTE_ONCE) {
SelectionPosition selStart = sel.Start(); SelectionPosition selStart = sel.Start();
selStart = SelectionPosition(InsertSpace(selStart.Position(), selStart.VirtualSpace())); selStart = RealizeVirtualSpace(selStart);
const int lengthInserted = pdoc->InsertString(selStart.Position(), text, len); const int lengthInserted = pdoc->InsertString(selStart.Position(), text, len);
if (lengthInserted > 0) { if (lengthInserted > 0) {
SetEmptySelection(selStart.Position() + lengthInserted); SetEmptySelection(selStart.Position() + lengthInserted);
@ -2004,7 +2015,7 @@ void Editor::InsertPaste(const char *text, int len) {
sel.Range(r).MinimizeVirtualSpace(); sel.Range(r).MinimizeVirtualSpace();
} }
} }
positionInsert = InsertSpace(positionInsert, sel.Range(r).caret.VirtualSpace()); positionInsert = RealizeVirtualSpace(positionInsert, sel.Range(r).caret.VirtualSpace());
const int lengthInserted = pdoc->InsertString(positionInsert, text, len); const int lengthInserted = pdoc->InsertString(positionInsert, text, len);
if (lengthInserted > 0) { if (lengthInserted > 0) {
sel.Range(r).caret.SetPosition(positionInsert + lengthInserted); sel.Range(r).caret.SetPosition(positionInsert + lengthInserted);
@ -2126,8 +2137,7 @@ void Editor::PasteRectangular(SelectionPosition pos, const char *ptr, int len) {
sel.RangeMain() = SelectionRange(pos); sel.RangeMain() = SelectionRange(pos);
int line = pdoc->LineFromPosition(sel.MainCaret()); int line = pdoc->LineFromPosition(sel.MainCaret());
UndoGroup ug(pdoc); UndoGroup ug(pdoc);
sel.RangeMain().caret = SelectionPosition( sel.RangeMain().caret = RealizeVirtualSpace(sel.RangeMain().caret);
InsertSpace(sel.RangeMain().caret.Position(), sel.RangeMain().caret.VirtualSpace()));
int xInsert = XFromPosition(sel.RangeMain().caret); int xInsert = XFromPosition(sel.RangeMain().caret);
bool prevCr = false; bool prevCr = false;
while ((len > 0) && IsEOLChar(ptr[len-1])) while ((len > 0) && IsEOLChar(ptr[len-1]))
@ -2179,9 +2189,9 @@ void Editor::Clear() {
if (!RangeContainsProtected(sel.Range(r).caret.Position(), sel.Range(r).caret.Position() + 1)) { if (!RangeContainsProtected(sel.Range(r).caret.Position(), sel.Range(r).caret.Position() + 1)) {
if (sel.Range(r).Start().VirtualSpace()) { if (sel.Range(r).Start().VirtualSpace()) {
if (sel.Range(r).anchor < sel.Range(r).caret) if (sel.Range(r).anchor < sel.Range(r).caret)
sel.Range(r) = SelectionRange(InsertSpace(sel.Range(r).anchor.Position(), sel.Range(r).anchor.VirtualSpace())); sel.Range(r) = SelectionRange(RealizeVirtualSpace(sel.Range(r).anchor.Position(), sel.Range(r).anchor.VirtualSpace()));
else else
sel.Range(r) = SelectionRange(InsertSpace(sel.Range(r).caret.Position(), sel.Range(r).caret.VirtualSpace())); sel.Range(r) = SelectionRange(RealizeVirtualSpace(sel.Range(r).caret.Position(), sel.Range(r).caret.VirtualSpace()));
} }
if ((sel.Count() == 1) || !pdoc->IsPositionInLineEnd(sel.Range(r).caret.Position())) { if ((sel.Count() == 1) || !pdoc->IsPositionInLineEnd(sel.Range(r).caret.Position())) {
pdoc->DelChar(sel.Range(r).caret.Position()); pdoc->DelChar(sel.Range(r).caret.Position());
@ -3283,7 +3293,7 @@ int Editor::HorizontalMove(unsigned int iMessage) {
case SCI_CHARLEFTRECTEXTEND: case SCI_CHARLEFTRECTEXTEND:
if (pdoc->IsLineEndPosition(spCaret.Position()) && spCaret.VirtualSpace()) { if (pdoc->IsLineEndPosition(spCaret.Position()) && spCaret.VirtualSpace()) {
spCaret.SetVirtualSpace(spCaret.VirtualSpace() - 1); spCaret.SetVirtualSpace(spCaret.VirtualSpace() - 1);
} else { } else if ((virtualSpaceOptions & SCVS_NOWRAPLINESTART) == 0 || pdoc->GetColumn(spCaret.Position()) > 0) {
spCaret = SelectionPosition(spCaret.Position() - 1); spCaret = SelectionPosition(spCaret.Position() - 1);
} }
break; break;
@ -3328,7 +3338,7 @@ int Editor::HorizontalMove(unsigned int iMessage) {
case SCI_CHARLEFTEXTEND: case SCI_CHARLEFTEXTEND:
if (spCaret.VirtualSpace()) { if (spCaret.VirtualSpace()) {
spCaret.SetVirtualSpace(spCaret.VirtualSpace() - 1); spCaret.SetVirtualSpace(spCaret.VirtualSpace() - 1);
} else { } else if ((virtualSpaceOptions & SCVS_NOWRAPLINESTART) == 0 || pdoc->GetColumn(spCaret.Position()) > 0) {
spCaret = SelectionPosition(spCaret.Position() - 1); spCaret = SelectionPosition(spCaret.Position() - 1);
} }
break; break;
@ -3504,7 +3514,7 @@ int Editor::DelWordOrLine(unsigned int iMessage) {
} else { } else {
// Delete to the right so first realise the virtual space. // Delete to the right so first realise the virtual space.
sel.Range(r) = SelectionRange( sel.Range(r) = SelectionRange(
InsertSpace(sel.Range(r).caret.Position(), sel.Range(r).caret.VirtualSpace())); RealizeVirtualSpace(sel.Range(r).caret));
} }
Range rangeDelete; Range rangeDelete;
@ -4208,7 +4218,7 @@ void Editor::DropAt(SelectionPosition position, const char *value, size_t length
SetEmptySelection(position); SetEmptySelection(position);
} else { } else {
position = MovePositionOutsideChar(position, sel.MainCaret() - position.Position()); position = MovePositionOutsideChar(position, sel.MainCaret() - position.Position());
position = SelectionPosition(InsertSpace(position.Position(), position.VirtualSpace())); position = RealizeVirtualSpace(position);
const int lengthInserted = pdoc->InsertString( const int lengthInserted = pdoc->InsertString(
position.Position(), convertedText.c_str(), static_cast<int>(convertedText.length())); position.Position(), convertedText.c_str(), static_cast<int>(convertedText.length()));
if (lengthInserted > 0) { if (lengthInserted > 0) {
@ -5293,6 +5303,9 @@ void Editor::FoldExpand(int line, int action, int level) {
if (action == SC_FOLDACTION_TOGGLE) { if (action == SC_FOLDACTION_TOGGLE) {
expanding = !cs.GetExpanded(line); expanding = !cs.GetExpanded(line);
} }
// Ensure child lines lexed and fold information extracted before
// flipping the state.
pdoc->GetLastChild(line, LevelNumber(level));
SetFoldExpanded(line, expanding); SetFoldExpanded(line, expanding);
if (expanding && (cs.HiddenLines() == 0)) if (expanding && (cs.HiddenLines() == 0))
// Nothing to do // Nothing to do

View File

@ -390,7 +390,8 @@ protected: // ScintillaBase subclass needs access to much of Editor
void ChangeSize(); void ChangeSize();
void FilterSelections(); void FilterSelections();
int InsertSpace(int position, unsigned int spaces); int RealizeVirtualSpace(int position, unsigned int virtualSpace);
SelectionPosition RealizeVirtualSpace(const SelectionPosition &position);
void AddChar(char ch); void AddChar(char ch);
virtual void AddCharUTF(const char *s, unsigned int len, bool treatAsDBCS=false); virtual void AddCharUTF(const char *s, unsigned int len, bool treatAsDBCS=false);
void ClearBeforeTentativeStart(); void ClearBeforeTentativeStart();

View File

@ -218,7 +218,7 @@ void ScintillaBase::AutoCompleteInsert(Position startPos, int removeLen, const c
if (!RangeContainsProtected(sel.Range(r).Start().Position(), if (!RangeContainsProtected(sel.Range(r).Start().Position(),
sel.Range(r).End().Position())) { sel.Range(r).End().Position())) {
int positionInsert = sel.Range(r).Start().Position(); int positionInsert = sel.Range(r).Start().Position();
positionInsert = InsertSpace(positionInsert, sel.Range(r).caret.VirtualSpace()); positionInsert = RealizeVirtualSpace(positionInsert, sel.Range(r).caret.VirtualSpace());
if (positionInsert - removeLen >= 0) { if (positionInsert - removeLen >= 0) {
positionInsert -= removeLen; positionInsert -= removeLen;
pdoc->DeleteChars(positionInsert, removeLen); pdoc->DeleteChars(positionInsert, removeLen);

View File

@ -22,13 +22,13 @@ using namespace Scintilla;
static const char *NextField(const char *s) { static const char *NextField(const char *s) {
// In case there are leading spaces in the string // In case there are leading spaces in the string
while (*s && *s == ' ') { while (*s == ' ') {
s++; s++;
} }
while (*s && *s != ' ') { while (*s && *s != ' ') {
s++; s++;
} }
while (*s && *s == ' ') { while (*s == ' ') {
s++; s++;
} }
return s; return s;

View File

@ -1 +1 @@
366 367