diff options
-rw-r--r-- | Readme-mod.txt | 2 | ||||
-rw-r--r-- | scintilla/doc/ScintillaHistory.html | 1 | ||||
-rw-r--r-- | scintilla/include/Face.py | 8 | ||||
-rw-r--r-- | scintilla/include/Platform.h | 8 | ||||
-rw-r--r-- | scintilla/include/Scintilla.iface | 4 | ||||
-rw-r--r-- | scintilla/lexers/LexCPP.cxx | 2 | ||||
-rw-r--r-- | scintilla/lexers/LexCSS.cxx | 29 | ||||
-rw-r--r-- | scintilla/src/AutoComplete.cxx | 13 | ||||
-rw-r--r-- | scintilla/src/AutoComplete.h | 8 | ||||
-rw-r--r-- | scintilla/src/Document.cxx | 54 | ||||
-rw-r--r-- | scintilla/src/Editor.cxx | 12 | ||||
-rw-r--r-- | scintilla/src/Editor.h | 1 | ||||
-rw-r--r-- | scintilla/src/ScintillaBase.cxx | 37 |
13 files changed, 121 insertions, 58 deletions
diff --git a/Readme-mod.txt b/Readme-mod.txt index 3263423..e35a3fa 100644 --- a/Readme-mod.txt +++ b/Readme-mod.txt @@ -31,6 +31,6 @@ Ctrl+Alt+F2 Expand selection to next match. Ctrl+Alt+Shift+F2 Expand selection to previous match.
Ctrl+Shift+Enter New line with toggled auto indent option.
-Notepad2-mod 4.2.25 has been created with Scintilla 3.2.0 HG 6b1e016f96a2.
+Notepad2-mod 4.2.25 has been created with Scintilla 3.2.0 HG 9c1b36b3bbd1.
You can use WDK 7.1, MSVC 2010 or Intel C++ Compiler XE 2011 SP1 Update 10
to build Notepad2-mod.
diff --git a/scintilla/doc/ScintillaHistory.html b/scintilla/doc/ScintillaHistory.html index 70fe55a..cf2d01a 100644 --- a/scintilla/doc/ScintillaHistory.html +++ b/scintilla/doc/ScintillaHistory.html @@ -402,6 +402,7 @@ <td>Martin Panter</td>
</tr><tr>
<td>Mark Yen</td>
+ <td>Philippe Elsass</td>
</tr>
</table>
<p>
diff --git a/scintilla/include/Face.py b/scintilla/include/Face.py index 642b957..2cf4b89 100644 --- a/scintilla/include/Face.py +++ b/scintilla/include/Face.py @@ -12,7 +12,7 @@ def decodeFunction(featureVal): nameIdent, params = rest.split("(")
name, value = nameIdent.split("=")
params, rest = params.split(")")
- param1, param2 = params.split(",")[0:2]
+ param1, param2 = params.split(",")
return retType, name, value, param1, param2
def decodeEvent(featureVal):
@@ -60,7 +60,11 @@ class Face: currentCommentFinished = 1
featureType, featureVal = line.split(" ", 1)
if featureType in ["fun", "get", "set"]:
- retType, name, value, param1, param2 = decodeFunction(featureVal)
+ try:
+ retType, name, value, param1, param2 = decodeFunction(featureVal)
+ except ValueError:
+ print("Failed to decode %s" % line)
+ raise
p1 = decodeParam(param1)
p2 = decodeParam(param2)
self.features[name] = {
diff --git a/scintilla/include/Platform.h b/scintilla/include/Platform.h index 0f9fb00..8399fcb 100644 --- a/scintilla/include/Platform.h +++ b/scintilla/include/Platform.h @@ -31,14 +31,14 @@ #undef PLAT_WX
#define PLAT_WX 1
-#elif defined(GTK)
-#undef PLAT_GTK
-#define PLAT_GTK 1
-
#elif defined(SCINTILLA_QT)
#undef PLAT_QT
#define PLAT_QT 1
+#elif defined(GTK)
+#undef PLAT_GTK
+#define PLAT_GTK 1
+
#if defined(__WIN32__) || defined(_MSC_VER)
#undef PLAT_GTK_WIN32
#define PLAT_GTK_WIN32 1
diff --git a/scintilla/include/Scintilla.iface b/scintilla/include/Scintilla.iface index c628ead..d6f1a9e 100644 --- a/scintilla/include/Scintilla.iface +++ b/scintilla/include/Scintilla.iface @@ -1907,7 +1907,7 @@ get int GetIndicatorCurrent=2501(,) # Set the value used for IndicatorFillRange
set void SetIndicatorValue=2502(int value,)
-# Get the current indicator vaue
+# Get the current indicator value
get int GetIndicatorValue=2503(,)
# Turn a indicator on over a range.
@@ -2131,7 +2131,7 @@ set void SetSelectionNStart=2584(int selection, position pos) get position GetSelectionNStart=2585(int selection,)
# Sets the position that ends the selection - this becomes the currentPosition.
-set void SetSelectionNEnd=2586(int selection, position pos,)
+set void SetSelectionNEnd=2586(int selection, position pos)
# Returns the position at the end of the selection.
get position GetSelectionNEnd=2587(int selection,)
diff --git a/scintilla/lexers/LexCPP.cxx b/scintilla/lexers/LexCPP.cxx index 783710d..b3e9bae 100644 --- a/scintilla/lexers/LexCPP.cxx +++ b/scintilla/lexers/LexCPP.cxx @@ -918,7 +918,7 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle, }
}
- if (!IsASpace(sc.ch) && !IsSpaceEquiv(sc.state)) {
+ if (!IsASpace(sc.ch) && !IsSpaceEquiv(MaskActive(sc.state))) {
chPrevNonWhite = sc.ch;
visibleChars++;
}
diff --git a/scintilla/lexers/LexCSS.cxx b/scintilla/lexers/LexCSS.cxx index f5bd78f..896bfcd 100644 --- a/scintilla/lexers/LexCSS.cxx +++ b/scintilla/lexers/LexCSS.cxx @@ -98,18 +98,29 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo // Set to 1 for Sassy CSS (.scss)
bool isScssDocument = styler.GetPropertyInt("lexer.css.scss.language") != 0;
- // TODO: implement Less support
- bool isLessDocument = false;
+ // property lexer.css.less.language
+ // Set to 1 for Less CSS (.less)
+ bool isLessDocument = styler.GetPropertyInt("lexer.css.less.language") != 0;
- // SCSS and Less both support single-line comments
+ // property lexer.css.hss.language
+ // Set to 1 for HSS (.hss)
+ bool isHssDocument = styler.GetPropertyInt("lexer.css.hss.language") != 0;
+
+ // SCSS/LESS/HSS have the concept of variable
+ bool hasVariables = isScssDocument || isLessDocument || isHssDocument;
+ char varPrefix = 0;
+ if (hasVariables)
+ varPrefix = isLessDocument ? '@' : '$';
+
+ // SCSS/LESS/HSS support single-line comments
typedef enum _CommentModes { eCommentBlock = 0, eCommentLine = 1} CommentMode;
CommentMode comment_mode = eCommentBlock;
- bool hasSingleLineComments = isScssDocument || isLessDocument;
+ bool hasSingleLineComments = isScssDocument || isLessDocument || isHssDocument;
- // must keep track of nesting level in document types that support it (SCSS, Less)
+ // must keep track of nesting level in document types that support it (SCSS/LESS/HSS)
bool hasNesting = false;
int nestingLevel = 0;
- if (isScssDocument || isLessDocument) {
+ if (isScssDocument || isLessDocument || isHssDocument) {
hasNesting = true;
nestingLevel = NestingLevelLookBehind(startPos, styler);
}
@@ -329,11 +340,13 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo insideParentheses = false;
// SCSS special modes
- if (isScssDocument) {
+ if (hasVariables) {
// variable name
- if (sc.ch == '$') {
+ if (sc.ch == varPrefix) {
switch (sc.state) {
case SCE_CSS_DEFAULT:
+ if (isLessDocument) // give priority to pseudo elements
+ break;
case SCE_CSS_VALUE:
lastStateVar = sc.state;
sc.SetState(SCE_CSS_VARIABLE);
diff --git a/scintilla/src/AutoComplete.cxx b/scintilla/src/AutoComplete.cxx index bb50b21..9020cda 100644 --- a/scintilla/src/AutoComplete.cxx +++ b/scintilla/src/AutoComplete.cxx @@ -10,6 +10,8 @@ #include <stdio.h>
#include <assert.h>
+#include <string>
+
#include "Platform.h"
#include "CharacterSet.h"
@@ -101,6 +103,16 @@ void AutoComplete::SetList(const char *list) { lb->SetList(list, separator, typesep);
}
+int AutoComplete::GetSelection() const {
+ return lb->GetSelection();
+}
+
+std::string AutoComplete::GetValue(int item) const {
+ char value[maxItemLen];
+ lb->GetValue(item, value, sizeof(value));
+ return std::string(value);
+}
+
void AutoComplete::Show(bool show) {
lb->Show(show);
if (show)
@@ -130,7 +142,6 @@ void AutoComplete::Move(int delta) { void AutoComplete::Select(const char *word) {
size_t lenWord = strlen(word);
int location = -1;
- const int maxItemLen=1000;
int start = 0; // lower bound of the api array block to search
int end = lb->Length() - 1; // upper bound of the api array block to search
while ((start <= end) && (location == -1)) { // Binary searching loop
diff --git a/scintilla/src/AutoComplete.h b/scintilla/src/AutoComplete.h index e06ce9a..4725f5d 100644 --- a/scintilla/src/AutoComplete.h +++ b/scintilla/src/AutoComplete.h @@ -20,8 +20,10 @@ class AutoComplete { char fillUpChars[256];
char separator;
char typesep; // Type seperator
+ enum { maxItemLen=1000 };
public:
+
bool ignoreCase;
bool chooseSingle;
ListBox *lb;
@@ -61,6 +63,12 @@ public: /// The list string contains a sequence of words separated by the separator character
void SetList(const char *list);
+
+ /// Return the position of the currently selected list item
+ int GetSelection() const;
+
+ /// Return the value of an item in the list
+ std::string GetValue(int item) const;
void Show(bool show);
void Cancel();
diff --git a/scintilla/src/Document.cxx b/scintilla/src/Document.cxx index a491aa8..7edbec7 100644 --- a/scintilla/src/Document.cxx +++ b/scintilla/src/Document.cxx @@ -849,6 +849,10 @@ int Document::Undo() { bool multiLine = false;
int steps = cb.StartUndo();
//Platform::DebugPrintf("Steps=%d\n", steps);
+ int coalescedRemovePos = -1;
+ int coalescedRemoveLen = 0;
+ int prevRemoveActionPos = -1;
+ int prevRemoveActionLen = 0;
for (int step = 0; step < steps; step++) {
const int prevLinesTotal = LinesTotal();
const Action &action = cb.GetUndoStep();
@@ -859,15 +863,20 @@ int Document::Undo() { DocModification dm(SC_MOD_CONTAINER | SC_PERFORMED_UNDO);
dm.token = action.position;
NotifyModified(dm);
+ if (!action.mayCoalesce) {
+ coalescedRemovePos = -1;
+ coalescedRemoveLen = 0;
+ prevRemoveActionPos = -1;
+ prevRemoveActionLen = 0;
+ }
} else {
NotifyModified(DocModification(
SC_MOD_BEFOREDELETE | SC_PERFORMED_UNDO, action));
}
cb.PerformUndoStep();
- int cellPosition = action.position;
if (action.at != containerAction) {
- ModifiedAt(cellPosition);
- newPos = cellPosition;
+ ModifiedAt(action.position);
+ newPos = action.position;
}
int modFlags = SC_PERFORMED_UNDO;
@@ -875,8 +884,22 @@ int Document::Undo() { if (action.at == removeAction) {
newPos += action.lenData;
modFlags |= SC_MOD_INSERTTEXT;
+ if ((coalescedRemoveLen > 0) &&
+ (action.position == prevRemoveActionPos || action.position == (prevRemoveActionPos + prevRemoveActionLen))) {
+ coalescedRemoveLen += action.lenData;
+ newPos = coalescedRemovePos + coalescedRemoveLen;
+ } else {
+ coalescedRemovePos = action.position;
+ coalescedRemoveLen = action.lenData;
+ }
+ prevRemoveActionPos = action.position;
+ prevRemoveActionLen = action.lenData;
} else if (action.at == insertAction) {
modFlags |= SC_MOD_DELETETEXT;
+ coalescedRemovePos = -1;
+ coalescedRemoveLen = 0;
+ prevRemoveActionPos = -1;
+ prevRemoveActionLen = 0;
}
if (steps > 1)
modFlags |= SC_MULTISTEPUNDOREDO;
@@ -888,7 +911,7 @@ int Document::Undo() { if (multiLine)
modFlags |= SC_MULTILINEUNDOREDO;
}
- NotifyModified(DocModification(modFlags, cellPosition, action.lenData,
+ NotifyModified(DocModification(modFlags, action.position, action.lenData,
linesAdded, action.data));
}
@@ -1003,21 +1026,19 @@ static int NextTab(int pos, int tabSize) { return ((pos / tabSize) + 1) * tabSize;
}
-static void CreateIndentation(char *linebuf, int length, int indent, int tabSize, bool insertSpaces) {
- length--; // ensure space for \0
+static std::string CreateIndentation(int indent, int tabSize, bool insertSpaces) {
+ std::string indentation;
if (!insertSpaces) {
- while ((indent >= tabSize) && (length > 0)) {
- *linebuf++ = '\t';
+ while (indent >= tabSize) {
+ indentation += '\t';
indent -= tabSize;
- length--;
}
}
- while ((indent > 0) && (length > 0)) {
- *linebuf++ = ' ';
+ while (indent > 0) {
+ indentation += ' ';
indent--;
- length--;
}
- *linebuf = '\0';
+ return indentation;
}
int SCI_METHOD Document::GetLineIndentation(int line) {
@@ -1043,13 +1064,12 @@ void Document::SetLineIndentation(int line, int indent) { if (indent < 0)
indent = 0;
if (indent != indentOfLine) {
- char linebuf[1000];
- CreateIndentation(linebuf, sizeof(linebuf), indent, tabInChars, !useTabs);
+ std::string linebuf = CreateIndentation(indent, tabInChars, !useTabs);
int thisLineStart = LineStart(line);
int indentPos = GetLineIndentPosition(line);
UndoGroup ug(this);
DeleteChars(thisLineStart, indentPos - thisLineStart);
- InsertCString(thisLineStart, linebuf);
+ InsertCString(thisLineStart, linebuf.c_str());
}
}
@@ -1734,10 +1754,12 @@ void Document::MarginSetText(int line, const char *text) { void Document::MarginSetStyle(int line, int style) {
static_cast<LineAnnotation *>(perLineData[ldMargin])->SetStyle(line, style);
+ NotifyModified(DocModification(SC_MOD_CHANGEMARGIN, LineStart(line), 0, 0, 0, line));
}
void Document::MarginSetStyles(int line, const unsigned char *styles) {
static_cast<LineAnnotation *>(perLineData[ldMargin])->SetStyles(line, styles);
+ NotifyModified(DocModification(SC_MOD_CHANGEMARGIN, LineStart(line), 0, 0, 0, line));
}
int Document::MarginLength(int line) const {
diff --git a/scintilla/src/Editor.cxx b/scintilla/src/Editor.cxx index 24306a4..d57b5f1 100644 --- a/scintilla/src/Editor.cxx +++ b/scintilla/src/Editor.cxx @@ -5862,6 +5862,18 @@ char *Editor::CopyRange(int start, int end) { return text;
}
+std::string Editor::RangeText(int start, int end) const {
+ if (start < end) {
+ int len = end - start;
+ std::string ret(len, '\0');
+ for (int i = 0; i < len; i++) {
+ ret[i] = pdoc->CharAt(start + i);
+ }
+ return ret;
+ }
+ return std::string();
+}
+
void Editor::CopySelectionRange(SelectionText *ss, bool allowLineCopy) {
if (sel.Empty()) {
if (allowLineCopy) {
diff --git a/scintilla/src/Editor.h b/scintilla/src/Editor.h index bd6186a..5516628 100644 --- a/scintilla/src/Editor.h +++ b/scintilla/src/Editor.h @@ -480,6 +480,7 @@ protected: // ScintillaBase subclass needs access to much of Editor virtual void CopyToClipboard(const SelectionText &selectedText) = 0;
char *CopyRange(int start, int end);
+ std::string RangeText(int start, int end) const;
void CopySelectionRange(SelectionText *ss, bool allowLineCopy=false);
void CopyRangeToClipboard(int start, int end);
void CopyText(int length, const char *text);
diff --git a/scintilla/src/ScintillaBase.cxx b/scintilla/src/ScintillaBase.cxx index 36d8782..d23893b 100644 --- a/scintilla/src/ScintillaBase.cxx +++ b/scintilla/src/ScintillaBase.cxx @@ -213,6 +213,7 @@ void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) { pdoc->InsertString(sel.MainCaret(), list + lenEntered, lenInsert - lenEntered);
SetEmptySelection(sel.MainCaret() + lenInsert - lenEntered);
}
+ ac.Cancel();
return;
}
}
@@ -293,13 +294,8 @@ void ScintillaBase::AutoCompleteMove(int delta) { }
void ScintillaBase::AutoCompleteMoveToCurrentWord() {
- char wordCurrent[1000];
- int i;
- int startWord = ac.posStart - ac.startLen;
- for (i = startWord; i < sel.MainCaret() && i - startWord < 1000; i++)
- wordCurrent[i - startWord] = pdoc->CharAt(i);
- wordCurrent[Platform::Minimum(i - startWord, 999)] = '\0';
- ac.Select(wordCurrent);
+ std::string wordCurrent = RangeText(ac.posStart - ac.startLen, sel.MainCaret());
+ ac.Select(wordCurrent.c_str());
}
void ScintillaBase::AutoCompleteCharacterAdded(char ch) {
@@ -328,15 +324,12 @@ void ScintillaBase::AutoCompleteCharacterDeleted() { }
void ScintillaBase::AutoCompleteCompleted() {
- int item = ac.lb->GetSelection();
- char selected[1000];
- selected[0] = '\0';
- if (item != -1) {
- ac.lb->GetValue(item, selected, sizeof(selected));
- } else {
+ int item = ac.GetSelection();
+ if (item == -1) {
AutoCompleteCancel();
return;
}
+ const std::string selected = ac.GetValue(item);
ac.Show(false);
@@ -348,7 +341,7 @@ void ScintillaBase::AutoCompleteCompleted() { Position firstPos = ac.posStart - ac.startLen;
scn.position = firstPos;
scn.lParam = firstPos;
- scn.text = selected;
+ scn.text = selected.c_str();
NotifyParent(scn);
if (!ac.Active())
@@ -369,8 +362,8 @@ void ScintillaBase::AutoCompleteCompleted() { }
SetEmptySelection(ac.posStart);
if (item != -1) {
- pdoc->InsertCString(firstPos, selected);
- SetEmptySelection(firstPos + static_cast<int>(strlen(selected)));
+ pdoc->InsertCString(firstPos, selected.c_str());
+ SetEmptySelection(firstPos + static_cast<int>(selected.length()));
}
SetLastXChosen();
}
@@ -378,19 +371,17 @@ void ScintillaBase::AutoCompleteCompleted() { int ScintillaBase::AutoCompleteGetCurrent() {
if (!ac.Active())
return -1;
- return ac.lb->GetSelection();
+ return ac.GetSelection();
}
int ScintillaBase::AutoCompleteGetCurrentText(char *buffer) {
if (ac.Active()) {
- int item = ac.lb->GetSelection();
- char selected[1000];
- selected[0] = '\0';
+ int item = ac.GetSelection();
if (item != -1) {
- ac.lb->GetValue(item, selected, sizeof(selected));
+ const std::string selected = ac.GetValue(item);
if (buffer != NULL)
- strcpy(buffer, selected);
- return static_cast<int>(strlen(selected));
+ strcpy(buffer, selected.c_str());
+ return static_cast<int>(selected.length());
}
}
if (buffer != NULL)
|