diff options
-rw-r--r-- | scintilla/src/Editor.cxx | 58 | ||||
-rw-r--r-- | scintilla/src/Editor.h | 8 | ||||
-rw-r--r-- | scintilla/src/ViewStyle.cxx | 2 | ||||
-rw-r--r-- | scintilla/src/ViewStyle.h | 1 |
4 files changed, 40 insertions, 29 deletions
diff --git a/scintilla/src/Editor.cxx b/scintilla/src/Editor.cxx index d13217a..53758cd 100644 --- a/scintilla/src/Editor.cxx +++ b/scintilla/src/Editor.cxx @@ -1030,6 +1030,12 @@ void Editor::VerticalCentreCaret() { }
}
+// Avoid 64 bit compiler warnings.
+// Scintilla does not support text buffers larger than 2**31
+static int istrlen(const char *s) {
+ return static_cast<int>(strlen(s));
+}
+
void Editor::MoveSelectedLines(int lineDelta) {
// if selection doesn't start at the beginning of the line, set the new start
@@ -1043,9 +1049,11 @@ void Editor::MoveSelectedLines(int lineDelta) { int selectionEnd = SelectionEnd().Position();
int endLine = pdoc->LineFromPosition(selectionEnd);
int beginningOfEndLine = pdoc->LineStart(endLine);
+ bool appendEol = false;
if (selectionEnd > beginningOfEndLine
|| selectionStart == selectionEnd) {
selectionEnd = pdoc->LineStart(endLine + 1);
+ appendEol = (selectionEnd == pdoc->Length() && pdoc->LineFromPosition(selectionEnd) == endLine);
}
// if there's nowhere for the selection to move
@@ -1059,19 +1067,34 @@ void Editor::MoveSelectedLines(int lineDelta) { UndoGroup ug(pdoc);
+ if (lineDelta > 0 && selectionEnd == pdoc->LineStart(pdoc->LinesTotal() - 1)) {
+ SetSelection(pdoc->MovePositionOutsideChar(selectionEnd - 1, -1), selectionEnd);
+ ClearSelection();
+ selectionEnd = CurrentPosition();
+ }
SetSelection(selectionStart, selectionEnd);
SelectionText selectedText;
CopySelectionRange(&selectedText);
int selectionLength = SelectionRange(selectionStart, selectionEnd).Length();
- ClearSelection();
-
Point currentLocation = LocationFromPosition(CurrentPosition());
int currentLine = LineFromLocation(currentLocation);
+
+ if (appendEol)
+ SetSelection(pdoc->MovePositionOutsideChar(selectionStart - 1, -1), selectionEnd);
+ ClearSelection();
+
+ const char *eol = StringFromEOLMode(pdoc->eolMode);
+ if (currentLine + lineDelta >= pdoc->LinesTotal())
+ pdoc->InsertCString(pdoc->Length(), eol);
GoToLine(currentLine + lineDelta);
pdoc->InsertCString(CurrentPosition(), selectedText.s);
+ if (appendEol) {
+ pdoc->InsertCString(CurrentPosition() + selectionLength, eol);
+ selectionLength += istrlen(eol);
+ }
SetSelection(CurrentPosition(), CurrentPosition() + selectionLength);
}
@@ -1636,12 +1659,6 @@ int Editor::SubstituteMarkerIfEmpty(int markerCheck, int markerDefault) { return markerCheck;
}
-// Avoid 64 bit compiler warnings.
-// Scintilla does not support text buffers larger than 2**31
-static int istrlen(const char *s) {
- return static_cast<int>(strlen(s));
-}
-
bool ValidStyledText(ViewStyle &vs, size_t styleOffset, const StyledText &st) {
if (st.multipleStyles) {
for (size_t iStyle=0; iStyle<st.length; iStyle++) {
@@ -2308,17 +2325,6 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou width = 20;
}
if ((ll->validity == LineLayout::llPositions) || (ll->widthLine != width)) {
- XYPOSITION wrapAddIndent = 0; // This will be added to initial indent of line
- if (wrapIndentMode == SC_WRAPINDENT_INDENT) {
- wrapAddIndent = pdoc->IndentSize() * vstyle.spaceWidth;
- } else if (wrapIndentMode == SC_WRAPINDENT_SAME) {
- wrapAddIndent = 0;
- } else { //SC_WRAPINDENT_FIXED
- wrapAddIndent = wrapVisualStartIndent * vstyle.aveCharWidth;
- if ((wrapVisualFlags & SC_WRAPVISUALFLAG_START) && (wrapAddIndent <= 0))
- wrapAddIndent = vstyle.aveCharWidth; // must indent to show start visual
- }
-
ll->widthLine = width;
if (width == LineLayout::wrapWidthInfinite) {
ll->lines = 1;
@@ -2329,6 +2335,12 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou if (wrapVisualFlags & SC_WRAPVISUALFLAG_END) {
width -= static_cast<int>(vstyle.aveCharWidth); // take into account the space for end wrap mark
}
+ XYPOSITION wrapAddIndent = 0; // This will be added to initial indent of line
+ if (wrapIndentMode == SC_WRAPINDENT_INDENT) {
+ wrapAddIndent = pdoc->IndentSize() * vstyle.spaceWidth;
+ } else if (wrapIndentMode == SC_WRAPINDENT_FIXED) {
+ wrapAddIndent = wrapVisualStartIndent * vstyle.aveCharWidth;
+ }
ll->wrapIndent = wrapAddIndent;
if (wrapIndentMode != SC_WRAPINDENT_FIXED)
for (int i = 0; i < ll->numCharsInLine; i++) {
@@ -3738,10 +3750,10 @@ long Editor::FormatRange(bool draw, Sci_RangeToFormat *pfr) { if (!pfr)
return 0;
- AutoSurface surface(pfr->hdc, this);
+ AutoSurface surface(pfr->hdc, this, SC_TECHNOLOGY_DEFAULT);
if (!surface)
return 0;
- AutoSurface surfaceMeasure(pfr->hdcTarget, this);
+ AutoSurface surfaceMeasure(pfr->hdcTarget, this, SC_TECHNOLOGY_DEFAULT);
if (!surfaceMeasure) {
return 0;
}
@@ -3750,6 +3762,7 @@ long Editor::FormatRange(bool draw, Sci_RangeToFormat *pfr) { posCache.Clear();
ViewStyle vsPrint(vs);
+ vsPrint.technology = SC_TECHNOLOGY_DEFAULT;
// Modify the view style for printing as do not normally want any of the transient features to be printed
// Printing supports only the line number margin.
@@ -3761,9 +3774,10 @@ long Editor::FormatRange(bool draw, Sci_RangeToFormat *pfr) { vsPrint.ms[margin].width = 0;
}
}
- vsPrint.showMarkedLines = false;
vsPrint.fixedColumnWidth = 0;
vsPrint.zoomLevel = printMagnification;
+ // Don't show indentation guides
+ // If this ever gets changed, cached pixmap would need to be recreated if technology != SC_TECHNOLOGY_DEFAULT
vsPrint.viewIndentationGuides = ivNone;
// Don't show the selection when printing
vsPrint.selbackset = false;
diff --git a/scintilla/src/Editor.h b/scintilla/src/Editor.h index 226dd7c..6ed446e 100644 --- a/scintilla/src/Editor.h +++ b/scintilla/src/Editor.h @@ -572,9 +572,9 @@ class AutoSurface { private:
Surface *surf;
public:
- AutoSurface(Editor *ed) : surf(0) {
+ AutoSurface(Editor *ed, int technology = -1) : surf(0) {
if (ed->wMain.GetID()) {
- surf = Surface::Allocate(ed->technology);
+ surf = Surface::Allocate(technology != -1 ? technology : ed->technology);
if (surf) {
surf->Init(ed->wMain.GetID());
surf->SetUnicodeMode(SC_CP_UTF8 == ed->CodePage());
@@ -582,9 +582,9 @@ public: }
}
}
- AutoSurface(SurfaceID sid, Editor *ed) : surf(0) {
+ AutoSurface(SurfaceID sid, Editor *ed, int technology = -1) : surf(0) {
if (ed->wMain.GetID()) {
- surf = Surface::Allocate(ed->technology);
+ surf = Surface::Allocate(technology != -1 ? technology : ed->technology);
if (surf) {
surf->Init(sid, ed->wMain.GetID());
surf->SetUnicodeMode(SC_CP_UTF8 == ed->CodePage());
diff --git a/scintilla/src/ViewStyle.cxx b/scintilla/src/ViewStyle.cxx index 53828f2..2f51723 100644 --- a/scintilla/src/ViewStyle.cxx +++ b/scintilla/src/ViewStyle.cxx @@ -200,7 +200,6 @@ ViewStyle::ViewStyle(const ViewStyle &source) { whitespaceSize = source.whitespaceSize;
viewIndentationGuides = source.viewIndentationGuides;
viewEOL = source.viewEOL;
- showMarkedLines = source.showMarkedLines;
extraFontFlag = source.extraFontFlag;
extraAscent = source.extraAscent;
extraDescent = source.extraDescent;
@@ -314,7 +313,6 @@ void ViewStyle::Init(size_t stylesSize_) { whitespaceSize = 1;
viewIndentationGuides = ivNone;
viewEOL = false;
- showMarkedLines = true;
extraFontFlag = 0;
extraAscent = 0;
extraDescent = 0;
diff --git a/scintilla/src/ViewStyle.h b/scintilla/src/ViewStyle.h index 2087b81..994bdea 100644 --- a/scintilla/src/ViewStyle.h +++ b/scintilla/src/ViewStyle.h @@ -112,7 +112,6 @@ public: int whitespaceSize;
IndentView viewIndentationGuides;
bool viewEOL;
- bool showMarkedLines;
ColourDesired caretcolour;
ColourDesired additionalCaretColour;
bool showCaretLineBackground;
|