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. --- src/EditView.cxx | 26 +++++++++++++++----------- src/Editor.cxx | 8 ++++++++ src/ViewStyle.cxx | 2 ++ src/ViewStyle.h | 3 +++ 4 files changed, 28 insertions(+), 11 deletions(-) (limited to 'src') 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