aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--gtk/ScintillaGTK.cxx3
-rw-r--r--src/Editor.cxx30
-rw-r--r--src/Editor.h3
-rw-r--r--src/PositionCache.cxx4
-rw-r--r--src/PositionCache.h1
-rw-r--r--win32/ScintillaWin.cxx6
6 files changed, 29 insertions, 18 deletions
diff --git a/gtk/ScintillaGTK.cxx b/gtk/ScintillaGTK.cxx
index 801fc734a..8ec420e05 100644
--- a/gtk/ScintillaGTK.cxx
+++ b/gtk/ScintillaGTK.cxx
@@ -2495,8 +2495,7 @@ gboolean ScintillaGTK::DragMotionThis(GdkDragContext *context,
gint x, gint y, guint dragtime) {
try {
Point npt(x, y);
- SetDragPosition(SPositionFromLocation(npt, false, false,
- ((virtualSpaceOptions & SCVS_USERACCESSIBLE) != 0)));
+ SetDragPosition(SPositionFromLocation(npt, false, false, UserVirtualSpace()));
GdkDragAction preferredAction = context->suggested_action;
SelectionPosition pos = SPositionFromLocation(npt);
if ((inDragDrop == ddDragging) && (PositionInSelection(pos.Position()))) {
diff --git a/src/Editor.cxx b/src/Editor.cxx
index a2abba607..eeee752a8 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -473,7 +473,7 @@ SelectionPosition Editor::SPositionFromLocation(Point pt, bool canReturnInvalid,
i++;
}
if (virtualSpace) {
- const int spaceWidth = static_cast<int>(vs.spaceWidth);
+ const int spaceWidth = static_cast<int>(vs.styles[ll->EndLineStyle()].spaceWidth);
int spaceOffset = (pt.x + subLineStart - ll->positions[lineEnd] + spaceWidth / 2) /
spaceWidth;
return SelectionPosition(lineEnd + posLineStart, spaceOffset);
@@ -564,7 +564,7 @@ SelectionPosition Editor::SPositionFromLineX(int lineDoc, int x) {
}
i++;
}
- const int spaceWidth = static_cast<int>(vs.spaceWidth);
+ const int spaceWidth = static_cast<int>(vs.styles[ll->EndLineStyle()].spaceWidth);
int spaceOffset = (x + subLineStart - ll->positions[lineEnd] + spaceWidth / 2) / spaceWidth;
return SelectionPosition(lineEnd + posLineStart, spaceOffset);
}
@@ -2238,8 +2238,10 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin
PRectangle rcSegment = rcLine;
int virtualSpace = 0;
- if (subLine == (ll->lines - 1))
- virtualSpace = sel.VirtualSpaceFor(pdoc->LineEnd(line)) * vsDraw.spaceWidth;
+ if (subLine == (ll->lines - 1)) {
+ const int spaceWidth = static_cast<int>(vsDraw.styles[ll->EndLineStyle()].spaceWidth);
+ virtualSpace = sel.VirtualSpaceFor(pdoc->LineEnd(line)) * spaceWidth;
+ }
// Fill in a PRectangle representing the end of line characters
int xEol = ll->positions[lineEnd] - subLineStart;
@@ -2863,8 +2865,9 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
SelectionPosition spEnd;
if (sel.Range(r).Intersect(posLineStart, posLineStart + lineEnd, spStart, spEnd)) {
if (!(spStart == spEnd)) {
- rcSegment.left = xStart + ll->positions[spStart.Position() - posLineStart] - subLineStart + spStart.VirtualSpace() * vsDraw.spaceWidth;
- rcSegment.right = xStart + ll->positions[spEnd.Position() - posLineStart] - subLineStart + spEnd.VirtualSpace() * vsDraw.spaceWidth;
+ const int spaceWidth = static_cast<int>(vsDraw.styles[ll->EndLineStyle()].spaceWidth);
+ rcSegment.left = xStart + ll->positions[spStart.Position() - posLineStart] - subLineStart + spStart.VirtualSpace() * spaceWidth;
+ rcSegment.right = xStart + ll->positions[spEnd.Position() - posLineStart] - subLineStart + spEnd.VirtualSpace() * spaceWidth;
rcSegment.left = Platform::Maximum(rcSegment.left, rcLine.left);
rcSegment.right = Platform::Minimum(rcSegment.right, rcLine.right);
SimpleAlphaRectangle(surface, rcSegment, SelectionBackground(vsDraw),
@@ -3044,7 +3047,8 @@ void Editor::DrawCarets(Surface *surface, ViewStyle &vsDraw, int lineDoc, int xS
const bool mainCaret = r == sel.Main();
const SelectionPosition posCaret = (drawDrag ? posDrag : sel.Range(r).caret);
const int offset = posCaret.Position() - rangeLine.start;
- const int virtualOffset = posCaret.VirtualSpace() * vsDraw.spaceWidth;
+ const int spaceWidth = static_cast<int>(vsDraw.styles[ll->EndLineStyle()].spaceWidth);
+ const int virtualOffset = posCaret.VirtualSpace() * spaceWidth;
if (ll->InLine(offset, subLine) && offset <= ll->numCharsInLine) {
int xposCaret = ll->positions[offset] + virtualOffset - ll->positions[ll->LineStart(subLine)] + xStart;
if (ll->wrapIndent != 0) {
@@ -3777,10 +3781,12 @@ void Editor::PasteRectangular(SelectionPosition pos, const char *ptr, int len) {
}
sel.Clear();
sel.RangeMain() = SelectionRange(pos, pos);
- int xInsert = XFromPosition(sel.RangeMain().caret);
int line = pdoc->LineFromPosition(sel.MainCaret());
- bool prevCr = false;
pdoc->BeginUndoAction();
+ sel.RangeMain().caret = SelectionPosition(
+ InsertSpace(sel.RangeMain().caret.Position(), sel.RangeMain().caret.VirtualSpace()));
+ int xInsert = XFromPosition(sel.RangeMain().caret);
+ bool prevCr = false;
for (int i = 0; i < len; i++) {
if (IsEOLChar(ptr[i])) {
if ((ptr[i] == '\r') || (!prevCr))
@@ -4508,10 +4514,10 @@ void Editor::CursorUpOrDown(int direction, Selection::selTypes selt) {
int subLine = (pt.y - ptStartLine.y) / vs.lineHeight;
int commentLines = vs.annotationVisible ? pdoc->AnnotationLines(lineDoc) : 0;
SelectionPosition posNew = SPositionFromLocation(
- Point(lastXChosen, pt.y + direction * vs.lineHeight));
+ Point(lastXChosen, pt.y + direction * vs.lineHeight), false, false, UserVirtualSpace());
if ((direction > 0) && (subLine >= (cs.GetHeight(lineDoc) - 1 - commentLines))) {
posNew = SPositionFromLocation(
- Point(lastXChosen, pt.y + (commentLines + 1) * vs.lineHeight));
+ Point(lastXChosen, pt.y + (commentLines + 1) * vs.lineHeight), false, false, UserVirtualSpace());
}
if (direction < 0) {
// Line wrapping may lead to a location on the same line, so
@@ -5407,7 +5413,7 @@ void Editor::DropAt(SelectionPosition position, const char *value, bool moving,
position = positionAfterDeletion;
if (rectangular) {
- PasteRectangular(SelectionPosition(position), value, istrlen(value));
+ PasteRectangular(position, value, istrlen(value));
pdoc->EndUndoAction();
// Should try to select new rectangle but it may not be a rectangle now so just select the drop position
SetEmptySelection(position);
diff --git a/src/Editor.h b/src/Editor.h
index 687d963eb..051eb9329 100644
--- a/src/Editor.h
+++ b/src/Editor.h
@@ -276,6 +276,9 @@ protected: // ScintillaBase subclass needs access to much of Editor
PRectangle RectangleFromRange(int start, int end);
void InvalidateRange(int start, int end);
+ bool UserVirtualSpace() const {
+ return ((virtualSpaceOptions & SCVS_USERACCESSIBLE) != 0);
+ }
int CurrentPosition();
bool SelectionEmpty();
SelectionPosition SelectionStart();
diff --git a/src/PositionCache.cxx b/src/PositionCache.cxx
index 258a14860..b727ec465 100644
--- a/src/PositionCache.cxx
+++ b/src/PositionCache.cxx
@@ -197,6 +197,10 @@ int LineLayout::FindBefore(int x, int lower, int upper) const {
return lower;
}
+int LineLayout::EndLineStyle() const {
+ return styles[numCharsBeforeEOL > 0 ? numCharsBeforeEOL-1 : 0];
+}
+
LineLayoutCache::LineLayoutCache() :
level(0), length(0), size(0), cache(0),
allInvalidated(false), styleClock(-1), useCount(0) {
diff --git a/src/PositionCache.h b/src/PositionCache.h
index bd984d40b..a86881070 100644
--- a/src/PositionCache.h
+++ b/src/PositionCache.h
@@ -66,6 +66,7 @@ public:
char bracesMatchStyle, int xHighlight);
void RestoreBracesHighlight(Range rangeLine, Position braces[]);
int FindBefore(int x, int lower, int upper) const;
+ int EndLineStyle() const;
};
/**
diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx
index e24d32bde..76ccbeb40 100644
--- a/win32/ScintillaWin.cxx
+++ b/win32/ScintillaWin.cxx
@@ -2164,8 +2164,7 @@ STDMETHODIMP ScintillaWin::DragOver(DWORD grfKeyState, POINTL pt, PDWORD pdwEffe
// Update the cursor.
POINT rpt = {pt.x, pt.y};
::ScreenToClient(MainHWND(), &rpt);
- SetDragPosition(SPositionFromLocation(Point(rpt.x, rpt.y), false, false,
- ((virtualSpaceOptions & SCVS_USERACCESSIBLE) != 0)));
+ SetDragPosition(SPositionFromLocation(Point(rpt.x, rpt.y), false, false, UserVirtualSpace()));
return S_OK;
} catch (...) {
@@ -2250,8 +2249,7 @@ STDMETHODIMP ScintillaWin::Drop(LPDATAOBJECT pIDataSource, DWORD grfKeyState,
POINT rpt = {pt.x, pt.y};
::ScreenToClient(MainHWND(), &rpt);
- SelectionPosition movePos = SPositionFromLocation(Point(rpt.x, rpt.y), false, false,
- ((virtualSpaceOptions & SCVS_USERACCESSIBLE) != 0));
+ SelectionPosition movePos = SPositionFromLocation(Point(rpt.x, rpt.y), false, false, UserVirtualSpace());
DropAt(movePos, data, *pdwEffect == DROPEFFECT_MOVE, hrRectangular == S_OK);