aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2014-11-08 21:01:43 -0500
committermitchell <70453897+667e-11@users.noreply.github.com>2014-11-08 21:01:43 -0500
commit1d65d265c83a2ead67a3b59764b72c21a332eb33 (patch)
tree600556603e44dd571d7c6164a089a431aa0fed53 /src
parent851a720917c29c044d90fcdb42f57bd9fa1ed0be (diff)
downloadtextadept-1d65d265c83a2ead67a3b59764b72c21a332eb33.tar.gz
textadept-1d65d265c83a2ead67a3b59764b72c21a332eb33.zip
Patch Scintilla in order to allow custom wrap visuals; src/scintilla.patch
This is for drawing wrap markers as text in the terminal version. This patch is subject to change until Neil applies or modifies the upstream patch I sent.
Diffstat (limited to 'src')
-rw-r--r--src/scintilla.patch207
1 files changed, 156 insertions, 51 deletions
diff --git a/src/scintilla.patch b/src/scintilla.patch
index 56cd0644..a236f8fa 100644
--- a/src/scintilla.patch
+++ b/src/scintilla.patch
@@ -35,65 +35,105 @@ diff -r 326449de45d0 gtk/ScintillaGTK.cxx
std::string dest(data, len);
if (selectionTypeData == GDK_TARGET_STRING) {
if (IsUnicodeMode()) {
-diff -r 01c4696a39a9 src/Editor.cxx
---- a/src/Editor.cxx Tue Sep 30 09:58:13 2014 +1000
-+++ b/src/Editor.cxx Wed Oct 22 13:22:55 2014 -0400
-@@ -112,6 +112,7 @@
- mouseDownCaptures = true;
-
- lastClickTime = 0;
-+ clickCloseThreshold = 3;
- dwellDelay = SC_TIME_FOREVER;
- ticksToDwell = SC_TIME_FOREVER;
- dwelling = false;
-@@ -3757,10 +3758,10 @@
- EnsureCaretVisible();
- }
-
--static bool Close(Point pt1, Point pt2) {
-- if (abs(pt1.x - pt2.x) > 3)
-+static bool Close(Point pt1, Point pt2, int threshold) {
-+ if (abs(pt1.x - pt2.x) > threshold)
- return false;
-- if (abs(pt1.y - pt2.y) > 3)
-+ if (abs(pt1.y - pt2.y) > threshold)
- return false;
- return true;
- }
-@@ -4116,7 +4117,7 @@
- if (shift && !inSelMargin) {
- SetSelection(newPos);
- }
-- if (((curTime - lastClickTime) < Platform::DoubleClickTime()) && Close(pt, lastClick)) {
-+ if (((curTime - lastClickTime) < Platform::DoubleClickTime()) && Close(pt, lastClick, clickCloseThreshold)) {
- //Platform::DebugPrintf("Double click %d %d = %d\n", curTime, lastClickTime, curTime - lastClickTime);
- SetMouseCapture(true);
- if (FineTickerAvailable()) {
-diff -r 01c4696a39a9 src/Editor.h
---- a/src/Editor.h Tue Sep 30 09:58:13 2014 +1000
-+++ b/src/Editor.h Wed Oct 22 13:22:55 2014 -0400
-@@ -203,6 +203,7 @@
-
- Point lastClick;
- unsigned int lastClickTime;
-+ int clickCloseThreshold;
- int dwellDelay;
- int ticksToDwell;
- bool dwelling;
+diff -r 01c4696a39a9 src/Editor.cxx
+--- a/src/Editor.cxx Tue Sep 30 09:58:13 2014 +1000
++++ b/src/Editor.cxx Wed Oct 22 13:22:55 2014 -0400
+@@ -112,6 +112,7 @@
+ mouseDownCaptures = true;
+
+ lastClickTime = 0;
++ clickCloseThreshold = 3;
+ dwellDelay = SC_TIME_FOREVER;
+ ticksToDwell = SC_TIME_FOREVER;
+ dwelling = false;
+@@ -3757,10 +3758,10 @@
+ EnsureCaretVisible();
+ }
+
+-static bool Close(Point pt1, Point pt2) {
+- if (abs(pt1.x - pt2.x) > 3)
++static bool Close(Point pt1, Point pt2, int threshold) {
++ if (abs(pt1.x - pt2.x) > threshold)
+ return false;
+- if (abs(pt1.y - pt2.y) > 3)
++ if (abs(pt1.y - pt2.y) > threshold)
+ return false;
+ return true;
+ }
+@@ -4116,7 +4117,7 @@
+ if (shift && !inSelMargin) {
+ SetSelection(newPos);
+ }
+- if (((curTime - lastClickTime) < Platform::DoubleClickTime()) && Close(pt, lastClick)) {
++ if (((curTime - lastClickTime) < Platform::DoubleClickTime()) && Close(pt, lastClick, clickCloseThreshold)) {
+ //Platform::DebugPrintf("Double click %d %d = %d\n", curTime, lastClickTime, curTime - lastClickTime);
+ SetMouseCapture(true);
+ if (FineTickerAvailable()) {
+diff -r 01c4696a39a9 src/Editor.h
+--- a/src/Editor.h Tue Sep 30 09:58:13 2014 +1000
++++ b/src/Editor.h Wed Oct 22 13:22:55 2014 -0400
+@@ -203,6 +203,7 @@
+
+ Point lastClick;
+ unsigned int lastClickTime;
++ int clickCloseThreshold;
+ int dwellDelay;
+ int ticksToDwell;
+ bool dwelling;
diff -r 326449de45d0 src/EditView.cxx
--- a/src/EditView.cxx Thu Sep 25 09:48:50 2014 +1000
-+++ b/src/EditView.cxx Fri Nov 07 22:12:15 2014 -0500
-@@ -185,6 +185,7 @@
++++ b/src/EditView.cxx Sat Nov 08 21:00:02 2014 -0500
+@@ -185,6 +185,9 @@
pixmapIndentGuideHighlight = 0;
llc.SetLevel(LineLayoutCache::llcCaret);
posCache.SetSize(0x400);
++ tabArrowPaddingTop = 4;
+ customDrawTabArrow = NULL;
++ customDrawWrapMarker = NULL;
}
EditView::~EditView() {
-@@ -1465,7 +1466,10 @@
+@@ -927,7 +930,11 @@
+ rcPlace.right = rcLine.right;
+ rcPlace.left = rcPlace.right - vsDraw.aveCharWidth;
+ }
+- DrawWrapMarker(surface, rcPlace, true, vsDraw.WrapColour());
++ if (customDrawWrapMarker == NULL) {
++ DrawWrapMarker(surface, rcPlace, true, vsDraw.WrapColour());
++ } else {
++ customDrawWrapMarker(surface, rcPlace, true, vsDraw.WrapColour());
++ }
+ }
+ }
+
+@@ -1201,7 +1208,7 @@
+ }
+
+ static void DrawWrapIndentAndMarker(Surface *surface, const ViewStyle &vsDraw, const LineLayout *ll,
+- int xStart, PRectangle rcLine, ColourOptional background) {
++ int xStart, PRectangle rcLine, ColourOptional background, DrawWrapMarkerFn customDrawWrapMarker) {
+ // default bgnd here..
+ surface->FillRectangle(rcLine, background.isSet ? background :
+ vsDraw.styles[STYLE_DEFAULT].back);
+@@ -1219,7 +1226,11 @@
+ else
+ rcPlace.right = rcPlace.left + vsDraw.aveCharWidth;
+
+- DrawWrapMarker(surface, rcPlace, false, vsDraw.WrapColour());
++ if (customDrawWrapMarker == NULL) {
++ DrawWrapMarker(surface, rcPlace, false, vsDraw.WrapColour());
++ } else {
++ customDrawWrapMarker(surface, rcPlace, false, vsDraw.WrapColour());
++ }
+ }
+ }
+
+@@ -1463,9 +1474,12 @@
+ if (vsDraw.whitespaceColours.fore.isSet)
+ textFore = vsDraw.whitespaceColours.fore;
surface->PenColour(textFore);
- PRectangle rcTab(rcSegment.left + 1, rcSegment.top + 4,
+- PRectangle rcTab(rcSegment.left + 1, rcSegment.top + 4,
++ PRectangle rcTab(rcSegment.left + 1, rcSegment.top + tabArrowPaddingTop,
rcSegment.right - 1, rcSegment.bottom - vsDraw.maxDescent);
- DrawTabArrow(surface, rcTab, static_cast<int>(rcSegment.top + vsDraw.lineHeight / 2));
+ if (customDrawTabArrow == NULL)
@@ -103,9 +143,18 @@ diff -r 326449de45d0 src/EditView.cxx
}
}
} else {
+@@ -1632,7 +1646,7 @@
+
+ if ((ll->wrapIndent != 0) && (subLine > 0)) {
+ if (phase & drawBack) {
+- DrawWrapIndentAndMarker(surface, vsDraw, ll, xStart, rcLine, background);
++ DrawWrapIndentAndMarker(surface, vsDraw, ll, xStart, rcLine, background, customDrawWrapMarker);
+ }
+ xStart += static_cast<int>(ll->wrapIndent);
+ }
diff -r 326449de45d0 src/EditView.h
--- a/src/EditView.h Thu Sep 25 09:48:50 2014 +1000
-+++ b/src/EditView.h Fri Nov 07 22:12:15 2014 -0500
++++ b/src/EditView.h Sat Nov 08 21:00:02 2014 -0500
@@ -42,6 +42,8 @@
void DrawStyledText(Surface *surface, const ViewStyle &vs, int styleOffset, PRectangle rcText,
const StyledText &st, size_t start, size_t length, DrawPhase phase);
@@ -115,16 +164,72 @@ diff -r 326449de45d0 src/EditView.h
/**
* EditView draws the main text area.
*/
-@@ -78,6 +80,12 @@
+@@ -78,6 +80,14 @@
LineLayoutCache llc;
PositionCache posCache;
++ int tabArrowPaddingTop; // draw arrows this many pixels below line top
+ /** Some platforms, notably PLAT_CURSES, do not support Scintilla's native
+ * DrawTabArrow function for drawing tab characters. Allow those platforms to
+ * override it instead of creating a new method in the Surface class that
+ * existing platforms must implement as empty. */
+ DrawTabArrowFn customDrawTabArrow;
++ DrawWrapMarkerFn customDrawWrapMarker;
+
EditView();
virtual ~EditView();
+diff -r 326449de45d0 src/MarginView.cxx
+--- a/src/MarginView.cxx Thu Sep 25 09:48:50 2014 +1000
++++ b/src/MarginView.cxx Sat Nov 08 21:00:02 2014 -0500
+@@ -102,6 +102,8 @@
+ pixmapSelMargin = 0;
+ pixmapSelPattern = 0;
+ pixmapSelPatternOffset1 = 0;
++ wrapMarkerPaddingRight = 3;
++ customDrawWrapMarker = NULL;
+ }
+
+ void MarginView::DropGraphics(bool freeObjects) {
+@@ -391,9 +393,13 @@
+ rcNumber.top + vs.maxAscent, number, static_cast<int>(strlen(number)), drawAll);
+ } else if (vs.wrapVisualFlags & SC_WRAPVISUALFLAG_MARGIN) {
+ PRectangle rcWrapMarker = rcMarker;
+- rcWrapMarker.right -= 3;
++ rcWrapMarker.right -= wrapMarkerPaddingRight;
+ rcWrapMarker.left = rcWrapMarker.right - vs.styles[STYLE_LINENUMBER].aveCharWidth;
+- DrawWrapMarker(surface, rcWrapMarker, false, vs.styles[STYLE_LINENUMBER].fore);
++ if (customDrawWrapMarker == NULL) {
++ DrawWrapMarker(surface, rcWrapMarker, false, vs.styles[STYLE_LINENUMBER].fore);
++ } else {
++ customDrawWrapMarker(surface, rcWrapMarker, false, vs.styles[STYLE_LINENUMBER].fore);
++ }
+ }
+ } else if (vs.ms[margin].style == SC_MARGIN_TEXT || vs.ms[margin].style == SC_MARGIN_RTEXT) {
+ if (firstSubLine) {
+diff -r 326449de45d0 src/MarginView.h
+--- a/src/MarginView.h Thu Sep 25 09:48:50 2014 +1000
++++ b/src/MarginView.h Sat Nov 08 21:00:02 2014 -0500
+@@ -14,6 +14,8 @@
+
+ void DrawWrapMarker(Surface *surface, PRectangle rcPlace, bool isEndMarker, ColourDesired wrapColour);
+
++typedef void (*DrawWrapMarkerFn)(Surface *, PRectangle, bool, ColourDesired);
++
+ /**
+ * MarginView draws the margins.
+ */
+@@ -25,6 +27,13 @@
+ // Highlight current folding block
+ HighlightDelimiter highlightDelimiter;
+
++ int wrapMarkerPaddingRight; // right-most pixel padding of wrap markers
++ /** Some platforms, notably PLAT_CURSES, do not support Scintilla's native
++ * DrawWrapMarker function for drawing wrap markers. Allow those platforms to
++ * override it instead of creating a new method in the Surface class that
++ * existing platforms must implement as empty. */
++ DrawWrapMarkerFn customDrawWrapMarker;
++
+ MarginView();
+
+ void DropGraphics(bool freeObjects);