diff options
Diffstat (limited to 'scintilla/src')
35 files changed, 688 insertions, 384 deletions
diff --git a/scintilla/src/AutoComplete.cxx b/scintilla/src/AutoComplete.cxx index bd3aa99..9fd3b1d 100644 --- a/scintilla/src/AutoComplete.cxx +++ b/scintilla/src/AutoComplete.cxx @@ -10,6 +10,7 @@ #include <stdio.h>
#include <assert.h>
+#include <stdexcept>
#include <string>
#include <vector>
#include <algorithm>
@@ -18,6 +19,7 @@ #include "Scintilla.h"
#include "CharacterSet.h"
+#include "Position.h"
#include "AutoComplete.h"
#ifdef SCI_NAMESPACE
diff --git a/scintilla/src/CallTip.cxx b/scintilla/src/CallTip.cxx index f0f2a20..3cf7454 100644 --- a/scintilla/src/CallTip.cxx +++ b/scintilla/src/CallTip.cxx @@ -9,6 +9,7 @@ #include <string.h>
#include <stdio.h>
+#include <stdexcept>
#include <string>
#include "Platform.h"
@@ -16,6 +17,7 @@ #include "Scintilla.h"
#include "StringCopy.h"
+#include "Position.h"
#include "CallTip.h"
#ifdef SCI_NAMESPACE
diff --git a/scintilla/src/CaseConvert.cxx b/scintilla/src/CaseConvert.cxx index 5108ddc..b4c8bcf 100644 --- a/scintilla/src/CaseConvert.cxx +++ b/scintilla/src/CaseConvert.cxx @@ -10,6 +10,7 @@ #include <cstring>
+#include <stdexcept>
#include <vector>
#include <algorithm>
diff --git a/scintilla/src/CaseFolder.cxx b/scintilla/src/CaseFolder.cxx index 200ac99..4e095df 100644 --- a/scintilla/src/CaseFolder.cxx +++ b/scintilla/src/CaseFolder.cxx @@ -5,6 +5,7 @@ // Copyright 1998-2013 by Neil Hodgson <neilh@scintilla.org> // The License.txt file describes the conditions under which this software may be distributed. +#include <stdexcept> #include <vector> #include <algorithm> diff --git a/scintilla/src/Catalogue.cxx b/scintilla/src/Catalogue.cxx index 057fed3..5eedabc 100644 --- a/scintilla/src/Catalogue.cxx +++ b/scintilla/src/Catalogue.cxx @@ -12,6 +12,7 @@ #include <assert.h>
#include <ctype.h>
+#include <stdexcept>
#include <vector>
#include "ILexer.h"
diff --git a/scintilla/src/CellBuffer.cxx b/scintilla/src/CellBuffer.cxx index 4203f0a..e9f8779 100644 --- a/scintilla/src/CellBuffer.cxx +++ b/scintilla/src/CellBuffer.cxx @@ -16,6 +16,7 @@ #include "Platform.h"
#include "Scintilla.h"
+#include "Position.h"
#include "SplitVector.h"
#include "Partitioning.h"
#include "CellBuffer.h"
diff --git a/scintilla/src/CharClassify.cxx b/scintilla/src/CharClassify.cxx index d4e5aa4..5eaba45 100644 --- a/scintilla/src/CharClassify.cxx +++ b/scintilla/src/CharClassify.cxx @@ -8,6 +8,8 @@ #include <stdlib.h>
#include <ctype.h>
+#include <stdexcept>
+
#include "CharClassify.h"
#ifdef SCI_NAMESPACE
diff --git a/scintilla/src/ContractionState.cxx b/scintilla/src/ContractionState.cxx index 7d19b57..bd2d120 100644 --- a/scintilla/src/ContractionState.cxx +++ b/scintilla/src/ContractionState.cxx @@ -7,10 +7,12 @@ #include <string.h>
+#include <stdexcept>
#include <algorithm>
#include "Platform.h"
+#include "Position.h"
#include "SplitVector.h"
#include "Partitioning.h"
#include "RunStyles.h"
diff --git a/scintilla/src/Decoration.cxx b/scintilla/src/Decoration.cxx index 4ffbcff..51cf9b7 100644 --- a/scintilla/src/Decoration.cxx +++ b/scintilla/src/Decoration.cxx @@ -9,11 +9,13 @@ #include <stdio.h>
#include <stdarg.h>
+#include <stdexcept>
#include <algorithm>
#include "Platform.h"
#include "Scintilla.h"
+#include "Position.h"
#include "SplitVector.h"
#include "Partitioning.h"
#include "RunStyles.h"
diff --git a/scintilla/src/Document.cxx b/scintilla/src/Document.cxx index 34b8138..31ef548 100644 --- a/scintilla/src/Document.cxx +++ b/scintilla/src/Document.cxx @@ -26,6 +26,7 @@ #include "Scintilla.h"
#include "CharacterSet.h"
+#include "Position.h"
#include "SplitVector.h"
#include "Partitioning.h"
#include "RunStyles.h"
@@ -339,7 +340,7 @@ int Document::LineFromHandle(int markerHandle) { return static_cast<LineMarkers *>(perLineData[ldMarkers])->LineFromHandle(markerHandle);
}
-int SCI_METHOD Document::LineStart(int line) const {
+Sci_Position SCI_METHOD Document::LineStart(Sci_Position line) const {
return cb.LineStart(line);
}
@@ -347,7 +348,7 @@ bool Document::IsLineStartPosition(int position) const { return LineStart(LineFromPosition(position)) == position;
}
-int SCI_METHOD Document::LineEnd(int line) const {
+Sci_Position SCI_METHOD Document::LineEnd(Sci_Position line) const {
if (line >= LinesTotal() - 1) {
return LineStart(line + 1);
} else {
@@ -381,7 +382,7 @@ void SCI_METHOD Document::SetErrorStatus(int status) { }
}
-int SCI_METHOD Document::LineFromPosition(int pos) const {
+Sci_Position SCI_METHOD Document::LineFromPosition(Sci_Position pos) const {
return cb.LineFromPosition(pos);
}
@@ -410,7 +411,7 @@ int Document::VCHomePosition(int position) const { return startText;
}
-int SCI_METHOD Document::SetLevel(int line, int level) {
+int SCI_METHOD Document::SetLevel(Sci_Position line, int level) {
int prev = static_cast<LineLevels *>(perLineData[ldLevels])->SetLevel(line, level, LinesTotal());
if (prev != level) {
DocModification mh(SC_MOD_CHANGEFOLD | SC_MOD_CHANGEMARKER,
@@ -422,7 +423,7 @@ int SCI_METHOD Document::SetLevel(int line, int level) { return prev;
}
-int SCI_METHOD Document::GetLevel(int line) const {
+int SCI_METHOD Document::GetLevel(Sci_Position line) const {
return static_cast<LineLevels *>(perLineData[ldLevels])->GetLevel(line);
}
@@ -770,7 +771,7 @@ bool Document::NextCharacter(int &pos, int moveDir) const { }
// Return -1 on out-of-bounds
-int SCI_METHOD Document::GetRelativePosition(int positionStart, int characterOffset) const {
+Sci_Position SCI_METHOD Document::GetRelativePosition(Sci_Position positionStart, Sci_Position characterOffset) const {
int pos = positionStart;
if (dbcsCodePage) {
const int increment = (characterOffset > 0) ? 1 : -1;
@@ -810,7 +811,7 @@ int Document::GetRelativePositionUTF16(int positionStart, int characterOffset) c return pos;
}
-int SCI_METHOD Document::GetCharacterAndWidth(int position, int *pWidth) const {
+int SCI_METHOD Document::GetCharacterAndWidth(Sci_Position position, Sci_Position *pWidth) const {
int character;
int bytesInCharacter = 1;
if (dbcsCodePage) {
@@ -1050,7 +1051,7 @@ void Document::ChangeInsertion(const char *s, int length) { insertion.assign(s, length);
}
-int SCI_METHOD Document::AddData(char *data, int length) {
+int SCI_METHOD Document::AddData(char *data, Sci_Position length) {
try {
int position = Length();
InsertString(position, data, length);
@@ -1247,7 +1248,7 @@ static std::string CreateIndentation(int indent, int tabSize, bool insertSpaces) return indentation;
}
-int SCI_METHOD Document::GetLineIndentation(int line) {
+int SCI_METHOD Document::GetLineIndentation(Sci_Position line) {
int indent = 0;
if ((line >= 0) && (line < LinesTotal())) {
int lineStart = LineStart(line);
@@ -1827,11 +1828,11 @@ int Document::GetCharsOfClass(CharClassify::cc characterClass, unsigned char *bu return charClass.GetCharsOfClass(characterClass, buffer);
}
-void SCI_METHOD Document::StartStyling(int position, char) {
+void SCI_METHOD Document::StartStyling(Sci_Position position, char) {
endStyled = position;
}
-bool SCI_METHOD Document::SetStyleFor(int length, char style) {
+bool SCI_METHOD Document::SetStyleFor(Sci_Position length, char style) {
if (enteredStyling != 0) {
return false;
} else {
@@ -1848,7 +1849,7 @@ bool SCI_METHOD Document::SetStyleFor(int length, char style) { }
}
-bool SCI_METHOD Document::SetStyles(int length, const char *styles) {
+bool SCI_METHOD Document::SetStyles(Sci_Position length, const char *styles) {
if (enteredStyling != 0) {
return false;
} else {
@@ -1900,7 +1901,7 @@ void Document::LexerChanged() { }
}
-int SCI_METHOD Document::SetLineState(int line, int state) {
+int SCI_METHOD Document::SetLineState(Sci_Position line, int state) {
int statePrevious = static_cast<LineState *>(perLineData[ldState])->SetLineState(line, state);
if (state != statePrevious) {
DocModification mh(SC_MOD_CHANGELINESTATE, LineStart(line), 0, 0, 0, line);
@@ -1909,7 +1910,7 @@ int SCI_METHOD Document::SetLineState(int line, int state) { return statePrevious;
}
-int SCI_METHOD Document::GetLineState(int line) const {
+int SCI_METHOD Document::GetLineState(Sci_Position line) const {
return static_cast<LineState *>(perLineData[ldState])->GetLineState(line);
}
@@ -1917,7 +1918,7 @@ int Document::GetMaxLineState() { return static_cast<LineState *>(perLineData[ldState])->GetMaxLineState();
}
-void SCI_METHOD Document::ChangeLexerState(int start, int end) {
+void SCI_METHOD Document::ChangeLexerState(Sci_Position start, Sci_Position end) {
DocModification mh(SC_MOD_LEXERSTATE, start, end-start, 0, 0, 0);
NotifyModified(mh);
}
@@ -1997,7 +1998,7 @@ void Document::IncrementStyleClock() { styleClock = (styleClock + 1) % 0x100000;
}
-void SCI_METHOD Document::DecorationFillRange(int position, int value, int fillLength) {
+void SCI_METHOD Document::DecorationFillRange(Sci_Position position, int value, Sci_Position fillLength) {
if (decorations.FillRange(position, value, fillLength)) {
DocModification mh(SC_MOD_CHANGEINDICATOR | SC_PERFORMED_USER,
position, fillLength);
diff --git a/scintilla/src/Document.h b/scintilla/src/Document.h index 86b7174..d0ca953 100644 --- a/scintilla/src/Document.h +++ b/scintilla/src/Document.h @@ -270,7 +270,7 @@ public: void SCI_METHOD SetErrorStatus(int status);
- int SCI_METHOD LineFromPosition(int pos) const;
+ Sci_Position SCI_METHOD LineFromPosition(Sci_Position pos) const;
int ClampPositionIntoDocument(int pos) const;
bool IsCrLf(int pos) const;
int LenChar(int pos);
@@ -278,9 +278,9 @@ public: int MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd=true) const;
int NextPosition(int pos, int moveDir) const;
bool NextCharacter(int &pos, int moveDir) const; // Returns true if pos changed
- int SCI_METHOD GetRelativePosition(int positionStart, int characterOffset) const;
+ Sci_Position SCI_METHOD GetRelativePosition(Sci_Position positionStart, Sci_Position characterOffset) const;
int GetRelativePositionUTF16(int positionStart, int characterOffset) const;
- int SCI_METHOD GetCharacterAndWidth(int position, int *pWidth) const;
+ int SCI_METHOD GetCharacterAndWidth(Sci_Position position, Sci_Position *pWidth) const;
int SCI_METHOD CodePage() const;
bool SCI_METHOD IsDBCSLeadByte(char ch) const;
int SafeSegment(const char *text, int length, int lengthSegment) const;
@@ -292,7 +292,7 @@ public: bool DeleteChars(int pos, int len);
int InsertString(int position, const char *s, int insertLength);
void ChangeInsertion(const char *s, int length);
- int SCI_METHOD AddData(char *data, int length);
+ int SCI_METHOD AddData(char *data, Sci_Position length);
void * SCI_METHOD ConvertToDocument();
int Undo();
int Redo();
@@ -318,7 +318,7 @@ public: const char *RangePointer(int position, int rangeLength) { return cb.RangePointer(position, rangeLength); }
int GapPosition() const { return cb.GapPosition(); }
- int SCI_METHOD GetLineIndentation(int line);
+ int SCI_METHOD GetLineIndentation(Sci_Position line);
int SetLineIndentation(int line, int indent);
int GetLineIndentPosition(int line) const;
int GetColumn(int position);
@@ -335,10 +335,10 @@ public: void DelCharBack(int pos);
char CharAt(int position) const { return cb.CharAt(position); }
- void SCI_METHOD GetCharRange(char *buffer, int position, int lengthRetrieve) const {
+ void SCI_METHOD GetCharRange(char *buffer, Sci_Position position, Sci_Position lengthRetrieve) const {
cb.GetCharRange(buffer, position, lengthRetrieve);
}
- char SCI_METHOD StyleAt(int position) const { return cb.StyleAt(position); }
+ char SCI_METHOD StyleAt(Sci_Position position) const { return cb.StyleAt(position); }
void GetStyleRange(unsigned char *buffer, int position, int lengthRetrieve) const {
cb.GetStyleRange(buffer, position, lengthRetrieve);
}
@@ -350,16 +350,16 @@ public: void DeleteMarkFromHandle(int markerHandle);
void DeleteAllMarks(int markerNum);
int LineFromHandle(int markerHandle);
- int SCI_METHOD LineStart(int line) const;
+ Sci_Position SCI_METHOD LineStart(Sci_Position line) const;
bool IsLineStartPosition(int position) const;
- int SCI_METHOD LineEnd(int line) const;
+ Sci_Position SCI_METHOD LineEnd(Sci_Position line) const;
int LineEndPosition(int position) const;
bool IsLineEndPosition(int position) const;
bool IsPositionInLineEnd(int position) const;
int VCHomePosition(int position) const;
- int SCI_METHOD SetLevel(int line, int level);
- int SCI_METHOD GetLevel(int line) const;
+ int SCI_METHOD SetLevel(Sci_Position line, int level);
+ int SCI_METHOD GetLevel(Sci_Position line) const;
void ClearLevels();
int GetLastChild(int lineParent, int level=-1, int lastLine=-1);
int GetFoldParent(int line) const;
@@ -369,7 +369,7 @@ public: int ExtendWordSelect(int pos, int delta, bool onlyWordCharacters=false);
int NextWordStart(int pos, int delta);
int NextWordEnd(int pos, int delta);
- int SCI_METHOD Length() const { return cb.Length(); }
+ Sci_Position SCI_METHOD Length() const { return cb.Length(); }
void Allocate(int newSize) { cb.Allocate(newSize); }
struct CharacterExtracted {
@@ -395,9 +395,9 @@ public: void SetDefaultCharClasses(bool includeWordClass);
void SetCharClasses(const unsigned char *chars, CharClassify::cc newCharClass);
int GetCharsOfClass(CharClassify::cc characterClass, unsigned char *buffer);
- void SCI_METHOD StartStyling(int position, char mask);
- bool SCI_METHOD SetStyleFor(int length, char style);
- bool SCI_METHOD SetStyles(int length, const char *styles);
+ void SCI_METHOD StartStyling(Sci_Position position, char mask);
+ bool SCI_METHOD SetStyleFor(Sci_Position length, char style);
+ bool SCI_METHOD SetStyles(Sci_Position length, const char *styles);
int GetEndStyled() const { return endStyled; }
void EnsureStyledTo(int pos);
void LexerChanged();
@@ -406,12 +406,12 @@ public: void SCI_METHOD DecorationSetCurrentIndicator(int indicator) {
decorations.SetCurrentIndicator(indicator);
}
- void SCI_METHOD DecorationFillRange(int position, int value, int fillLength);
+ void SCI_METHOD DecorationFillRange(Sci_Position position, int value, Sci_Position fillLength);
- int SCI_METHOD SetLineState(int line, int state);
- int SCI_METHOD GetLineState(int line) const;
+ int SCI_METHOD SetLineState(Sci_Position line, int state);
+ int SCI_METHOD GetLineState(Sci_Position line) const;
int GetMaxLineState();
- void SCI_METHOD ChangeLexerState(int start, int end);
+ void SCI_METHOD ChangeLexerState(Sci_Position start, Sci_Position end);
StyledText MarginStyledText(int line) const;
void MarginSetStyle(int line, int style);
diff --git a/scintilla/src/EditModel.cxx b/scintilla/src/EditModel.cxx index b50ade2..35903c6 100644 --- a/scintilla/src/EditModel.cxx +++ b/scintilla/src/EditModel.cxx @@ -25,6 +25,7 @@ #include "Scintilla.h" #include "StringCopy.h" +#include "Position.h" #include "SplitVector.h" #include "Partitioning.h" #include "RunStyles.h" diff --git a/scintilla/src/EditView.cxx b/scintilla/src/EditView.cxx index 5372e3a..f8912a9 100644 --- a/scintilla/src/EditView.cxx +++ b/scintilla/src/EditView.cxx @@ -25,6 +25,7 @@ #include "Scintilla.h" #include "StringCopy.h" +#include "Position.h" #include "SplitVector.h" #include "Partitioning.h" #include "RunStyles.h" @@ -389,9 +390,17 @@ void EditView::LayoutLine(const EditModel &model, int line, Surface *surface, co else if (vstyle.styles[ll->styles[numCharsInLine]].caseForce == Style::caseLower) allSame = allSame && (ll->chars[numCharsInLine] == static_cast<char>(tolower(chDoc))); - else // Style::caseUpper + else if (vstyle.styles[ll->styles[numCharsInLine]].caseForce == Style::caseUpper) allSame = allSame && (ll->chars[numCharsInLine] == static_cast<char>(toupper(chDoc))); + else { // Style::caseCamel + if ((model.pdoc->WordCharClass(ll->chars[numCharsInLine]) == CharClassify::ccWord) && + ((numCharsInLine == 0) || (model.pdoc->WordCharClass(ll->chars[numCharsInLine - 1]) != CharClassify::ccWord))) { + allSame = allSame && (ll->chars[numCharsInLine] == static_cast<char>(toupper(chDoc))); + } else { + allSame = allSame && (ll->chars[numCharsInLine] == static_cast<char>(tolower(chDoc))); + } + } numCharsInLine++; } allSame = allSame && (ll->styles[numCharsInLine] == styleByte); // For eolFilled @@ -434,6 +443,14 @@ void EditView::LayoutLine(const EditModel &model, int line, Surface *surface, co ll->chars[charInLine] = static_cast<char>(toupper(chDoc)); else if (vstyle.styles[ll->styles[charInLine]].caseForce == Style::caseLower) ll->chars[charInLine] = static_cast<char>(tolower(chDoc)); + else if (vstyle.styles[ll->styles[charInLine]].caseForce == Style::caseCamel) { + if ((model.pdoc->WordCharClass(ll->chars[charInLine]) == CharClassify::ccWord) && + ((charInLine == 0) || (model.pdoc->WordCharClass(ll->chars[charInLine - 1]) != CharClassify::ccWord))) { + ll->chars[charInLine] = static_cast<char>(toupper(chDoc)); + } else { + ll->chars[charInLine] = static_cast<char>(tolower(chDoc)); + } + } } } ll->xHighlightGuide = 0; @@ -756,6 +773,8 @@ static void SimpleAlphaRectangle(Surface *surface, PRectangle rc, ColourDesired static void DrawTextBlob(Surface *surface, const ViewStyle &vsDraw, PRectangle rcSegment, const char *s, ColourDesired textBack, ColourDesired textFore, bool fillBackground) { + if (rcSegment.Empty()) + return; if (fillBackground) { surface->FillRectangle(rcSegment, textBack); } @@ -1268,7 +1287,7 @@ void EditView::DrawBackground(Surface *surface, const EditModel &model, const Vi rcSegment.right = ll->positions[ts.end()] + xStart - static_cast<XYPOSITION>(subLineStart); // Only try to draw if really visible - enhances performance by not calling environment to // draw strings that are completely past the right side of the window. - if (rcSegment.Intersects(rcLine)) { + if (!rcSegment.Empty() && rcSegment.Intersects(rcLine)) { // Clip to line rectangle, since may have a huge position which will not work with some platforms if (rcSegment.left < rcLine.left) rcSegment.left = rcLine.left; diff --git a/scintilla/src/Editor.cxx b/scintilla/src/Editor.cxx index 7170aa2..a7de643 100644 --- a/scintilla/src/Editor.cxx +++ b/scintilla/src/Editor.cxx @@ -25,6 +25,7 @@ #include "Scintilla.h"
#include "StringCopy.h"
+#include "Position.h"
#include "SplitVector.h"
#include "Partitioning.h"
#include "RunStyles.h"
@@ -731,7 +732,7 @@ void Editor::MultipleSelectAdd(AddNumber addNumber) { int searchStart = it->start;
const int searchEnd = it->end;
for (;;) {
- int lengthFound = selectedText.length();
+ int lengthFound = static_cast<int>(selectedText.length());
int pos = pdoc->FindText(searchStart, searchEnd, selectedText.c_str(),
searchFlags, &lengthFound);
if (pos >= 0) {
@@ -803,9 +804,37 @@ SelectionPosition Editor::MovePositionOutsideChar(SelectionPosition pos, int mov return pos;
}
+void Editor::MovedCaret(SelectionPosition newPos, SelectionPosition previousPos, bool ensureVisible) {
+ const int currentLine = pdoc->LineFromPosition(newPos.Position());
+ if (ensureVisible) {
+ // In case in need of wrapping to ensure DisplayFromDoc works.
+ if (currentLine >= wrapPending.start)
+ WrapLines(wsAll);
+ XYScrollPosition newXY = XYScrollToMakeVisible(
+ SelectionRange(posDrag.IsValid() ? posDrag : newPos), xysDefault);
+ if (previousPos.IsValid() && (newXY.xOffset == xOffset)) {
+ // simple vertical scroll then invalidate
+ ScrollTo(newXY.topLine);
+ InvalidateSelection(SelectionRange(previousPos), true);
+ } else {
+ SetXYScroll(newXY);
+ }
+ }
+
+ ShowCaretAtCurrentPosition();
+
+ ClaimSelection();
+ SetHoverIndicatorPosition(sel.MainCaret());
+ QueueIdleWork(WorkNeeded::workUpdateUI);
+
+ if (marginView.highlightDelimiter.NeedsDrawing(currentLine)) {
+ RedrawSelMargin();
+ }
+}
+
void Editor::MovePositionTo(SelectionPosition newPos, Selection::selTypes selt, bool ensureVisible) {
- const bool simpleCaret = (sel.Count() == 1) && sel.Empty();
- const SelectionPosition spCaret = sel.Last();
+ const SelectionPosition spCaret = ((sel.Count() == 1) && sel.Empty()) ?
+ sel.Last() : SelectionPosition(INVALID_POSITION);
int delta = newPos.Position() - sel.MainCaret();
newPos = ClampPositionIntoDocument(newPos);
@@ -830,27 +859,8 @@ void Editor::MovePositionTo(SelectionPosition newPos, Selection::selTypes selt, } else {
SetEmptySelection(newPos);
}
- ShowCaretAtCurrentPosition();
- const int currentLine = pdoc->LineFromPosition(newPos.Position());
- if (ensureVisible) {
- // In case in need of wrapping to ensure DisplayFromDoc works.
- if (currentLine >= wrapPending.start)
- WrapLines(wsAll);
- XYScrollPosition newXY = XYScrollToMakeVisible(
- SelectionRange(posDrag.IsValid() ? posDrag : sel.RangeMain().caret), xysDefault);
- if (simpleCaret && (newXY.xOffset == xOffset)) {
- // simple vertical scroll then invalidate
- ScrollTo(newXY.topLine);
- InvalidateSelection(SelectionRange(spCaret), true);
- } else {
- SetXYScroll(newXY);
- }
- }
-
- if (marginView.highlightDelimiter.NeedsDrawing(currentLine)) {
- RedrawSelMargin();
- }
+ MovedCaret(newPos, spCaret, ensureVisible);
}
void Editor::MovePositionTo(int newPos, Selection::selTypes selt, bool ensureVisible) {
@@ -2952,30 +2962,36 @@ void Editor::CancelModes() { }
void Editor::NewLine() {
- // Remove non-main ranges
InvalidateWholeSelection();
- sel.DropAdditionalRanges();
- sel.RangeMain().ClearVirtualSpace();
+ if (sel.IsRectangular() || !additionalSelectionTyping) {
+ // Remove non-main ranges
+ sel.DropAdditionalRanges();
+ }
- // Clear main range and insert line end
- bool needGroupUndo = !sel.Empty();
- if (needGroupUndo)
- pdoc->BeginUndoAction();
+ UndoGroup ug(pdoc, !sel.Empty() || (sel.Count() > 1));
- if (!sel.Empty())
+ // Clear each range
+ if (!sel.Empty()) {
ClearSelection();
- const char *eol = "\n";
- if (pdoc->eolMode == SC_EOL_CRLF) {
- eol = "\r\n";
- } else if (pdoc->eolMode == SC_EOL_CR) {
- eol = "\r";
- } // else SC_EOL_LF -> "\n" already set
- const int insertLength = pdoc->InsertString(sel.MainCaret(), eol, istrlen(eol));
- // Want to end undo group before NotifyChar as applications often modify text here
- if (needGroupUndo)
- pdoc->EndUndoAction();
- if (insertLength > 0) {
- SetEmptySelection(sel.MainCaret() + insertLength);
+ }
+
+ // Insert each line end
+ size_t countInsertions = 0;
+ for (size_t r = 0; r < sel.Count(); r++) {
+ sel.Range(r).ClearVirtualSpace();
+ const char *eol = StringFromEOLMode(pdoc->eolMode);
+ const int positionInsert = sel.Range(r).caret.Position();
+ const int insertLength = pdoc->InsertString(positionInsert, eol, istrlen(eol));
+ if (insertLength > 0) {
+ sel.Range(r) = SelectionRange(positionInsert + insertLength);
+ countInsertions++;
+ }
+ }
+
+ // Perform notifications after all the changes as the application may change the
+ // selections in response to the characters.
+ for (size_t i = 0; i < countInsertions; i++) {
+ const char *eol = StringFromEOLMode(pdoc->eolMode);
while (*eol) {
NotifyChar(*eol);
if (recordingMacro) {
@@ -2987,6 +3003,7 @@ void Editor::NewLine() { eol++;
}
}
+
SetLastXChosen();
SetScrollBars();
EnsureCaretVisible();
@@ -2994,26 +3011,17 @@ void Editor::NewLine() { ShowCaretAtCurrentPosition();
}
-void Editor::CursorUpOrDown(int direction, Selection::selTypes selt) {
- SelectionPosition caretToUse = sel.Range(sel.Main()).caret;
- if (sel.IsRectangular()) {
- if (selt == Selection::noSel) {
- caretToUse = (direction > 0) ? sel.Limits().end : sel.Limits().start;
- } else {
- caretToUse = sel.Rectangular().caret;
- }
- }
-
- Point pt = LocationFromPosition(caretToUse);
+SelectionPosition Editor::PositionUpOrDown(SelectionPosition spStart, int direction, int lastX) {
+ const Point pt = LocationFromPosition(spStart);
int skipLines = 0;
if (vs.annotationVisible) {
- int lineDoc = pdoc->LineFromPosition(caretToUse.Position());
- Point ptStartLine = LocationFromPosition(pdoc->LineStart(lineDoc));
- int subLine = static_cast<int>(pt.y - ptStartLine.y) / vs.lineHeight;
+ const int lineDoc = pdoc->LineFromPosition(spStart.Position());
+ const Point ptStartLine = LocationFromPosition(pdoc->LineStart(lineDoc));
+ const int subLine = static_cast<int>(pt.y - ptStartLine.y) / vs.lineHeight;
if (direction < 0 && subLine == 0) {
- int lineDisplay = cs.DisplayFromDoc(lineDoc);
+ const int lineDisplay = cs.DisplayFromDoc(lineDoc);
if (lineDisplay > 0) {
skipLines = pdoc->AnnotationLines(cs.DocFromDisplay(lineDisplay - 1));
}
@@ -3022,9 +3030,12 @@ void Editor::CursorUpOrDown(int direction, Selection::selTypes selt) { }
}
- int newY = static_cast<int>(pt.y) + (1 + skipLines) * direction * vs.lineHeight;
+ const int newY = static_cast<int>(pt.y) + (1 + skipLines) * direction * vs.lineHeight;
+ if (lastX < 0) {
+ lastX = static_cast<int>(pt.x) + xOffset;
+ }
SelectionPosition posNew = SPositionFromLocation(
- Point::FromInts(lastXChosen - xOffset, newY), false, false, UserVirtualSpace());
+ Point::FromInts(lastX - xOffset, newY), false, false, UserVirtualSpace());
if (direction < 0) {
// Line wrapping may lead to a location on the same line, so
@@ -3039,14 +3050,53 @@ void Editor::CursorUpOrDown(int direction, Selection::selTypes selt) { // There is an equivalent case when moving down which skips
// over a line.
Point ptNew = LocationFromPosition(posNew.Position());
- while ((posNew.Position() > caretToUse.Position()) && (ptNew.y > newY)) {
+ while ((posNew.Position() > spStart.Position()) && (ptNew.y > newY)) {
posNew.Add(-1);
posNew.SetVirtualSpace(0);
ptNew = LocationFromPosition(posNew.Position());
}
}
+ return posNew;
+}
- MovePositionTo(MovePositionSoVisible(posNew, direction), selt);
+void Editor::CursorUpOrDown(int direction, Selection::selTypes selt) {
+ SelectionPosition caretToUse = sel.Range(sel.Main()).caret;
+ if (sel.IsRectangular()) {
+ if (selt == Selection::noSel) {
+ caretToUse = (direction > 0) ? sel.Limits().end : sel.Limits().start;
+ } else {
+ caretToUse = sel.Rectangular().caret;
+ }
+ }
+ if (selt == Selection::selRectangle) {
+ const SelectionRange rangeBase = sel.IsRectangular() ? sel.Rectangular() : sel.RangeMain();
+ if (!sel.IsRectangular()) {
+ InvalidateWholeSelection();
+ sel.DropAdditionalRanges();
+ }
+ const SelectionPosition posNew = MovePositionSoVisible(
+ PositionUpOrDown(caretToUse, direction, lastXChosen), direction);
+ sel.selType = Selection::selRectangle;
+ sel.Rectangular() = SelectionRange(posNew, rangeBase.anchor);
+ SetRectangularRange();
+ MovedCaret(posNew, caretToUse, true);
+ } else {
+ InvalidateWholeSelection();
+ if (!additionalSelectionTyping || (sel.IsRectangular())) {
+ sel.DropAdditionalRanges();
+ }
+ sel.selType = Selection::selStream;
+ for (size_t r = 0; r < sel.Count(); r++) {
+ const int lastX = (r == sel.Main()) ? lastXChosen : -1;
+ const SelectionPosition spCaretNow = sel.Range(r).caret;
+ const SelectionPosition posNew = MovePositionSoVisible(
+ PositionUpOrDown(spCaretNow, direction, lastX), direction);
+ sel.Range(r) = selt == Selection::selStream ?
+ SelectionRange(posNew, sel.Range(r).anchor) : SelectionRange(posNew);
+ }
+ sel.RemoveDuplicates();
+ MovedCaret(sel.RangeMain().caret, caretToUse, true);
+ }
}
void Editor::ParaUpOrDown(int direction, Selection::selTypes selt) {
@@ -3076,6 +3126,402 @@ int Editor::StartEndDisplayLine(int pos, bool start) { }
}
+namespace {
+
+unsigned int WithExtends(unsigned int iMessage) {
+ switch (iMessage) {
+ case SCI_CHARLEFT: return SCI_CHARLEFTEXTEND;
+ case SCI_CHARRIGHT: return SCI_CHARRIGHTEXTEND;
+
+ case SCI_WORDLEFT: return SCI_WORDLEFTEXTEND;
+ case SCI_WORDRIGHT: return SCI_WORDRIGHTEXTEND;
+ case SCI_WORDLEFTEND: return SCI_WORDLEFTENDEXTEND;
+ case SCI_WORDRIGHTEND: return SCI_WORDRIGHTENDEXTEND;
+ case SCI_WORDPARTLEFT: return SCI_WORDPARTLEFTEXTEND;
+ case SCI_WORDPARTRIGHT: return SCI_WORDPARTRIGHTEXTEND;
+
+ case SCI_HOME: return SCI_HOMEEXTEND;
+ case SCI_HOMEDISPLAY: return SCI_HOMEDISPLAYEXTEND;
+ case SCI_HOMEWRAP: return SCI_HOMEWRAPEXTEND;
+ case SCI_VCHOME: return SCI_VCHOMEEXTEND;
+ case SCI_VCHOMEDISPLAY: return SCI_VCHOMEDISPLAYEXTEND;
+ case SCI_VCHOMEWRAP: return SCI_VCHOMEWRAPEXTEND;
+
+ case SCI_LINEEND: return SCI_LINEENDEXTEND;
+ case SCI_LINEENDDISPLAY: return SCI_LINEENDDISPLAYEXTEND;
+ case SCI_LINEENDWRAP: return SCI_LINEENDWRAPEXTEND;
+
+ default: return iMessage;
+ }
+}
+
+int NaturalDirection(unsigned int iMessage) {
+ switch (iMessage) {
+ case SCI_CHARLEFT:
+ case SCI_CHARLEFTEXTEND:
+ case SCI_CHARLEFTRECTEXTEND:
+ case SCI_WORDLEFT:
+ case SCI_WORDLEFTEXTEND:
+ case SCI_WORDLEFTEND:
+ case SCI_WORDLEFTENDEXTEND:
+ case SCI_WORDPARTLEFT:
+ case SCI_WORDPARTLEFTEXTEND:
+ case SCI_HOME:
+ case SCI_HOMEEXTEND:
+ case SCI_HOMEDISPLAY:
+ case SCI_HOMEDISPLAYEXTEND:
+ case SCI_HOMEWRAP:
+ case SCI_HOMEWRAPEXTEND:
+ // VC_HOME* mostly goes back
+ case SCI_VCHOME:
+ case SCI_VCHOMEEXTEND:
+ case SCI_VCHOMEDISPLAY:
+ case SCI_VCHOMEDISPLAYEXTEND:
+ case SCI_VCHOMEWRAP:
+ case SCI_VCHOMEWRAPEXTEND:
+ return -1;
+
+ default:
+ return 1;
+ }
+}
+
+bool IsRectExtend(unsigned int iMessage) {
+ switch (iMessage) {
+ case SCI_CHARLEFTRECTEXTEND:
+ case SCI_CHARRIGHTRECTEXTEND:
+ case SCI_HOMERECTEXTEND:
+ case SCI_VCHOMERECTEXTEND:
+ case SCI_LINEENDRECTEXTEND:
+ return true;
+ default:
+ return false;
+ }
+}
+
+}
+
+int Editor::VCHomeDisplayPosition(int position) {
+ const int homePos = pdoc->VCHomePosition(position);
+ const int viewLineStart = StartEndDisplayLine(position, true);
+ if (viewLineStart > homePos)
+ return viewLineStart;
+ else
+ return homePos;
+}
+
+int Editor::VCHomeWrapPosition(int position) {
+ const int homePos = pdoc->VCHomePosition(position);
+ const int viewLineStart = StartEndDisplayLine(position, true);
+ if ((viewLineStart < position) && (viewLineStart > homePos))
+ return viewLineStart;
+ else
+ return homePos;
+}
+
+int Editor::LineEndWrapPosition(int position) {
+ const int endPos = StartEndDisplayLine(position, false);
+ const int realEndPos = pdoc->LineEndPosition(position);
+ if (endPos > realEndPos // if moved past visible EOLs
+ || position >= endPos) // if at end of display line already
+ return realEndPos;
+ else
+ return endPos;
+}
+
+int Editor::HorizontalMove(unsigned int iMessage) {
+ if (sel.MoveExtends()) {
+ iMessage = WithExtends(iMessage);
+ }
+
+ if (!multipleSelection && !sel.IsRectangular()) {
+ // Simplify selection down to 1
+ sel.SetSelection(sel.RangeMain());
+ }
+
+ // Invalidate each of the current selections
+ InvalidateWholeSelection();
+
+ if (IsRectExtend(iMessage)) {
+ const SelectionRange rangeBase = sel.IsRectangular() ? sel.Rectangular() : sel.RangeMain();
+ if (!sel.IsRectangular()) {
+ sel.DropAdditionalRanges();
+ }
+ // Will change to rectangular if not currently rectangular
+ SelectionPosition spCaret = rangeBase.caret;
+ switch (iMessage) {
+ case SCI_CHARLEFTRECTEXTEND:
+ if (pdoc->IsLineEndPosition(spCaret.Position()) && spCaret.VirtualSpace()) {
+ spCaret.SetVirtualSpace(spCaret.VirtualSpace() - 1);
+ } else {
+ spCaret = SelectionPosition(spCaret.Position() - 1);
+ }
+ break;
+ case SCI_CHARRIGHTRECTEXTEND:
+ if ((virtualSpaceOptions & SCVS_RECTANGULARSELECTION) && pdoc->IsLineEndPosition(sel.MainCaret())) {
+ spCaret.SetVirtualSpace(spCaret.VirtualSpace() + 1);
+ } else {
+ spCaret = SelectionPosition(spCaret.Position() + 1);
+ }
+ break;
+ case SCI_HOMERECTEXTEND:
+ spCaret = SelectionPosition(pdoc->LineStart(pdoc->LineFromPosition(spCaret.Position())));
+ break;
+ case SCI_VCHOMERECTEXTEND:
+ spCaret = SelectionPosition(pdoc->VCHomePosition(spCaret.Position()));
+ break;
+ case SCI_LINEENDRECTEXTEND:
+ spCaret = SelectionPosition(pdoc->LineEndPosition(spCaret.Position()));
+ break;
+ }
+ const int directionMove = (spCaret < rangeBase.caret) ? -1 : 1;
+ spCaret = MovePositionSoVisible(spCaret, directionMove);
+ sel.selType = Selection::selRectangle;
+ sel.Rectangular() = SelectionRange(spCaret, rangeBase.anchor);
+ SetRectangularRange();
+ } else {
+ if (sel.IsRectangular()) {
+ // Not a rectangular extension so switch to stream.
+ SelectionPosition selAtLimit = (NaturalDirection(iMessage) > 0) ? sel.Limits().end : sel.Limits().start;
+ sel.selType = Selection::selStream;
+ sel.SetSelection(SelectionRange(selAtLimit));
+ }
+ if (!additionalSelectionTyping) {
+ InvalidateWholeSelection();
+ sel.DropAdditionalRanges();
+ }
+ for (size_t r = 0; r < sel.Count(); r++) {
+ const SelectionPosition spCaretNow = sel.Range(r).caret;
+ SelectionPosition spCaret = spCaretNow;
+ switch (iMessage) {
+ case SCI_CHARLEFT:
+ case SCI_CHARLEFTEXTEND:
+ if (spCaret.VirtualSpace()) {
+ spCaret.SetVirtualSpace(spCaret.VirtualSpace() - 1);
+ } else {
+ spCaret = SelectionPosition(spCaret.Position() - 1);
+ }
+ break;
+ case SCI_CHARRIGHT:
+ case SCI_CHARRIGHTEXTEND:
+ if ((virtualSpaceOptions & SCVS_USERACCESSIBLE) && pdoc->IsLineEndPosition(spCaret.Position())) {
+ spCaret.SetVirtualSpace(spCaret.VirtualSpace() + 1);
+ } else {
+ spCaret = SelectionPosition(spCaret.Position() + 1);
+ }
+ break;
+ case SCI_WORDLEFT:
+ case SCI_WORDLEFTEXTEND:
+ spCaret = SelectionPosition(pdoc->NextWordStart(spCaret.Position(), -1));
+ break;
+ case SCI_WORDRIGHT:
+ case SCI_WORDRIGHTEXTEND:
+ spCaret = SelectionPosition(pdoc->NextWordStart(spCaret.Position(), 1));
+ break;
+ case SCI_WORDLEFTEND:
+ case SCI_WORDLEFTENDEXTEND:
+ spCaret = SelectionPosition(pdoc->NextWordEnd(spCaret.Position(), -1));
+ break;
+ case SCI_WORDRIGHTEND:
+ case SCI_WORDRIGHTENDEXTEND:
+ spCaret = SelectionPosition(pdoc->NextWordEnd(spCaret.Position(), 1));
+ break;
+ case SCI_WORDPARTLEFT:
+ case SCI_WORDPARTLEFTEXTEND:
+ spCaret = SelectionPosition(pdoc->WordPartLeft(spCaret.Position()));
+ break;
+ case SCI_WORDPARTRIGHT:
+ case SCI_WORDPARTRIGHTEXTEND:
+ spCaret = SelectionPosition(pdoc->WordPartRight(spCaret.Position()));
+ break;
+ case SCI_HOME:
+ case SCI_HOMEEXTEND:
+ spCaret = SelectionPosition(pdoc->LineStart(pdoc->LineFromPosition(spCaret.Position())));
+ break;
+ case SCI_HOMEDISPLAY:
+ case SCI_HOMEDISPLAYEXTEND:
+ spCaret = SelectionPosition(StartEndDisplayLine(spCaret.Position(), true));
+ break;
+ case SCI_HOMEWRAP:
+ case SCI_HOMEWRAPEXTEND:
+ spCaret = MovePositionSoVisible(StartEndDisplayLine(spCaret.Position(), true), -1);
+ if (spCaretNow <= spCaret)
+ spCaret = SelectionPosition(pdoc->LineStart(pdoc->LineFromPosition(spCaret.Position())));
+ break;
+ case SCI_VCHOME:
+ case SCI_VCHOMEEXTEND:
+ // VCHome alternates between beginning of line and beginning of text so may move back or forwards
+ spCaret = SelectionPosition(pdoc->VCHomePosition(spCaret.Position()));
+ break;
+ case SCI_VCHOMEDISPLAY:
+ case SCI_VCHOMEDISPLAYEXTEND:
+ spCaret = SelectionPosition(VCHomeDisplayPosition(spCaret.Position()));
+ break;
+ case SCI_VCHOMEWRAP:
+ case SCI_VCHOMEWRAPEXTEND:
+ spCaret = SelectionPosition(VCHomeWrapPosition(spCaret.Position()));
+ break;
+ case SCI_LINEEND:
+ case SCI_LINEENDEXTEND:
+ spCaret = SelectionPosition(pdoc->LineEndPosition(spCaret.Position()));
+ break;
+ case SCI_LINEENDDISPLAY:
+ case SCI_LINEENDDISPLAYEXTEND:
+ spCaret = SelectionPosition(StartEndDisplayLine(spCaret.Position(), false));
+ break;
+ case SCI_LINEENDWRAP:
+ case SCI_LINEENDWRAPEXTEND:
+ spCaret = SelectionPosition(LineEndWrapPosition(spCaret.Position()));
+ break;
+
+ default:
+ PLATFORM_ASSERT(false);
+ }
+
+ const int directionMove = (spCaret < spCaretNow) ? -1 : 1;
+ spCaret = MovePositionSoVisible(spCaret, directionMove);
+
+ // Handle move versus extend, and special behaviour for non-emoty left/right
+ switch (iMessage) {
+ case SCI_CHARLEFT:
+ case SCI_CHARRIGHT:
+ if (sel.Range(r).Empty()) {
+ sel.Range(r) = SelectionRange(spCaret);
+ } else {
+ sel.Range(r) = SelectionRange(
+ (iMessage == SCI_CHARLEFT) ? sel.Range(r).Start() : sel.Range(r).End());
+ }
+ break;
+
+ case SCI_WORDLEFT:
+ case SCI_WORDRIGHT:
+ case SCI_WORDLEFTEND:
+ case SCI_WORDRIGHTEND:
+ case SCI_WORDPARTLEFT:
+ case SCI_WORDPARTRIGHT:
+ case SCI_HOME:
+ case SCI_HOMEDISPLAY:
+ case SCI_HOMEWRAP:
+ case SCI_VCHOME:
+ case SCI_VCHOMEDISPLAY:
+ case SCI_VCHOMEWRAP:
+ case SCI_LINEEND:
+ case SCI_LINEENDDISPLAY:
+ case SCI_LINEENDWRAP:
+ sel.Range(r) = SelectionRange(spCaret);
+ break;
+
+ case SCI_CHARLEFTEXTEND:
+ case SCI_CHARRIGHTEXTEND:
+ case SCI_WORDLEFTEXTEND:
+ case SCI_WORDRIGHTEXTEND:
+ case SCI_WORDLEFTENDEXTEND:
+ case SCI_WORDRIGHTENDEXTEND:
+ case SCI_WORDPARTLEFTEXTEND:
+ case SCI_WORDPARTRIGHTEXTEND:
+ case SCI_HOMEEXTEND:
+ case SCI_HOMEDISPLAYEXTEND:
+ case SCI_HOMEWRAPEXTEND:
+ case SCI_VCHOMEEXTEND:
+ case SCI_VCHOMEDISPLAYEXTEND:
+ case SCI_VCHOMEWRAPEXTEND:
+ case SCI_LINEENDEXTEND:
+ case SCI_LINEENDDISPLAYEXTEND:
+ case SCI_LINEENDWRAPEXTEND: {
+ SelectionRange rangeNew = SelectionRange(spCaret, sel.Range(r).anchor);
+ sel.TrimOtherSelections(r, SelectionRange(rangeNew));
+ sel.Range(r) = rangeNew;
+ }
+ break;
+
+ default:
+ PLATFORM_ASSERT(false);
+ }
+ }
+ }
+
+ sel.RemoveDuplicates();
+
+ MovedCaret(sel.RangeMain().caret, SelectionPosition(INVALID_POSITION), true);
+
+ // Invalidate the new state of the selection
+ InvalidateWholeSelection();
+
+ SetLastXChosen();
+ // Need the line moving and so forth from MovePositionTo
+ return 0;
+}
+
+int Editor::DelWordOrLine(unsigned int iMessage) {
+ // Virtual space may be realised for SCI_DELWORDRIGHT or SCI_DELWORDRIGHTEND
+ // which means 2 actions so wrap in an undo group.
+
+ // Rightwards and leftwards deletions differ in treatment of virtual space.
+ // Clear virtual space for leftwards, realise for rightwards.
+ const bool leftwards = (iMessage == SCI_DELWORDLEFT) || (iMessage == SCI_DELLINELEFT);
+
+ if (!additionalSelectionTyping) {
+ InvalidateWholeSelection();
+ sel.DropAdditionalRanges();
+ }
+
+ UndoGroup ug0(pdoc, (sel.Count() > 1) || !leftwards);
+
+ for (size_t r = 0; r < sel.Count(); r++) {
+ if (leftwards) {
+ // Delete to the left so first clear the virtual space.
+ sel.Range(r).ClearVirtualSpace();
+ } else {
+ // Delete to the right so first realise the virtual space.
+ sel.Range(r) = SelectionRange(
+ InsertSpace(sel.Range(r).caret.Position(), sel.Range(r).caret.VirtualSpace()));
+ }
+
+ Range rangeDelete;
+ switch (iMessage) {
+ case SCI_DELWORDLEFT:
+ rangeDelete = Range(
+ pdoc->NextWordStart(sel.Range(r).caret.Position(), -1),
+ sel.Range(r).caret.Position());
+ break;
+ case SCI_DELWORDRIGHT:
+ rangeDelete = Range(
+ sel.Range(r).caret.Position(),
+ pdoc->NextWordStart(sel.Range(r).caret.Position(), 1));
+ break;
+ case SCI_DELWORDRIGHTEND:
+ rangeDelete = Range(
+ sel.Range(r).caret.Position(),
+ pdoc->NextWordEnd(sel.Range(r).caret.Position(), 1));
+ break;
+ case SCI_DELLINELEFT:
+ rangeDelete = Range(
+ pdoc->LineStart(pdoc->LineFromPosition(sel.Range(r).caret.Position())),
+ sel.Range(r).caret.Position());
+ break;
+ case SCI_DELLINERIGHT:
+ rangeDelete = Range(
+ sel.Range(r).caret.Position(),
+ pdoc->LineEnd(pdoc->LineFromPosition(sel.Range(r).caret.Position())));
+ break;
+ }
+ if (!RangeContainsProtected(rangeDelete.start, rangeDelete.end)) {
+ pdoc->DeleteChars(rangeDelete.start, rangeDelete.end - rangeDelete.start);
+ }
+ }
+
+ // May need something stronger here: can selections overlap at this point?
+ sel.RemoveDuplicates();
+
+ MovedCaret(sel.RangeMain().caret, SelectionPosition(INVALID_POSITION), true);
+
+ // Invalidate the new state of the selection
+ InvalidateWholeSelection();
+
+ SetLastXChosen();
+ return 0;
+}
+
int Editor::KeyCommand(unsigned int iMessage) {
switch (iMessage) {
case SCI_LINEDOWN:
@@ -3116,174 +3562,48 @@ int Editor::KeyCommand(unsigned int iMessage) { ScrollTo(topLine - 1);
MoveCaretInsideView(false);
break;
+
case SCI_CHARLEFT:
- if (SelectionEmpty() || sel.MoveExtends()) {
- if ((sel.Count() == 1) && pdoc->IsLineEndPosition(sel.MainCaret()) && sel.RangeMain().caret.VirtualSpace()) {
- SelectionPosition spCaret = sel.RangeMain().caret;
- spCaret.SetVirtualSpace(spCaret.VirtualSpace() - 1);
- MovePositionTo(spCaret);
- } else if (sel.MoveExtends() && sel.selType == Selection::selStream) {
- MovePositionTo(MovePositionSoVisible(SelectionPosition(sel.MainCaret() - 1), -1));
- } else {
- MovePositionTo(MovePositionSoVisible(
- SelectionPosition((sel.LimitsForRectangularElseMain().start).Position() - 1), -1));
- }
- } else {
- MovePositionTo(sel.LimitsForRectangularElseMain().start);
- }
- SetLastXChosen();
- break;
case SCI_CHARLEFTEXTEND:
- if (pdoc->IsLineEndPosition(sel.MainCaret()) && sel.RangeMain().caret.VirtualSpace()) {
- SelectionPosition spCaret = sel.RangeMain().caret;
- spCaret.SetVirtualSpace(spCaret.VirtualSpace() - 1);
- MovePositionTo(spCaret, Selection::selStream);
- } else {
- MovePositionTo(MovePositionSoVisible(SelectionPosition(sel.MainCaret() - 1), -1), Selection::selStream);
- }
- SetLastXChosen();
- break;
case SCI_CHARLEFTRECTEXTEND:
- if (pdoc->IsLineEndPosition(sel.MainCaret()) && sel.RangeMain().caret.VirtualSpace()) {
- SelectionPosition spCaret = sel.RangeMain().caret;
- spCaret.SetVirtualSpace(spCaret.VirtualSpace() - 1);
- MovePositionTo(spCaret, Selection::selRectangle);
- } else {
- MovePositionTo(MovePositionSoVisible(SelectionPosition(sel.MainCaret() - 1), -1), Selection::selRectangle);
- }
- SetLastXChosen();
- break;
case SCI_CHARRIGHT:
- if (SelectionEmpty() || sel.MoveExtends()) {
- if ((virtualSpaceOptions & SCVS_USERACCESSIBLE) && pdoc->IsLineEndPosition(sel.MainCaret())) {
- SelectionPosition spCaret = sel.RangeMain().caret;
- spCaret.SetVirtualSpace(spCaret.VirtualSpace() + 1);
- MovePositionTo(spCaret);
- } else if (sel.MoveExtends() && sel.selType == Selection::selStream) {
- MovePositionTo(MovePositionSoVisible(SelectionPosition(sel.MainCaret() + 1), 1));
- } else {
- MovePositionTo(MovePositionSoVisible(
- SelectionPosition((sel.LimitsForRectangularElseMain().end).Position() + 1), 1));
- }
- } else {
- MovePositionTo(sel.LimitsForRectangularElseMain().end);
- }
- SetLastXChosen();
- break;
case SCI_CHARRIGHTEXTEND:
- if ((virtualSpaceOptions & SCVS_USERACCESSIBLE) && pdoc->IsLineEndPosition(sel.MainCaret())) {
- SelectionPosition spCaret = sel.RangeMain().caret;
- spCaret.SetVirtualSpace(spCaret.VirtualSpace() + 1);
- MovePositionTo(spCaret, Selection::selStream);
- } else {
- MovePositionTo(MovePositionSoVisible(SelectionPosition(sel.MainCaret() + 1), 1), Selection::selStream);
- }
- SetLastXChosen();
- break;
case SCI_CHARRIGHTRECTEXTEND:
- if ((virtualSpaceOptions & SCVS_RECTANGULARSELECTION) && pdoc->IsLineEndPosition(sel.MainCaret())) {
- SelectionPosition spCaret = sel.RangeMain().caret;
- spCaret.SetVirtualSpace(spCaret.VirtualSpace() + 1);
- MovePositionTo(spCaret, Selection::selRectangle);
- } else {
- MovePositionTo(MovePositionSoVisible(SelectionPosition(sel.MainCaret() + 1), 1), Selection::selRectangle);
- }
- SetLastXChosen();
- break;
case SCI_WORDLEFT:
- MovePositionTo(MovePositionSoVisible(pdoc->NextWordStart(sel.MainCaret(), -1), -1));
- SetLastXChosen();
- break;
case SCI_WORDLEFTEXTEND:
- MovePositionTo(MovePositionSoVisible(pdoc->NextWordStart(sel.MainCaret(), -1), -1), Selection::selStream);
- SetLastXChosen();
- break;
case SCI_WORDRIGHT:
- MovePositionTo(MovePositionSoVisible(pdoc->NextWordStart(sel.MainCaret(), 1), 1));
- SetLastXChosen();
- break;
case SCI_WORDRIGHTEXTEND:
- MovePositionTo(MovePositionSoVisible(pdoc->NextWordStart(sel.MainCaret(), 1), 1), Selection::selStream);
- SetLastXChosen();
- break;
-
case SCI_WORDLEFTEND:
- MovePositionTo(MovePositionSoVisible(pdoc->NextWordEnd(sel.MainCaret(), -1), -1));
- SetLastXChosen();
- break;
case SCI_WORDLEFTENDEXTEND:
- MovePositionTo(MovePositionSoVisible(pdoc->NextWordEnd(sel.MainCaret(), -1), -1), Selection::selStream);
- SetLastXChosen();
- break;
case SCI_WORDRIGHTEND:
- MovePositionTo(MovePositionSoVisible(pdoc->NextWordEnd(sel.MainCaret(), 1), 1));
- SetLastXChosen();
- break;
case SCI_WORDRIGHTENDEXTEND:
- MovePositionTo(MovePositionSoVisible(pdoc->NextWordEnd(sel.MainCaret(), 1), 1), Selection::selStream);
- SetLastXChosen();
- break;
-
+ case SCI_WORDPARTLEFT:
+ case SCI_WORDPARTLEFTEXTEND:
+ case SCI_WORDPARTRIGHT:
+ case SCI_WORDPARTRIGHTEXTEND:
case SCI_HOME:
- MovePositionTo(pdoc->LineStart(pdoc->LineFromPosition(sel.MainCaret())));
- SetLastXChosen();
- break;
case SCI_HOMEEXTEND:
- MovePositionTo(pdoc->LineStart(pdoc->LineFromPosition(sel.MainCaret())), Selection::selStream);
- SetLastXChosen();
- break;
case SCI_HOMERECTEXTEND:
- MovePositionTo(pdoc->LineStart(pdoc->LineFromPosition(sel.MainCaret())), Selection::selRectangle);
- SetLastXChosen();
- break;
+ case SCI_HOMEDISPLAY:
+ case SCI_HOMEDISPLAYEXTEND:
+ case SCI_HOMEWRAP:
+ case SCI_HOMEWRAPEXTEND:
+ case SCI_VCHOME:
+ case SCI_VCHOMEEXTEND:
+ case SCI_VCHOMERECTEXTEND:
+ case SCI_VCHOMEDISPLAY:
+ case SCI_VCHOMEDISPLAYEXTEND:
+ case SCI_VCHOMEWRAP:
+ case SCI_VCHOMEWRAPEXTEND:
case SCI_LINEEND:
- MovePositionTo(pdoc->LineEndPosition(sel.MainCaret()));
- SetLastXChosen();
- break;
case SCI_LINEENDEXTEND:
- MovePositionTo(pdoc->LineEndPosition(sel.MainCaret()), Selection::selStream);
- SetLastXChosen();
- break;
case SCI_LINEENDRECTEXTEND:
- MovePositionTo(pdoc->LineEndPosition(sel.MainCaret()), Selection::selRectangle);
- SetLastXChosen();
- break;
- case SCI_HOMEWRAP: {
- SelectionPosition homePos = MovePositionSoVisible(StartEndDisplayLine(sel.MainCaret(), true), -1);
- if (sel.RangeMain().caret <= homePos)
- homePos = SelectionPosition(pdoc->LineStart(pdoc->LineFromPosition(sel.MainCaret())));
- MovePositionTo(homePos);
- SetLastXChosen();
- }
- break;
- case SCI_HOMEWRAPEXTEND: {
- SelectionPosition homePos = MovePositionSoVisible(StartEndDisplayLine(sel.MainCaret(), true), -1);
- if (sel.RangeMain().caret <= homePos)
- homePos = SelectionPosition(pdoc->LineStart(pdoc->LineFromPosition(sel.MainCaret())));
- MovePositionTo(homePos, Selection::selStream);
- SetLastXChosen();
- }
- break;
- case SCI_LINEENDWRAP: {
- SelectionPosition endPos = MovePositionSoVisible(StartEndDisplayLine(sel.MainCaret(), false), 1);
- SelectionPosition realEndPos = SelectionPosition(pdoc->LineEndPosition(sel.MainCaret()));
- if (endPos > realEndPos // if moved past visible EOLs
- || sel.RangeMain().caret >= endPos) // if at end of display line already
- endPos = realEndPos;
- MovePositionTo(endPos);
- SetLastXChosen();
- }
- break;
- case SCI_LINEENDWRAPEXTEND: {
- SelectionPosition endPos = MovePositionSoVisible(StartEndDisplayLine(sel.MainCaret(), false), 1);
- SelectionPosition realEndPos = SelectionPosition(pdoc->LineEndPosition(sel.MainCaret()));
- if (endPos > realEndPos // if moved past visible EOLs
- || sel.RangeMain().caret >= endPos) // if at end of display line already
- endPos = realEndPos;
- MovePositionTo(endPos, Selection::selStream);
- SetLastXChosen();
- }
- break;
+ case SCI_LINEENDDISPLAY:
+ case SCI_LINEENDDISPLAYEXTEND:
+ case SCI_LINEENDWRAP:
+ case SCI_LINEENDWRAPEXTEND:
+ return HorizontalMove(iMessage);
+
case SCI_DOCUMENTSTART:
MovePositionTo(0);
SetLastXChosen();
@@ -3381,38 +3701,6 @@ int Editor::KeyCommand(unsigned int iMessage) { case SCI_FORMFEED:
AddChar('\f');
break;
- case SCI_VCHOME:
- MovePositionTo(pdoc->VCHomePosition(sel.MainCaret()));
- SetLastXChosen();
- break;
- case SCI_VCHOMEEXTEND:
- MovePositionTo(pdoc->VCHomePosition(sel.MainCaret()), Selection::selStream);
- SetLastXChosen();
- break;
- case SCI_VCHOMERECTEXTEND:
- MovePositionTo(pdoc->VCHomePosition(sel.MainCaret()), Selection::selRectangle);
- SetLastXChosen();
- break;
- case SCI_VCHOMEWRAP: {
- SelectionPosition homePos = SelectionPosition(pdoc->VCHomePosition(sel.MainCaret()));
- SelectionPosition viewLineStart = MovePositionSoVisible(StartEndDisplayLine(sel.MainCaret(), true), -1);
- if ((viewLineStart < sel.RangeMain().caret) && (viewLineStart > homePos))
- homePos = viewLineStart;
-
- MovePositionTo(homePos);
- SetLastXChosen();
- }
- break;
- case SCI_VCHOMEWRAPEXTEND: {
- SelectionPosition homePos = SelectionPosition(pdoc->VCHomePosition(sel.MainCaret()));
- SelectionPosition viewLineStart = MovePositionSoVisible(StartEndDisplayLine(sel.MainCaret(), true), -1);
- if ((viewLineStart < sel.RangeMain().caret) && (viewLineStart > homePos))
- homePos = viewLineStart;
-
- MovePositionTo(homePos, Selection::selStream);
- SetLastXChosen();
- }
- break;
case SCI_ZOOMIN:
if (vs.zoomLevel < 20) {
vs.zoomLevel++;
@@ -3427,46 +3715,14 @@ int Editor::KeyCommand(unsigned int iMessage) { NotifyZoom();
}
break;
- case SCI_DELWORDLEFT: {
- int startWord = pdoc->NextWordStart(sel.MainCaret(), -1);
- pdoc->DeleteChars(startWord, sel.MainCaret() - startWord);
- sel.RangeMain().ClearVirtualSpace();
- SetLastXChosen();
- }
- break;
- case SCI_DELWORDRIGHT: {
- UndoGroup ug(pdoc);
- InvalidateWholeSelection();
- sel.RangeMain().caret = SelectionPosition(
- InsertSpace(sel.RangeMain().caret.Position(), sel.RangeMain().caret.VirtualSpace()));
- sel.RangeMain().anchor = sel.RangeMain().caret;
- int endWord = pdoc->NextWordStart(sel.MainCaret(), 1);
- pdoc->DeleteChars(sel.MainCaret(), endWord - sel.MainCaret());
- }
- break;
- case SCI_DELWORDRIGHTEND: {
- UndoGroup ug(pdoc);
- InvalidateWholeSelection();
- sel.RangeMain().caret = SelectionPosition(
- InsertSpace(sel.RangeMain().caret.Position(), sel.RangeMain().caret.VirtualSpace()));
- int endWord = pdoc->NextWordEnd(sel.MainCaret(), 1);
- pdoc->DeleteChars(sel.MainCaret(), endWord - sel.MainCaret());
- }
- break;
- case SCI_DELLINELEFT: {
- int line = pdoc->LineFromPosition(sel.MainCaret());
- int start = pdoc->LineStart(line);
- pdoc->DeleteChars(start, sel.MainCaret() - start);
- sel.RangeMain().ClearVirtualSpace();
- SetLastXChosen();
- }
- break;
- case SCI_DELLINERIGHT: {
- int line = pdoc->LineFromPosition(sel.MainCaret());
- int end = pdoc->LineEnd(line);
- pdoc->DeleteChars(sel.MainCaret(), end - sel.MainCaret());
- }
- break;
+
+ case SCI_DELWORDLEFT:
+ case SCI_DELWORDRIGHT:
+ case SCI_DELWORDRIGHTEND:
+ case SCI_DELLINELEFT:
+ case SCI_DELLINERIGHT:
+ return DelWordOrLine(iMessage);
+
case SCI_LINECOPY: {
int lineStart = pdoc->LineFromPosition(SelectionStart().Position());
int lineEnd = pdoc->LineFromPosition(SelectionEnd().Position());
@@ -3506,62 +3762,6 @@ int Editor::KeyCommand(unsigned int iMessage) { case SCI_UPPERCASE:
ChangeCaseOfSelection(cmUpper);
break;
- case SCI_WORDPARTLEFT:
- MovePositionTo(MovePositionSoVisible(pdoc->WordPartLeft(sel.MainCaret()), -1));
- SetLastXChosen();
- break;
- case SCI_WORDPARTLEFTEXTEND:
- MovePositionTo(MovePositionSoVisible(pdoc->WordPartLeft(sel.MainCaret()), -1), Selection::selStream);
- SetLastXChosen();
- break;
- case SCI_WORDPARTRIGHT:
- MovePositionTo(MovePositionSoVisible(pdoc->WordPartRight(sel.MainCaret()), 1));
- SetLastXChosen();
- break;
- case SCI_WORDPARTRIGHTEXTEND:
- MovePositionTo(MovePositionSoVisible(pdoc->WordPartRight(sel.MainCaret()), 1), Selection::selStream);
- SetLastXChosen();
- break;
- case SCI_HOMEDISPLAY:
- MovePositionTo(MovePositionSoVisible(
- StartEndDisplayLine(sel.MainCaret(), true), -1));
- SetLastXChosen();
- break;
- case SCI_VCHOMEDISPLAY: {
- SelectionPosition homePos = SelectionPosition(pdoc->VCHomePosition(sel.MainCaret()));
- SelectionPosition viewLineStart = MovePositionSoVisible(StartEndDisplayLine(sel.MainCaret(), true), -1);
- if (viewLineStart > homePos)
- homePos = viewLineStart;
-
- MovePositionTo(homePos);
- SetLastXChosen();
- }
- break;
- case SCI_HOMEDISPLAYEXTEND:
- MovePositionTo(MovePositionSoVisible(
- StartEndDisplayLine(sel.MainCaret(), true), -1), Selection::selStream);
- SetLastXChosen();
- break;
- case SCI_VCHOMEDISPLAYEXTEND: {
- SelectionPosition homePos = SelectionPosition(pdoc->VCHomePosition(sel.MainCaret()));
- SelectionPosition viewLineStart = MovePositionSoVisible(StartEndDisplayLine(sel.MainCaret(), true), -1);
- if (viewLineStart > homePos)
- homePos = viewLineStart;
-
- MovePositionTo(homePos, Selection::selStream);
- SetLastXChosen();
- }
- break;
- case SCI_LINEENDDISPLAY:
- MovePositionTo(MovePositionSoVisible(
- StartEndDisplayLine(sel.MainCaret(), false), 1));
- SetLastXChosen();
- break;
- case SCI_LINEENDDISPLAYEXTEND:
- MovePositionTo(MovePositionSoVisible(
- StartEndDisplayLine(sel.MainCaret(), false), 1), Selection::selStream);
- SetLastXChosen();
- break;
case SCI_SCROLLTOSTART:
ScrollTo(0);
break;
@@ -6194,7 +6394,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return pdoc->ExtendWordSelect(static_cast<int>(wParam), 1, lParam != 0);
case SCI_ISRANGEWORD:
- return pdoc->IsWordAt(static_cast<int>(wParam), lParam);
+ return pdoc->IsWordAt(static_cast<int>(wParam), static_cast<int>(lParam));
case SCI_SETWRAPMODE:
if (vs.SetWrapState(static_cast<int>(wParam))) {
diff --git a/scintilla/src/Editor.h b/scintilla/src/Editor.h index 909c82a..a83062f 100644 --- a/scintilla/src/Editor.h +++ b/scintilla/src/Editor.h @@ -326,6 +326,7 @@ protected: // ScintillaBase subclass needs access to much of Editor bool SelectionContainsProtected();
int MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd=true) const;
SelectionPosition MovePositionOutsideChar(SelectionPosition pos, int moveDir, bool checkLineEnd=true) const;
+ void MovedCaret(SelectionPosition newPos, SelectionPosition previousPos, bool ensureVisible);
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);
@@ -458,9 +459,15 @@ protected: // ScintillaBase subclass needs access to much of Editor void Duplicate(bool forLine);
virtual void CancelModes();
void NewLine();
+ SelectionPosition PositionUpOrDown(SelectionPosition spStart, int direction, int lastX);
void CursorUpOrDown(int direction, Selection::selTypes selt);
void ParaUpOrDown(int direction, Selection::selTypes selt);
int StartEndDisplayLine(int pos, bool start);
+ int VCHomeDisplayPosition(int position);
+ int VCHomeWrapPosition(int position);
+ int LineEndWrapPosition(int position);
+ int HorizontalMove(unsigned int iMessage);
+ int DelWordOrLine(unsigned int iMessage);
virtual int KeyCommand(unsigned int iMessage);
virtual int KeyDefault(int /* key */, int /*modifiers*/);
int KeyDownWithModifiers(int key, int modifiers, bool *consumed);
diff --git a/scintilla/src/ExternalLexer.cxx b/scintilla/src/ExternalLexer.cxx index 8ccb34f..75396a7 100644 --- a/scintilla/src/ExternalLexer.cxx +++ b/scintilla/src/ExternalLexer.cxx @@ -11,6 +11,7 @@ #include <assert.h>
#include <ctype.h>
+#include <stdexcept>
#include <string>
#include "Platform.h"
diff --git a/scintilla/src/Indicator.cxx b/scintilla/src/Indicator.cxx index ec5db53..6b012a9 100644 --- a/scintilla/src/Indicator.cxx +++ b/scintilla/src/Indicator.cxx @@ -5,6 +5,7 @@ // Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
+#include <stdexcept>
#include <vector>
#include <map>
diff --git a/scintilla/src/KeyMap.cxx b/scintilla/src/KeyMap.cxx index 60729d0..93a3a0a 100644 --- a/scintilla/src/KeyMap.cxx +++ b/scintilla/src/KeyMap.cxx @@ -7,6 +7,7 @@ #include <stdlib.h>
+#include <stdexcept>
#include <vector>
#include <map>
diff --git a/scintilla/src/LineMarker.cxx b/scintilla/src/LineMarker.cxx index f6a0490..4456664 100644 --- a/scintilla/src/LineMarker.cxx +++ b/scintilla/src/LineMarker.cxx @@ -8,6 +8,7 @@ #include <string.h>
#include <math.h>
+#include <stdexcept>
#include <vector>
#include <map>
diff --git a/scintilla/src/MarginView.cxx b/scintilla/src/MarginView.cxx index a6fc1f4..f164a7c 100644 --- a/scintilla/src/MarginView.cxx +++ b/scintilla/src/MarginView.cxx @@ -25,6 +25,7 @@ #include "Scintilla.h" #include "StringCopy.h" +#include "Position.h" #include "SplitVector.h" #include "Partitioning.h" #include "RunStyles.h" diff --git a/scintilla/src/PerLine.cxx b/scintilla/src/PerLine.cxx index 4e241f8..8cc3818 100644 --- a/scintilla/src/PerLine.cxx +++ b/scintilla/src/PerLine.cxx @@ -7,12 +7,14 @@ #include <string.h>
+#include <stdexcept>
#include <vector>
#include <algorithm>
#include "Platform.h"
#include "Scintilla.h"
+#include "Position.h"
#include "SplitVector.h"
#include "Partitioning.h"
#include "CellBuffer.h"
diff --git a/scintilla/src/Position.h b/scintilla/src/Position.h new file mode 100644 index 0000000..4ef6552 --- /dev/null +++ b/scintilla/src/Position.h @@ -0,0 +1,22 @@ +// Scintilla source code edit control +/** @file Position.h + ** Will define global type name Position in the Sci internal namespace. + **/ +// Copyright 2015 by Neil Hodgson <neilh@scintilla.org> +// The License.txt file describes the conditions under which this software may be distributed. + +#ifndef POSITION_H +#define POSITION_H + +namespace Sci { + +// After 3.6.0: +// typedef int Position; + +// A later version (4.x) of this file may: +//#if defined(SCI_LARGE_FILE_SUPPORT) +//typedef ptrdiff_t Position; + +} + +#endif diff --git a/scintilla/src/PositionCache.cxx b/scintilla/src/PositionCache.cxx index 930e898..c9cf637 100644 --- a/scintilla/src/PositionCache.cxx +++ b/scintilla/src/PositionCache.cxx @@ -21,6 +21,7 @@ #include "ILexer.h"
#include "Scintilla.h"
+#include "Position.h"
#include "SplitVector.h"
#include "Partitioning.h"
#include "RunStyles.h"
diff --git a/scintilla/src/RESearch.cxx b/scintilla/src/RESearch.cxx index 4c60f55..ecb9ec4 100644 --- a/scintilla/src/RESearch.cxx +++ b/scintilla/src/RESearch.cxx @@ -202,9 +202,11 @@ #include <stdlib.h>
+#include <stdexcept>
#include <string>
#include <algorithm>
+#include "Position.h"
#include "CharClassify.h"
#include "RESearch.h"
diff --git a/scintilla/src/RunStyles.cxx b/scintilla/src/RunStyles.cxx index 733cc0b..9b310a6 100644 --- a/scintilla/src/RunStyles.cxx +++ b/scintilla/src/RunStyles.cxx @@ -15,6 +15,7 @@ #include "Platform.h"
#include "Scintilla.h"
+#include "Position.h"
#include "SplitVector.h"
#include "Partitioning.h"
#include "RunStyles.h"
diff --git a/scintilla/src/ScintillaBase.cxx b/scintilla/src/ScintillaBase.cxx index 914b54d..092a24e 100644 --- a/scintilla/src/ScintillaBase.cxx +++ b/scintilla/src/ScintillaBase.cxx @@ -33,6 +33,7 @@ #include "Catalogue.h"
#endif
+#include "Position.h"
#include "SplitVector.h"
#include "Partitioning.h"
#include "RunStyles.h"
@@ -168,10 +169,10 @@ int ScintillaBase::KeyCommand(unsigned int iMessage) { EnsureCaretVisible();
return 0;
case SCI_TAB:
- AutoCompleteCompleted();
+ AutoCompleteCompleted(0, SC_AC_TAB);
return 0;
case SCI_NEWLINE:
- AutoCompleteCompleted();
+ AutoCompleteCompleted(0, SC_AC_NEWLINE);
return 0;
default:
@@ -202,7 +203,7 @@ int ScintillaBase::KeyCommand(unsigned int iMessage) { void ScintillaBase::AutoCompleteDoubleClick(void *p) {
ScintillaBase *sci = reinterpret_cast<ScintillaBase *>(p);
- sci->AutoCompleteCompleted();
+ sci->AutoCompleteCompleted(0, SC_AC_DOUBLECLICK);
}
void ScintillaBase::AutoCompleteInsert(Position startPos, int removeLen, const char *text, int textLen) {
@@ -340,7 +341,7 @@ void ScintillaBase::AutoCompleteMoveToCurrentWord() { void ScintillaBase::AutoCompleteCharacterAdded(char ch) {
if (ac.IsFillUpChar(ch)) {
- AutoCompleteCompleted();
+ AutoCompleteCompleted(ch, SC_AC_FILLUP);
} else if (ac.IsStopChar(ch)) {
AutoCompleteCancel();
} else {
@@ -363,7 +364,7 @@ void ScintillaBase::AutoCompleteCharacterDeleted() { NotifyParent(scn);
}
-void ScintillaBase::AutoCompleteCompleted() {
+void ScintillaBase::AutoCompleteCompleted(char ch, unsigned int completionMethod) {
int item = ac.GetSelection();
if (item == -1) {
AutoCompleteCancel();
@@ -376,6 +377,8 @@ void ScintillaBase::AutoCompleteCompleted() { SCNotification scn = {};
scn.nmhdr.code = listType > 0 ? SCN_USERLISTSELECTION : SCN_AUTOCSELECTION;
scn.message = 0;
+ scn.ch = ch;
+ scn.listCompletionMethod = completionMethod;
scn.wParam = listType;
scn.listType = listType;
Position firstPos = ac.posStart - ac.startLen;
@@ -398,6 +401,10 @@ void ScintillaBase::AutoCompleteCompleted() { return;
AutoCompleteInsert(firstPos, endPos - firstPos, selected.c_str(), static_cast<int>(selected.length()));
SetLastXChosen();
+
+ scn.nmhdr.code = SCN_AUTOCCOMPLETED;
+ NotifyParent(scn);
+
}
int ScintillaBase::AutoCompleteGetCurrent() const {
@@ -733,6 +740,7 @@ void LexState::FreeSubStyles() { void LexState::SetIdentifiers(int style, const char *identifiers) {
if (instance && (interfaceVersion >= lvSubStyles)) {
static_cast<ILexerWithSubStyles *>(instance)->SetIdentifiers(style, identifiers);
+ pdoc->ModifiedAt(0);
}
}
@@ -788,7 +796,7 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara return ac.posStart;
case SCI_AUTOCCOMPLETE:
- AutoCompleteCompleted();
+ AutoCompleteCompleted(0, SC_AC_COMMAND);
break;
case SCI_AUTOCSETSEPARATOR:
diff --git a/scintilla/src/ScintillaBase.h b/scintilla/src/ScintillaBase.h index 9cffce5..e2eb7f1 100644 --- a/scintilla/src/ScintillaBase.h +++ b/scintilla/src/ScintillaBase.h @@ -75,7 +75,7 @@ protected: int AutoCompleteGetCurrentText(char *buffer) const;
void AutoCompleteCharacterAdded(char ch);
void AutoCompleteCharacterDeleted();
- void AutoCompleteCompleted();
+ void AutoCompleteCompleted(char ch, unsigned int completionMethod);
void AutoCompleteMoveToCurrentWord();
static void AutoCompleteDoubleClick(void *p);
diff --git a/scintilla/src/Selection.cxx b/scintilla/src/Selection.cxx index 498c4c0..8133537 100644 --- a/scintilla/src/Selection.cxx +++ b/scintilla/src/Selection.cxx @@ -7,6 +7,7 @@ #include <stdlib.h>
+#include <stdexcept>
#include <vector>
#include <algorithm>
@@ -14,6 +15,7 @@ #include "Scintilla.h"
+#include "Position.h"
#include "Selection.h"
#ifdef SCI_NAMESPACE
@@ -311,6 +313,14 @@ void Selection::TrimSelection(SelectionRange range) { }
}
+void Selection::TrimOtherSelections(size_t r, SelectionRange range) {
+ for (size_t i = 0; i<ranges.size(); ++i) {
+ if (i != r) {
+ ranges[i].Trim(range);
+ }
+ }
+}
+
void Selection::SetSelection(SelectionRange range) {
ranges.clear();
ranges.push_back(range);
diff --git a/scintilla/src/Selection.h b/scintilla/src/Selection.h index 0e605bb..fc14408 100644 --- a/scintilla/src/Selection.h +++ b/scintilla/src/Selection.h @@ -168,6 +168,7 @@ public: int Length() const;
void MovePositions(bool insertion, int startChange, int length);
void TrimSelection(SelectionRange range);
+ void TrimOtherSelections(size_t r, SelectionRange range);
void SetSelection(SelectionRange range);
void AddSelection(SelectionRange range);
void AddSelectionWithoutTrim(SelectionRange range);
diff --git a/scintilla/src/SplitVector.h b/scintilla/src/SplitVector.h index 0fc27dd..cd75e35 100644 --- a/scintilla/src/SplitVector.h +++ b/scintilla/src/SplitVector.h @@ -85,6 +85,9 @@ public: /// copy exisiting contents to the new buffer.
/// Must not be used to decrease the size of the buffer.
void ReAllocate(int newSize) {
+ if (newSize < 0)
+ throw std::runtime_error("SplitVector::ReAllocate: negative size.");
+
if (newSize > size) {
// Move the gap to the end
GapTo(lengthBody);
diff --git a/scintilla/src/Style.cxx b/scintilla/src/Style.cxx index 467a26f..15192ca 100644 --- a/scintilla/src/Style.cxx +++ b/scintilla/src/Style.cxx @@ -7,6 +7,8 @@ #include <string.h>
+#include <stdexcept>
+
#include "Platform.h"
#include "Scintilla.h"
diff --git a/scintilla/src/Style.h b/scintilla/src/Style.h index a4be6d9..2fb378b 100644 --- a/scintilla/src/Style.h +++ b/scintilla/src/Style.h @@ -61,7 +61,7 @@ public: ColourDesired back;
bool eolFilled;
bool underline;
- enum ecaseForced {caseMixed, caseUpper, caseLower};
+ enum ecaseForced {caseMixed, caseUpper, caseLower, caseCamel};
ecaseForced caseForce;
bool visible;
bool changeable;
diff --git a/scintilla/src/UniConversion.cxx b/scintilla/src/UniConversion.cxx index 4421d1a..639ccbf 100644 --- a/scintilla/src/UniConversion.cxx +++ b/scintilla/src/UniConversion.cxx @@ -7,6 +7,8 @@ #include <stdlib.h>
+#include <stdexcept>
+
#include "UniConversion.h"
#ifdef SCI_NAMESPACE
diff --git a/scintilla/src/ViewStyle.cxx b/scintilla/src/ViewStyle.cxx index d815614..eff7a82 100644 --- a/scintilla/src/ViewStyle.cxx +++ b/scintilla/src/ViewStyle.cxx @@ -8,12 +8,14 @@ #include <string.h>
#include <assert.h>
+#include <stdexcept>
#include <vector>
#include <map>
#include "Platform.h"
#include "Scintilla.h"
+#include "Position.h"
#include "SplitVector.h"
#include "Partitioning.h"
#include "RunStyles.h"
diff --git a/scintilla/src/XPM.cxx b/scintilla/src/XPM.cxx index 3e3faf0..05fbc22 100644 --- a/scintilla/src/XPM.cxx +++ b/scintilla/src/XPM.cxx @@ -8,6 +8,7 @@ #include <stdlib.h>
#include <string.h>
+#include <stdexcept>
#include <vector>
#include <map>
|