Update Scintilla to version 3.7.2

This commit is contained in:
Colomban Wendling 2016-12-30 18:29:43 +01:00
parent 16ea1d35a6
commit c914598dba
6 changed files with 67 additions and 41 deletions

View File

@ -650,7 +650,7 @@ Range EditView::RangeDisplayLine(Surface *surface, const EditModel &model, int l
return rangeSubLine;
}
SelectionPosition EditView::SPositionFromLocation(Surface *surface, const EditModel &model, Point pt, bool canReturnInvalid, bool charPosition, bool virtualSpace, const ViewStyle &vs) {
SelectionPosition EditView::SPositionFromLocation(Surface *surface, const EditModel &model, PointDocument pt, bool canReturnInvalid, bool charPosition, bool virtualSpace, const ViewStyle &vs) {
pt.x = pt.x - vs.textStart;
int visibleLine = static_cast<int>(floor(pt.y / vs.lineHeight));
if (!canReturnInvalid && (visibleLine < 0))
@ -671,7 +671,8 @@ SelectionPosition EditView::SPositionFromLocation(Surface *surface, const EditMo
const XYPOSITION subLineStart = ll->positions[rangeSubLine.start];
if (subLine > 0) // Wrapped
pt.x -= ll->wrapIndent;
const int positionInLine = ll->FindPositionFromX(pt.x + subLineStart, rangeSubLine, charPosition);
const int positionInLine = ll->FindPositionFromX(static_cast<XYPOSITION>(pt.x + subLineStart),
rangeSubLine, charPosition);
if (positionInLine < rangeSubLine.end) {
return SelectionPosition(model.pdoc->MovePositionOutsideChar(positionInLine + posLineStart, 1));
}

View File

@ -114,7 +114,7 @@ public:
Point LocationFromPosition(Surface *surface, const EditModel &model, SelectionPosition pos, int topLine,
const ViewStyle &vs, PointEnd pe);
Range RangeDisplayLine(Surface *surface, const EditModel &model, int lineVisible, const ViewStyle &vs);
SelectionPosition SPositionFromLocation(Surface *surface, const EditModel &model, Point pt, bool canReturnInvalid,
SelectionPosition SPositionFromLocation(Surface *surface, const EditModel &model, PointDocument pt, bool canReturnInvalid,
bool charPosition, bool virtualSpace, const ViewStyle &vs);
SelectionPosition SPositionFromLineX(Surface *surface, const EditModel &model, int lineDoc, int x, const ViewStyle &vs);
int DisplayFromPosition(Surface *surface, const EditModel &model, int pos, const ViewStyle &vs);

View File

@ -283,8 +283,8 @@ Point Editor::GetVisibleOriginInMain() const {
return Point(0,0);
}
Point Editor::DocumentPointFromView(Point ptView) const {
Point ptDocument = ptView;
PointDocument Editor::DocumentPointFromView(Point ptView) const {
PointDocument ptDocument(ptView);
if (wMargin.GetID()) {
Point ptOrigin = GetVisibleOriginInMain();
ptDocument.x += ptOrigin.x;
@ -399,8 +399,8 @@ SelectionPosition Editor::SPositionFromLocation(Point pt, bool canReturnInvalid,
if (pt.y < 0)
return SelectionPosition(INVALID_POSITION);
}
pt = DocumentPointFromView(pt);
return view.SPositionFromLocation(surface, *this, pt, canReturnInvalid, charPosition, virtualSpace, vs);
PointDocument ptdoc = DocumentPointFromView(pt);
return view.SPositionFromLocation(surface, *this, ptdoc, canReturnInvalid, charPosition, virtualSpace, vs);
}
int Editor::PositionFromLocation(Point pt, bool canReturnInvalid, bool charPosition) {
@ -5694,6 +5694,39 @@ sptr_t Editor::StyleGetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lPar
return 0;
}
void Editor::SetSelectionNMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
InvalidateRange(sel.Range(wParam).Start().Position(), sel.Range(wParam).End().Position());
switch (iMessage) {
case SCI_SETSELECTIONNCARET:
sel.Range(wParam).caret.SetPosition(static_cast<int>(lParam));
break;
case SCI_SETSELECTIONNANCHOR:
sel.Range(wParam).anchor.SetPosition(static_cast<int>(lParam));
break;
case SCI_SETSELECTIONNCARETVIRTUALSPACE:
sel.Range(wParam).caret.SetVirtualSpace(static_cast<int>(lParam));
break;
case SCI_SETSELECTIONNANCHORVIRTUALSPACE:
sel.Range(wParam).anchor.SetVirtualSpace(static_cast<int>(lParam));
break;
case SCI_SETSELECTIONNSTART:
sel.Range(wParam).anchor.SetPosition(static_cast<int>(lParam));
break;
case SCI_SETSELECTIONNEND:
sel.Range(wParam).caret.SetPosition(static_cast<int>(lParam));
break;
}
InvalidateRange(sel.Range(wParam).Start().Position(), sel.Range(wParam).End().Position());
ContainerNeedsUpdate(SC_UPDATE_SELECTION);
}
sptr_t Editor::StringResult(sptr_t lParam, const char *val) {
const size_t len = val ? strlen(val) : 0;
if (lParam) {
@ -7967,55 +8000,29 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return sel.Main();
case SCI_SETSELECTIONNCARET:
sel.Range(wParam).caret.SetPosition(static_cast<int>(lParam));
ContainerNeedsUpdate(SC_UPDATE_SELECTION);
Redraw();
case SCI_SETSELECTIONNANCHOR:
case SCI_SETSELECTIONNCARETVIRTUALSPACE:
case SCI_SETSELECTIONNANCHORVIRTUALSPACE:
case SCI_SETSELECTIONNSTART:
case SCI_SETSELECTIONNEND:
SetSelectionNMessage(iMessage, wParam, lParam);
break;
case SCI_GETSELECTIONNCARET:
return sel.Range(wParam).caret.Position();
case SCI_SETSELECTIONNANCHOR:
sel.Range(wParam).anchor.SetPosition(static_cast<int>(lParam));
ContainerNeedsUpdate(SC_UPDATE_SELECTION);
Redraw();
break;
case SCI_GETSELECTIONNANCHOR:
return sel.Range(wParam).anchor.Position();
case SCI_SETSELECTIONNCARETVIRTUALSPACE:
sel.Range(wParam).caret.SetVirtualSpace(static_cast<int>(lParam));
ContainerNeedsUpdate(SC_UPDATE_SELECTION);
Redraw();
break;
case SCI_GETSELECTIONNCARETVIRTUALSPACE:
return sel.Range(wParam).caret.VirtualSpace();
case SCI_SETSELECTIONNANCHORVIRTUALSPACE:
sel.Range(wParam).anchor.SetVirtualSpace(static_cast<int>(lParam));
ContainerNeedsUpdate(SC_UPDATE_SELECTION);
Redraw();
break;
case SCI_GETSELECTIONNANCHORVIRTUALSPACE:
return sel.Range(wParam).anchor.VirtualSpace();
case SCI_SETSELECTIONNSTART:
sel.Range(wParam).anchor.SetPosition(static_cast<int>(lParam));
ContainerNeedsUpdate(SC_UPDATE_SELECTION);
Redraw();
break;
case SCI_GETSELECTIONNSTART:
return sel.Range(wParam).Start().Position();
case SCI_SETSELECTIONNEND:
sel.Range(wParam).caret.SetPosition(static_cast<int>(lParam));
ContainerNeedsUpdate(SC_UPDATE_SELECTION);
Redraw();
break;
case SCI_GETSELECTIONNEND:
return sel.Range(wParam).End().Position();

View File

@ -275,7 +275,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
// The top left visible point in main window coordinates. Will be 0,0 except for
// scroll views where it will be equivalent to the current scroll position.
virtual Point GetVisibleOriginInMain() const;
Point DocumentPointFromView(Point ptView) const; // Convert a point from view space to document
PointDocument DocumentPointFromView(Point ptView) const; // Convert a point from view space to document
int TopLineOfMain() const; // Return the line at Main's y coordinate 0
virtual PRectangle GetClientRectangle() const;
virtual PRectangle GetClientDrawingRectangle();
@ -577,6 +577,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
bool ValidMargin(uptr_t wParam) const;
void StyleSetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
sptr_t StyleGetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
void SetSelectionNMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
static const char *StringFromEOLMode(int eolMode);

View File

@ -16,6 +16,23 @@ static inline bool IsEOLChar(char ch) {
return (ch == '\r') || (ch == '\n');
}
/**
* A point in document space.
* Uses double for sufficient resolution in large (>20,000,000 line) documents.
*/
class PointDocument {
public:
double x;
double y;
explicit PointDocument(double x_ = 0, double y_ = 0) : x(x_), y(y_) {
}
// Conversion from Point.
explicit PointDocument(Point pt) : x(pt.x), y(pt.y) {
}
};
// There are two points for some positions and this enumeration
// can choose between the end of the first line or subline
// and the start of the next line or subline.

View File

@ -1 +1 @@
371
372