summaryrefslogtreecommitdiffstats
path: root/scintilla/src
diff options
context:
space:
mode:
authorXhmikosR <xhmikosr@gmail.com>2015-06-22 16:47:33 +0300
committerXhmikosR <xhmikosr@gmail.com>2015-06-22 16:48:52 +0300
commit81042820fd773af8a4a5595303a24ad8faacec34 (patch)
tree2f2da7b29f3165bd6e59dfa0faa496ee4f50e10e /scintilla/src
parentaaced3ee7e32b63bc8460abcd2ee9817a052fbf3 (diff)
downloadnotepad2-mod-81042820fd773af8a4a5595303a24ad8faacec34.zip
notepad2-mod-81042820fd773af8a4a5595303a24ad8faacec34.tar.gz
notepad2-mod-81042820fd773af8a4a5595303a24ad8faacec34.tar.bz2
Update Scintilla to v3.5.7.4.2.25.955
Diffstat (limited to 'scintilla/src')
-rw-r--r--scintilla/src/Document.cxx9
-rw-r--r--scintilla/src/Document.h11
-rw-r--r--scintilla/src/Editor.cxx137
-rw-r--r--scintilla/src/Editor.h11
-rw-r--r--scintilla/src/PerLine.cxx5
-rw-r--r--scintilla/src/Selection.cxx4
-rw-r--r--scintilla/src/Selection.h1
7 files changed, 124 insertions, 54 deletions
diff --git a/scintilla/src/Document.cxx b/scintilla/src/Document.cxx
index fbb305b..34b8138 100644
--- a/scintilla/src/Document.cxx
+++ b/scintilla/src/Document.cxx
@@ -1603,7 +1603,7 @@ bool Document::IsWordEndAt(int pos) const {
* ends and where the characters on the inside are word or punctuation characters.
*/
bool Document::IsWordAt(int start, int end) const {
- return IsWordStartAt(start) && IsWordEndAt(end);
+ return (start < end) && IsWordStartAt(start) && IsWordEndAt(end);
}
bool Document::MatchesWordOptions(bool word, bool wordStart, int pos, int length) const {
@@ -1646,10 +1646,13 @@ Document::CharacterExtracted Document::ExtractCharacter(int position) const {
* Has not been tested with backwards DBCS searches yet.
*/
long Document::FindText(int minPos, int maxPos, const char *search,
- bool caseSensitive, bool word, bool wordStart, bool regExp, int flags,
- int *length) {
+ int flags, int *length) {
if (*length <= 0)
return minPos;
+ const bool caseSensitive = (flags & SCFIND_MATCHCASE) != 0;
+ const bool word = (flags & SCFIND_WHOLEWORD) != 0;
+ const bool wordStart = (flags & SCFIND_WORDSTART) != 0;
+ const bool regExp = (flags & SCFIND_REGEXP) != 0;
if (regExp) {
if (!regex)
regex = CreateRegexSearch(&charClass);
diff --git a/scintilla/src/Document.h b/scintilla/src/Document.h
index 23e5636..86b7174 100644
--- a/scintilla/src/Document.h
+++ b/scintilla/src/Document.h
@@ -381,11 +381,14 @@ public:
};
CharacterExtracted ExtractCharacter(int position) const;
+ bool IsWordStartAt(int pos) const;
+ bool IsWordEndAt(int pos) const;
+ bool IsWordAt(int start, int end) const;
+
bool MatchesWordOptions(bool word, bool wordStart, int pos, int length) const;
bool HasCaseFolder(void) const;
void SetCaseFolder(CaseFolder *pcf_);
- long FindText(int minPos, int maxPos, const char *search, bool caseSensitive, bool word,
- bool wordStart, bool regExp, int flags, int *length);
+ long FindText(int minPos, int maxPos, const char *search, int flags, int *length);
const char *SubstituteByPosition(const char *text, int *length);
int LinesTotal() const;
@@ -438,10 +441,6 @@ public:
int BraceMatch(int position, int maxReStyle);
private:
- bool IsWordStartAt(int pos) const;
- bool IsWordEndAt(int pos) const;
- bool IsWordAt(int start, int end) const;
-
void NotifyModifyAttempt();
void NotifySavePoint(bool atSavePoint);
void NotifyModified(DocModification mh);
diff --git a/scintilla/src/Editor.cxx b/scintilla/src/Editor.cxx
index 5586ee1..7170aa2 100644
--- a/scintilla/src/Editor.cxx
+++ b/scintilla/src/Editor.cxx
@@ -608,6 +608,10 @@ void Editor::InvalidateSelection(SelectionRange newMain, bool invalidateWholeSel
InvalidateRange(firstAffected, lastAffected);
}
+void Editor::InvalidateWholeSelection() {
+ InvalidateSelection(sel.RangeMain(), true);
+}
+
void Editor::SetSelection(SelectionPosition currentPos_, SelectionPosition anchor_) {
currentPos_ = ClampPositionIntoDocument(currentPos_);
anchor_ = ClampPositionIntoDocument(anchor_);
@@ -692,6 +696,59 @@ void Editor::SetEmptySelection(int currentPos_) {
SetEmptySelection(SelectionPosition(currentPos_));
}
+void Editor::MultipleSelectAdd(AddNumber addNumber) {
+ if (SelectionEmpty() || !multipleSelection) {
+ // Select word at caret
+ const int startWord = pdoc->ExtendWordSelect(sel.MainCaret(), -1, true);
+ const int endWord = pdoc->ExtendWordSelect(startWord, 1, true);
+ TrimAndSetSelection(endWord, startWord);
+
+ } else {
+
+ if (!pdoc->HasCaseFolder())
+ pdoc->SetCaseFolder(CaseFolderForEncoding());
+
+ const Range rangeMainSelection(sel.RangeMain().Start().Position(), sel.RangeMain().End().Position());
+ const std::string selectedText = RangeText(rangeMainSelection.start, rangeMainSelection.end);
+
+ const Range rangeTarget(targetStart, targetEnd);
+ std::vector<Range> searchRanges;
+ // Search should be over the target range excluding the current selection so
+ // may need to search 2 ranges, after the selection then before the selection.
+ if (rangeTarget.Overlaps(rangeMainSelection)) {
+ // Common case is that the selection is completely within the target but
+ // may also have overlap at start or end.
+ if (rangeMainSelection.end < rangeTarget.end)
+ searchRanges.push_back(Range(rangeMainSelection.end, rangeTarget.end));
+ if (rangeTarget.start < rangeMainSelection.start)
+ searchRanges.push_back(Range(rangeTarget.start, rangeMainSelection.start));
+ } else {
+ // No overlap
+ searchRanges.push_back(rangeTarget);
+ }
+
+ for (std::vector<Range>::const_iterator it = searchRanges.begin(); it != searchRanges.end(); ++it) {
+ int searchStart = it->start;
+ const int searchEnd = it->end;
+ for (;;) {
+ int lengthFound = selectedText.length();
+ int pos = pdoc->FindText(searchStart, searchEnd, selectedText.c_str(),
+ searchFlags, &lengthFound);
+ if (pos >= 0) {
+ sel.AddSelection(SelectionRange(pos + lengthFound, pos));
+ ScrollRange(sel.RangeMain());
+ Redraw();
+ if (addNumber == addOne)
+ return;
+ searchStart = pos + lengthFound;
+ } else {
+ break;
+ }
+ }
+ }
+ }
+}
+
bool Editor::RangeContainsProtected(int start, int end) const {
if (vs.ProtectionActive()) {
if (start > end) {
@@ -746,9 +803,9 @@ SelectionPosition Editor::MovePositionOutsideChar(SelectionPosition pos, int mov
return pos;
}
-int Editor::MovePositionTo(SelectionPosition newPos, Selection::selTypes selt, bool ensureVisible) {
- bool simpleCaret = (sel.Count() == 1) && sel.Empty();
- SelectionPosition spCaret = sel.Last();
+void Editor::MovePositionTo(SelectionPosition newPos, Selection::selTypes selt, bool ensureVisible) {
+ const bool simpleCaret = (sel.Count() == 1) && sel.Empty();
+ const SelectionPosition spCaret = sel.Last();
int delta = newPos.Position() - sel.MainCaret();
newPos = ClampPositionIntoDocument(newPos);
@@ -756,8 +813,7 @@ int Editor::MovePositionTo(SelectionPosition newPos, Selection::selTypes selt, b
if (!multipleSelection && sel.IsRectangular() && (selt == Selection::selStream)) {
// Can't turn into multiple selection so clear additional selections
InvalidateSelection(SelectionRange(newPos), true);
- SelectionRange rangeMain = sel.RangeMain();
- sel.SetSelection(rangeMain);
+ sel.DropAdditionalRanges();
}
if (!sel.IsRectangular() && (selt == Selection::selRectangle)) {
// Switching to rectangular
@@ -776,7 +832,7 @@ int Editor::MovePositionTo(SelectionPosition newPos, Selection::selTypes selt, b
}
ShowCaretAtCurrentPosition();
- int currentLine = pdoc->LineFromPosition(newPos.Position());
+ const int currentLine = pdoc->LineFromPosition(newPos.Position());
if (ensureVisible) {
// In case in need of wrapping to ensure DisplayFromDoc works.
if (currentLine >= wrapPending.start)
@@ -795,11 +851,10 @@ int Editor::MovePositionTo(SelectionPosition newPos, Selection::selTypes selt, b
if (marginView.highlightDelimiter.NeedsDrawing(currentLine)) {
RedrawSelMargin();
}
- return 0;
}
-int Editor::MovePositionTo(int newPos, Selection::selTypes selt, bool ensureVisible) {
- return MovePositionTo(SelectionPosition(newPos), selt, ensureVisible);
+void Editor::MovePositionTo(int newPos, Selection::selTypes selt, bool ensureVisible) {
+ MovePositionTo(SelectionPosition(newPos), selt, ensureVisible);
}
SelectionPosition Editor::MovePositionSoVisible(SelectionPosition pos, int moveDir) {
@@ -1780,9 +1835,8 @@ void Editor::AddChar(char ch) {
void Editor::FilterSelections() {
if (!additionalSelectionTyping && (sel.Count() > 1)) {
- SelectionRange rangeOnly = sel.RangeMain();
- InvalidateSelection(rangeOnly, true);
- sel.SetSelection(rangeOnly);
+ InvalidateWholeSelection();
+ sel.DropAdditionalRanges();
}
}
@@ -2899,8 +2953,8 @@ void Editor::CancelModes() {
void Editor::NewLine() {
// Remove non-main ranges
- InvalidateSelection(sel.RangeMain(), true);
- sel.SetSelection(sel.RangeMain());
+ InvalidateWholeSelection();
+ sel.DropAdditionalRanges();
sel.RangeMain().ClearVirtualSpace();
// Clear main range and insert line end
@@ -3025,7 +3079,7 @@ int Editor::StartEndDisplayLine(int pos, bool start) {
int Editor::KeyCommand(unsigned int iMessage) {
switch (iMessage) {
case SCI_LINEDOWN:
- CursorUpOrDown(1);
+ CursorUpOrDown(1, Selection::noSel);
break;
case SCI_LINEDOWNEXTEND:
CursorUpOrDown(1, Selection::selStream);
@@ -3034,7 +3088,7 @@ int Editor::KeyCommand(unsigned int iMessage) {
CursorUpOrDown(1, Selection::selRectangle);
break;
case SCI_PARADOWN:
- ParaUpOrDown(1);
+ ParaUpOrDown(1, Selection::noSel);
break;
case SCI_PARADOWNEXTEND:
ParaUpOrDown(1, Selection::selStream);
@@ -3044,7 +3098,7 @@ int Editor::KeyCommand(unsigned int iMessage) {
MoveCaretInsideView(false);
break;
case SCI_LINEUP:
- CursorUpOrDown(-1);
+ CursorUpOrDown(-1, Selection::noSel);
break;
case SCI_LINEUPEXTEND:
CursorUpOrDown(-1, Selection::selStream);
@@ -3053,7 +3107,7 @@ int Editor::KeyCommand(unsigned int iMessage) {
CursorUpOrDown(-1, Selection::selRectangle);
break;
case SCI_PARAUP:
- ParaUpOrDown(-1);
+ ParaUpOrDown(-1, Selection::noSel);
break;
case SCI_PARAUPEXTEND:
ParaUpOrDown(-1, Selection::selStream);
@@ -3285,6 +3339,11 @@ int Editor::KeyCommand(unsigned int iMessage) {
case SCI_CANCEL: // Cancel any modes - handled in subclass
// Also unselect text
CancelModes();
+ if (sel.Count() > 1) {
+ // Drop additional selections
+ InvalidateWholeSelection();
+ sel.DropAdditionalRanges();
+ }
break;
case SCI_DELETEBACK:
DelCharBack(true);
@@ -3377,7 +3436,7 @@ int Editor::KeyCommand(unsigned int iMessage) {
break;
case SCI_DELWORDRIGHT: {
UndoGroup ug(pdoc);
- InvalidateSelection(sel.RangeMain(), true);
+ InvalidateWholeSelection();
sel.RangeMain().caret = SelectionPosition(
InsertSpace(sel.RangeMain().caret.Position(), sel.RangeMain().caret.VirtualSpace()));
sel.RangeMain().anchor = sel.RangeMain().caret;
@@ -3387,7 +3446,7 @@ int Editor::KeyCommand(unsigned int iMessage) {
break;
case SCI_DELWORDRIGHTEND: {
UndoGroup ug(pdoc);
- InvalidateSelection(sel.RangeMain(), true);
+ InvalidateWholeSelection();
sel.RangeMain().caret = SelectionPosition(
InsertSpace(sel.RangeMain().caret.Position(), sel.RangeMain().caret.VirtualSpace()));
int endWord = pdoc->NextWordEnd(sel.MainCaret(), 1);
@@ -3659,10 +3718,6 @@ long Editor::FindText(
static_cast<int>(ft->chrg.cpMin),
static_cast<int>(ft->chrg.cpMax),
ft->lpstrText,
- (wParam & SCFIND_MATCHCASE) != 0,
- (wParam & SCFIND_WHOLEWORD) != 0,
- (wParam & SCFIND_WORDSTART) != 0,
- (wParam & SCFIND_REGEXP) != 0,
static_cast<int>(wParam),
&lengthFound);
if (pos != -1) {
@@ -3710,18 +3765,10 @@ long Editor::SearchText(
try {
if (iMessage == SCI_SEARCHNEXT) {
pos = pdoc->FindText(searchAnchor, pdoc->Length(), txt,
- (wParam & SCFIND_MATCHCASE) != 0,
- (wParam & SCFIND_WHOLEWORD) != 0,
- (wParam & SCFIND_WORDSTART) != 0,
- (wParam & SCFIND_REGEXP) != 0,
static_cast<int>(wParam),
&lengthFound);
} else {
pos = pdoc->FindText(searchAnchor, 0, txt,
- (wParam & SCFIND_MATCHCASE) != 0,
- (wParam & SCFIND_WHOLEWORD) != 0,
- (wParam & SCFIND_WORDSTART) != 0,
- (wParam & SCFIND_REGEXP) != 0,
static_cast<int>(wParam),
&lengthFound);
}
@@ -3764,10 +3811,6 @@ long Editor::SearchInTarget(const char *text, int length) {
pdoc->SetCaseFolder(CaseFolderForEncoding());
try {
long pos = pdoc->FindText(targetStart, targetEnd, text,
- (searchFlags & SCFIND_MATCHCASE) != 0,
- (searchFlags & SCFIND_WHOLEWORD) != 0,
- (searchFlags & SCFIND_WORDSTART) != 0,
- (searchFlags & SCFIND_REGEXP) != 0,
searchFlags,
&lengthFound);
if (pos != -1) {
@@ -4584,7 +4627,7 @@ void Editor::ButtonUp(Point pt, unsigned int curTime, bool ctrl) {
if (sel.Count() > 1) {
sel.RangeMain() =
SelectionRange(newPos, sel.Range(sel.Count() - 1).anchor);
- InvalidateSelection(sel.RangeMain(), true);
+ InvalidateWholeSelection();
} else {
SetSelection(newPos, sel.RangeMain().anchor);
}
@@ -5564,6 +5607,11 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
targetEnd = static_cast<int>(lParam);
break;
+ case SCI_TARGETWHOLEDOCUMENT:
+ targetStart = 0;
+ targetEnd = pdoc->Length();
+ break;
+
case SCI_TARGETFROMSELECTION:
if (sel.MainCaret() < sel.MainAnchor()) {
targetStart = sel.MainCaret();
@@ -6145,6 +6193,9 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_WORDENDPOSITION:
return pdoc->ExtendWordSelect(static_cast<int>(wParam), 1, lParam != 0);
+ case SCI_ISRANGEWORD:
+ return pdoc->IsWordAt(static_cast<int>(wParam), lParam);
+
case SCI_SETWRAPMODE:
if (vs.SetWrapState(static_cast<int>(wParam))) {
xOffset = 0;
@@ -7168,7 +7219,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
sel.SetMoveExtends(!sel.MoveExtends() || (sel.selType != Selection::selStream));
sel.selType = Selection::selStream;
}
- InvalidateSelection(sel.RangeMain(), true);
+ InvalidateWholeSelection();
break;
}
case SCI_GETSELECTIONMODE:
@@ -7660,7 +7711,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_ROTATESELECTION:
sel.RotateMain();
- InvalidateSelection(sel.RangeMain(), true);
+ InvalidateWholeSelection();
break;
case SCI_SWAPMAINANCHORCARET:
@@ -7668,6 +7719,14 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
sel.RangeMain() = SelectionRange(sel.RangeMain().anchor, sel.RangeMain().caret);
break;
+ case SCI_MULTIPLESELECTADDNEXT:
+ MultipleSelectAdd(addOne);
+ break;
+
+ case SCI_MULTIPLESELECTADDEACH:
+ MultipleSelectAdd(addEach);
+ break;
+
case SCI_CHANGELEXERSTATE:
pdoc->ChangeLexerState(static_cast<int>(wParam), static_cast<int>(lParam));
break;
diff --git a/scintilla/src/Editor.h b/scintilla/src/Editor.h
index 15adde8..909c82a 100644
--- a/scintilla/src/Editor.h
+++ b/scintilla/src/Editor.h
@@ -313,18 +313,21 @@ protected: // ScintillaBase subclass needs access to much of Editor
void SetRectangularRange();
void ThinRectangularRange();
void InvalidateSelection(SelectionRange newMain, bool invalidateWholeSelection=false);
+ void InvalidateWholeSelection();
void SetSelection(SelectionPosition currentPos_, SelectionPosition anchor_);
void SetSelection(int currentPos_, int anchor_);
void SetSelection(SelectionPosition currentPos_);
void SetSelection(int currentPos_);
void SetEmptySelection(SelectionPosition currentPos_);
void SetEmptySelection(int currentPos_);
+ enum AddNumber { addOne, addEach };
+ void MultipleSelectAdd(AddNumber addNumber);
bool RangeContainsProtected(int start, int end) const;
bool SelectionContainsProtected();
int MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd=true) const;
SelectionPosition MovePositionOutsideChar(SelectionPosition pos, int moveDir, bool checkLineEnd=true) const;
- int MovePositionTo(SelectionPosition newPos, Selection::selTypes selt=Selection::noSel, bool ensureVisible=true);
- int MovePositionTo(int newPos, Selection::selTypes selt=Selection::noSel, bool ensureVisible=true);
+ void MovePositionTo(SelectionPosition newPos, Selection::selTypes selt=Selection::noSel, bool ensureVisible=true);
+ void MovePositionTo(int newPos, Selection::selTypes selt=Selection::noSel, bool ensureVisible=true);
SelectionPosition MovePositionSoVisible(SelectionPosition pos, int moveDir);
SelectionPosition MovePositionSoVisible(int pos, int moveDir);
Point PointMainCaret();
@@ -455,8 +458,8 @@ protected: // ScintillaBase subclass needs access to much of Editor
void Duplicate(bool forLine);
virtual void CancelModes();
void NewLine();
- void CursorUpOrDown(int direction, Selection::selTypes selt=Selection::noSel);
- void ParaUpOrDown(int direction, Selection::selTypes selt=Selection::noSel);
+ void CursorUpOrDown(int direction, Selection::selTypes selt);
+ void ParaUpOrDown(int direction, Selection::selTypes selt);
int StartEndDisplayLine(int pos, bool start);
virtual int KeyCommand(unsigned int iMessage);
virtual int KeyDefault(int /* key */, int /*modifiers*/);
diff --git a/scintilla/src/PerLine.cxx b/scintilla/src/PerLine.cxx
index f0d8fc8..4e241f8 100644
--- a/scintilla/src/PerLine.cxx
+++ b/scintilla/src/PerLine.cxx
@@ -108,11 +108,12 @@ bool MarkerHandleSet::RemoveNumber(int markerNum, bool all) {
}
void MarkerHandleSet::CombineWith(MarkerHandleSet *other) {
- MarkerHandleNumber **pmhn = &root;
+ MarkerHandleNumber **pmhn = &other->root;
while (*pmhn) {
pmhn = &((*pmhn)->next);
}
- *pmhn = other->root;
+ *pmhn = root;
+ root = other->root;
other->root = 0;
}
diff --git a/scintilla/src/Selection.cxx b/scintilla/src/Selection.cxx
index 0c35730..498c4c0 100644
--- a/scintilla/src/Selection.cxx
+++ b/scintilla/src/Selection.cxx
@@ -343,6 +343,10 @@ void Selection::DropSelection(size_t r) {
}
}
+void Selection::DropAdditionalRanges() {
+ SetSelection(RangeMain());
+}
+
void Selection::TentativeSelection(SelectionRange range) {
if (!tentativeMain) {
rangesSaved = ranges;
diff --git a/scintilla/src/Selection.h b/scintilla/src/Selection.h
index f8bc8ca..0e605bb 100644
--- a/scintilla/src/Selection.h
+++ b/scintilla/src/Selection.h
@@ -172,6 +172,7 @@ public:
void AddSelection(SelectionRange range);
void AddSelectionWithoutTrim(SelectionRange range);
void DropSelection(size_t r);
+ void DropAdditionalRanges();
void TentativeSelection(SelectionRange range);
void CommitTentative();
int CharacterInSelection(int posCharacter) const;