diff options
author | Neil <nyamatongwe@gmail.com> | 2014-11-19 13:48:37 +1100 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2014-11-19 13:48:37 +1100 |
commit | c1ce889ce992cf7006120c01c336fc51b44de9d1 (patch) | |
tree | 2995c377e0b35b1d389bd3c8875824dd65104650 | |
parent | 5007acf288a92f58c3d4a039a69b9baf50bed08b (diff) | |
download | scintilla-mirror-c1ce889ce992cf7006120c01c336fc51b44de9d1.tar.gz |
Platform overrides for some drawing and behaviour to benefit PLAT_CURSES.
From Mitchell Foral.
-rw-r--r-- | doc/ScintillaHistory.html | 5 | ||||
-rw-r--r-- | src/EditView.cxx | 26 | ||||
-rw-r--r-- | src/EditView.h | 10 | ||||
-rw-r--r-- | src/Editor.cxx | 9 | ||||
-rw-r--r-- | src/Editor.h | 1 | ||||
-rw-r--r-- | src/LineMarker.cxx | 5 | ||||
-rw-r--r-- | src/LineMarker.h | 10 | ||||
-rw-r--r-- | src/MarginView.cxx | 10 | ||||
-rw-r--r-- | src/MarginView.h | 9 |
9 files changed, 73 insertions, 12 deletions
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index d1e449fc0..ddd3c78a6 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -500,6 +500,11 @@ but does not show a border. </li> <li> + Allow platform overrides for drawing tab arrows, wrap markers, and line markers. + Variable for size of double click detection area. + These enable better visuals and behaviour for PLAT_CURSES as it is character cell based. + </li> + <li> VHDL folder fixes "block" keyword. <a href="http://sourceforge.net/p/scintilla/bugs/1664/">Bug #1664</a>. </li> diff --git a/src/EditView.cxx b/src/EditView.cxx index 845d38dc5..4976d3614 100644 --- a/src/EditView.cxx +++ b/src/EditView.cxx @@ -186,6 +186,9 @@ EditView::EditView() { pixmapIndentGuideHighlight = 0; llc.SetLevel(LineLayoutCache::llcCaret); posCache.SetSize(0x400); + tabArrowHeight = 4; + customDrawTabArrow = NULL; + customDrawWrapMarker = NULL; } EditView::~EditView() { @@ -928,7 +931,11 @@ void EditView::DrawEOL(Surface *surface, const EditModel &model, const ViewStyle 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()); + } } } @@ -1204,7 +1211,7 @@ void EditView::DrawCarets(Surface *surface, const EditModel &model, const ViewSt } 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); @@ -1222,7 +1229,11 @@ static void DrawWrapIndentAndMarker(Surface *surface, const ViewStyle &vsDraw, c 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()); + } } } @@ -1466,9 +1477,12 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi 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 + tabArrowHeight, rcSegment.right - 1, rcSegment.bottom - vsDraw.maxDescent); - DrawTabArrow(surface, rcTab, static_cast<int>(rcSegment.top + vsDraw.lineHeight / 2)); + if (customDrawTabArrow == NULL) + DrawTabArrow(surface, rcTab, static_cast<int>(rcSegment.top + vsDraw.lineHeight / 2)); + else + customDrawTabArrow(surface, rcTab, static_cast<int>(rcSegment.top + vsDraw.lineHeight / 2)); } } } else { @@ -1635,7 +1649,7 @@ void EditView::DrawLine(Surface *surface, const EditModel &model, const ViewStyl 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 --git a/src/EditView.h b/src/EditView.h index 733612e8e..70af6b2bf 100644 --- a/src/EditView.h +++ b/src/EditView.h @@ -42,6 +42,8 @@ void DrawTextNoClipPhase(Surface *surface, PRectangle rc, const Style &style, XY void DrawStyledText(Surface *surface, const ViewStyle &vs, int styleOffset, PRectangle rcText, const StyledText &st, size_t start, size_t length, DrawPhase phase); +typedef void (*DrawTabArrowFn)(Surface *surface, PRectangle rcTab, int ymid); + /** * EditView draws the main text area. */ @@ -78,6 +80,14 @@ public: LineLayoutCache llc; PositionCache posCache; + int tabArrowHeight; // draw arrow heads this many pixels above/below line midpoint + /** 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 --git a/src/Editor.cxx b/src/Editor.cxx index bd15ac74e..64017c58d 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -113,6 +113,7 @@ Editor::Editor() { mouseDownCaptures = true; lastClickTime = 0; + doubleClickCloseThreshold = Point(3, 3); dwellDelay = SC_TIME_FOREVER; ticksToDwell = SC_TIME_FOREVER; dwelling = false; @@ -3777,10 +3778,10 @@ void Editor::GoToLine(int lineNo) { EnsureCaretVisible(); } -static bool Close(Point pt1, Point pt2) { - if (abs(pt1.x - pt2.x) > 3) +static bool Close(Point pt1, Point pt2, Point threshold) { + if (abs(pt1.x - pt2.x) > threshold.x) return false; - if (abs(pt1.y - pt2.y) > 3) + if (abs(pt1.y - pt2.y) > threshold.y) return false; return true; } @@ -4136,7 +4137,7 @@ void Editor::ButtonDownWithModifiers(Point pt, unsigned int curTime, int modifie if (shift && !inSelMargin) { SetSelection(newPos); } - if (((curTime - lastClickTime) < Platform::DoubleClickTime()) && Close(pt, lastClick)) { + if (((curTime - lastClickTime) < Platform::DoubleClickTime()) && Close(pt, lastClick, doubleClickCloseThreshold)) { //Platform::DebugPrintf("Double click %d %d = %d\n", curTime, lastClickTime, curTime - lastClickTime); SetMouseCapture(true); if (FineTickerAvailable()) { diff --git a/src/Editor.h b/src/Editor.h index a1f39e7c8..27a2469aa 100644 --- a/src/Editor.h +++ b/src/Editor.h @@ -203,6 +203,7 @@ protected: // ScintillaBase subclass needs access to much of Editor Point lastClick; unsigned int lastClickTime; + Point doubleClickCloseThreshold; int dwellDelay; int ticksToDwell; bool dwelling; diff --git a/src/LineMarker.cxx b/src/LineMarker.cxx index eb36f1bbc..98e75ca52 100644 --- a/src/LineMarker.cxx +++ b/src/LineMarker.cxx @@ -72,6 +72,11 @@ static void DrawMinus(Surface *surface, int centreX, int centreY, int armSize, C } void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharacter, typeOfFold tFold, int marginStyle) const { + if (customDraw != NULL) { + customDraw(surface, rcWhole, fontForCharacter, tFold, marginStyle, this); + return; + } + ColourDesired colourHead = back; ColourDesired colourBody = back; ColourDesired colourTail = back; diff --git a/src/LineMarker.h b/src/LineMarker.h index 4004a8a42..6a5fe7492 100644 --- a/src/LineMarker.h +++ b/src/LineMarker.h @@ -12,6 +12,8 @@ namespace Scintilla { #endif +typedef void (*DrawLineMarkerFn)(Surface *surface, PRectangle &rcWhole, Font &fontForCharacter, int tFold, int marginStyle, const void *lineMarker); + /** */ class LineMarker { @@ -25,6 +27,11 @@ public: int alpha; XPM *pxpm; RGBAImage *image; + /** Some platforms, notably PLAT_CURSES, do not support Scintilla's native + * Draw function for drawing line markers. Allow those platforms to override + * it instead of creating a new method(s) in the Surface class that existing + * platforms must implement as empty. */ + DrawLineMarkerFn customDraw; LineMarker() { markType = SC_MARK_CIRCLE; fore = ColourDesired(0,0,0); @@ -33,6 +40,7 @@ public: alpha = SC_ALPHA_NOALPHA; pxpm = NULL; image = NULL; + customDraw = NULL; } LineMarker(const LineMarker &) { // Defined to avoid pxpm being blindly copied, not as a complete copy constructor @@ -43,6 +51,7 @@ public: alpha = SC_ALPHA_NOALPHA; pxpm = NULL; image = NULL; + customDraw = NULL; } ~LineMarker() { delete pxpm; @@ -60,6 +69,7 @@ public: pxpm = NULL; delete image; image = NULL; + customDraw = NULL; } return *this; } diff --git a/src/MarginView.cxx b/src/MarginView.cxx index 269107443..b7ef48513 100644 --- a/src/MarginView.cxx +++ b/src/MarginView.cxx @@ -103,6 +103,8 @@ MarginView::MarginView() { pixmapSelMargin = 0; pixmapSelPattern = 0; pixmapSelPatternOffset1 = 0; + wrapMarkerPaddingRight = 3; + customDrawWrapMarker = NULL; } void MarginView::DropGraphics(bool freeObjects) { @@ -392,9 +394,13 @@ void MarginView::PaintMargin(Surface *surface, int topLine, PRectangle rc, PRect 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 --git a/src/MarginView.h b/src/MarginView.h index 465095f29..ff5564676 100644 --- a/src/MarginView.h +++ b/src/MarginView.h @@ -14,6 +14,8 @@ namespace Scintilla { void DrawWrapMarker(Surface *surface, PRectangle rcPlace, bool isEndMarker, ColourDesired wrapColour); +typedef void (*DrawWrapMarkerFn)(Surface *surface, PRectangle rcPlace, bool isEndMarker, ColourDesired wrapColour); + /** * MarginView draws the margins. */ @@ -25,6 +27,13 @@ public: // 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); |