From 3194268137ebe03b1fd8c0937f5879a94526d2b1 Mon Sep 17 00:00:00 2001 From: jedailey Date: Mon, 14 Nov 2016 12:54:25 +1100 Subject: Added alternate appearance for visible tabs which looks like a horizontal line. --- doc/ScintillaDoc.html | 29 +++++++++++++++++++++++++++++ doc/ScintillaHistory.html | 4 ++++ include/Scintilla.h | 4 ++++ include/Scintilla.iface | 11 +++++++++++ src/EditView.cxx | 26 +++++++++++++++----------- src/Editor.cxx | 8 ++++++++ src/ViewStyle.cxx | 2 ++ src/ViewStyle.h | 3 +++ 8 files changed, 76 insertions(+), 11 deletions(-) diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html index 9d60800cd..70ce8623f 100644 --- a/doc/ScintillaDoc.html +++ b/doc/ScintillaDoc.html @@ -2107,6 +2107,8 @@ struct Sci_TextToFind { SCI_SETWHITESPACESIZE(int size)
SCI_GETWHITESPACESIZE → int
+ SCI_SETTABDRAWMODE(int tabDrawMode)
+ SCI_GETTABDRAWMODE → int
SCI_SETEXTRAASCENT(int extraAscent)
SCI_GETEXTRAASCENT → int
SCI_SETEXTRADESCENT(int extraDescent)
@@ -2174,6 +2176,33 @@ struct Sci_TextToFind { The SCI_GETWHITESPACESIZE message retrieves the current size.

+

SCI_SETTABDRAWMODE(int tabDrawMode)
+ SCI_GETTABDRAWMODE → int
+ These two messages get and set how tab characters are drawn when white space is visible. + The tabDrawMode argument can be one of:

+ + + + + + + + + + + + + + + + + + + +
SCTD_LONGARROW0The default mode of an arrow stretching until the tabstop.
SCTD_STRIKEOUT1A horizontal line stretching until the tabstop.
+ +

The effect of using any other tabDrawMode value is undefined.

+

SCI_SETEXTRAASCENT(int extraAscent)
SCI_GETEXTRAASCENT → int
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index 3c156f49a..cd03b2b9d 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -531,6 +531,10 @@ underneath positions or characters.

  • + Added alternate appearance for visible tabs which looks like a horizontal line. + Controlled with SCI_SETTABDRAWMODE. +
  • +
  • Baan folder accomodates sections and lexer fixes definition of SCE_BAAN_FUNCDEF.
  • diff --git a/include/Scintilla.h b/include/Scintilla.h index dd643e9ea..b6c75a32d 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -76,6 +76,10 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCWS_VISIBLEONLYININDENT 3 #define SCI_GETVIEWWS 2020 #define SCI_SETVIEWWS 2021 +#define SCTD_LONGARROW 0 +#define SCTD_STRIKEOUT 1 +#define SCI_GETTABDRAWMODE 2698 +#define SCI_SETTABDRAWMODE 2699 #define SCI_POSITIONFROMPOINT 2022 #define SCI_POSITIONFROMPOINTCLOSE 2023 #define SCI_GOTOLINE 2024 diff --git a/include/Scintilla.iface b/include/Scintilla.iface index 6bb4da9b5..9f8a7db1c 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -168,6 +168,17 @@ get int GetViewWS=2020(,) # Make white space characters invisible, always visible or visible outside indentation. set void SetViewWS=2021(int viewWS,) +enu TabDrawMode=SCTD_ +val SCTD_LONGARROW=0 +val SCTD_STRIKEOUT=1 + +# Retrieve the current tab draw mode. +# Returns one of SCTD_* constants. +get int GetTabDrawMode=2698(,) + +# Set how tabs are drawn when visible. +set void SetTabDrawMode=2699(int tabDrawMode,) + # Find the position from a point within the window. fun position PositionFromPoint=2022(int x, int y) diff --git a/src/EditView.cxx b/src/EditView.cxx index 59e4e7ab7..04eea0ea5 100644 --- a/src/EditView.cxx +++ b/src/EditView.cxx @@ -306,21 +306,25 @@ static const char *ControlCharacterString(unsigned char ch) { } } -static void DrawTabArrow(Surface *surface, PRectangle rcTab, int ymid) { - int ydiff = static_cast(rcTab.bottom - rcTab.top) / 2; - int xhead = static_cast(rcTab.right) - 1 - ydiff; - if (xhead <= rcTab.left) { - ydiff -= static_cast(rcTab.left) - xhead - 1; - xhead = static_cast(rcTab.left) - 1; - } +static void DrawTabArrow(Surface *surface, PRectangle rcTab, int ymid, const ViewStyle &vsDraw) { if ((rcTab.left + 2) < (rcTab.right - 1)) surface->MoveTo(static_cast(rcTab.left) + 2, ymid); else surface->MoveTo(static_cast(rcTab.right) - 1, ymid); surface->LineTo(static_cast(rcTab.right) - 1, ymid); - surface->LineTo(xhead, ymid - ydiff); - surface->MoveTo(static_cast(rcTab.right) - 1, ymid); - surface->LineTo(xhead, ymid + ydiff); + + // Draw the arrow head if needed + if (vsDraw.tabDrawMode == tdLongArrow) { + int ydiff = static_cast(rcTab.bottom - rcTab.top) / 2; + int xhead = static_cast(rcTab.right) - 1 - ydiff; + if (xhead <= rcTab.left) { + ydiff -= static_cast(rcTab.left) - xhead - 1; + xhead = static_cast(rcTab.left) - 1; + } + surface->LineTo(xhead, ymid - ydiff); + surface->MoveTo(static_cast(rcTab.right) - 1, ymid); + surface->LineTo(xhead, ymid + ydiff); + } } void EditView::RefreshPixMaps(Surface *surfaceWindow, WindowID wid, const ViewStyle &vsDraw) { @@ -1579,7 +1583,7 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi PRectangle rcTab(rcSegment.left + 1, rcSegment.top + tabArrowHeight, rcSegment.right - 1, rcSegment.bottom - vsDraw.maxDescent); if (customDrawTabArrow == NULL) - DrawTabArrow(surface, rcTab, static_cast(rcSegment.top + vsDraw.lineHeight / 2)); + DrawTabArrow(surface, rcTab, static_cast(rcSegment.top + vsDraw.lineHeight / 2), vsDraw); else customDrawTabArrow(surface, rcTab, static_cast(rcSegment.top + vsDraw.lineHeight / 2)); } diff --git a/src/Editor.cxx b/src/Editor.cxx index 6950ac66e..5f588b1fd 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -6288,6 +6288,14 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { Redraw(); break; + case SCI_GETTABDRAWMODE: + return vs.tabDrawMode; + + case SCI_SETTABDRAWMODE: + vs.tabDrawMode = static_cast(wParam); + Redraw(); + break; + case SCI_GETWHITESPACESIZE: return vs.whitespaceSize; diff --git a/src/ViewStyle.cxx b/src/ViewStyle.cxx index e12620c96..b694a62e3 100644 --- a/src/ViewStyle.cxx +++ b/src/ViewStyle.cxx @@ -153,6 +153,7 @@ ViewStyle::ViewStyle(const ViewStyle &source) { textStart = source.textStart; zoomLevel = source.zoomLevel; viewWhitespace = source.viewWhitespace; + tabDrawMode = source.tabDrawMode; whitespaceSize = source.whitespaceSize; viewIndentationGuides = source.viewIndentationGuides; viewEOL = source.viewEOL; @@ -293,6 +294,7 @@ void ViewStyle::Init(size_t stylesSize_) { textStart = marginInside ? fixedColumnWidth : leftMarginWidth; zoomLevel = 0; viewWhitespace = wsInvisible; + tabDrawMode = tdLongArrow; whitespaceSize = 1; viewIndentationGuides = ivNone; viewEOL = false; diff --git a/src/ViewStyle.h b/src/ViewStyle.h index 82c176c87..1a876f85e 100644 --- a/src/ViewStyle.h +++ b/src/ViewStyle.h @@ -55,6 +55,8 @@ enum IndentView {ivNone, ivReal, ivLookForward, ivLookBoth}; enum WhiteSpaceVisibility {wsInvisible=0, wsVisibleAlways=1, wsVisibleAfterIndent=2, wsVisibleOnlyInIndent=3}; +enum TabDrawMode {tdLongArrow=0, tdStrikeOut=1}; + typedef std::map FontMap; enum WrapMode { eWrapNone, eWrapWord, eWrapChar, eWrapWhitespace }; @@ -133,6 +135,7 @@ public: int textStart; ///< Starting x position of text within the view int zoomLevel; WhiteSpaceVisibility viewWhitespace; + TabDrawMode tabDrawMode; int whitespaceSize; IndentView viewIndentationGuides; bool viewEOL; -- cgit v1.2.3