From 7621fda67d13735836c6f050d1eec8c691a68292 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Thu, 26 Feb 2026 10:38:16 +1100 Subject: Add SCI_SETTABDRAWMODE(SCTD_CONTROLCHAR). Allows rendering tabs (ASCII 9) with character representations like any other control character. --- doc/ScintillaDoc.html | 10 ++++++++++ doc/ScintillaHistory.html | 11 +++++++++++ include/Scintilla.h | 1 + include/Scintilla.iface | 2 ++ include/ScintillaTypes.h | 1 + src/EditView.cxx | 10 +++++----- src/Editor.cxx | 2 +- 7 files changed, 31 insertions(+), 6 deletions(-) diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html index d432043f6..3189a001a 100644 --- a/doc/ScintillaDoc.html +++ b/doc/ScintillaDoc.html @@ -2890,6 +2890,16 @@ struct Sci_TextToFindFull { A horizontal line stretching until the tabstop. + + + SCTD_CONTROLCHAR + + 2 + + Will be drawn as a control code according to the configured + character representation + without any indentation. + diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index b91a7e282..26333e1be 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -596,6 +596,17 @@

Releases

+

+ Release 5.6.1 +

+

Release 5.6.0

diff --git a/include/Scintilla.h b/include/Scintilla.h index b6786097e..94a66d4f8 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -78,6 +78,7 @@ typedef sptr_t (*SciFnDirectStatus)(sptr_t ptr, unsigned int iMessage, uptr_t wP #define SCI_SETVIEWWS 2021 #define SCTD_LONGARROW 0 #define SCTD_STRIKEOUT 1 +#define SCTD_CONTROLCHAR 2 #define SCI_GETTABDRAWMODE 2698 #define SCI_SETTABDRAWMODE 2699 #define SCI_POSITIONFROMPOINT 2022 diff --git a/include/Scintilla.iface b/include/Scintilla.iface index 6262f7c1b..d98ac8358 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -196,9 +196,11 @@ set void SetViewWS=2021(WhiteSpace viewWS,) enu TabDrawMode=SCTD_ val SCTD_LONGARROW=0 val SCTD_STRIKEOUT=1 +val SCTD_CONTROLCHAR=2 ali SCTD_LONGARROW=LONG_ARROW ali SCTD_STRIKEOUT=STRIKE_OUT +ali SCTD_CONTROLCHAR=CONTROL_CHAR # Retrieve the current tab draw mode. # Returns one of SCTD_* constants. diff --git a/include/ScintillaTypes.h b/include/ScintillaTypes.h index 0991a1480..a1e55c203 100644 --- a/include/ScintillaTypes.h +++ b/include/ScintillaTypes.h @@ -26,6 +26,7 @@ enum class WhiteSpace { enum class TabDrawMode { LongArrow = 0, StrikeOut = 1, + ControlChar = 2, }; enum class EndOfLine { diff --git a/src/EditView.cxx b/src/EditView.cxx index 2608f11e5..bec07fe95 100644 --- a/src/EditView.cxx +++ b/src/EditView.cxx @@ -352,7 +352,7 @@ void LayoutSegments(IPositionCache *pCache, XYPOSITION representationWidth = 0.0; // Tab is a special case of representation, taking a variable amount of space // which will be filled in later. - if (ll->chars[ts.start] != '\t') { + if (ll->chars[ts.start] != '\t' || vstyle.tabDrawMode == TabDrawMode::ControlChar) { representationWidth = vstyle.controlCharWidth; if (representationWidth <= 0.0) { assert(ts.representation->stringRep.length() <= Representation::maxLength); @@ -522,7 +522,7 @@ void EditView::LayoutLine(const EditModel &model, Surface *surface, const ViewSt for (const TextSegment &ts : segments) { if (vstyle.styles[ll->styles[ts.start]].visible && ts.representation && - (ll->chars[ts.start] == '\t')) { + ll->chars[ts.start] == '\t' && vstyle.tabDrawMode != TabDrawMode::ControlChar) { // Simple visible tab, go to next tab stop const XYPOSITION startTab = ll->positions[ts.start]; const XYPOSITION nextTab = NextTabstopPos(line, startTab, vstyle.tabWidth); @@ -610,7 +610,7 @@ void EditView::UpdateBidiData(const EditModel &model, const ViewStyle &vstyle, L const Representation *repr = model.reprs->RepresentationFromCharacter(std::string_view(&ll->chars[charsInLine], charWidth)); ll->bidiData->widthReprs[charsInLine] = 0.0f; - if (repr && ll->chars[charsInLine] != '\t') { + if (repr && (ll->chars[charsInLine] != '\t' || vstyle.tabDrawMode == TabDrawMode::ControlChar)) { ll->bidiData->widthReprs[charsInLine] = ll->positions[charsInLine + charWidth] - ll->positions[charsInLine]; } if (charWidth > 1) { @@ -1673,7 +1673,7 @@ void DrawBackground(Surface *surface, const EditModel &model, const ViewStyle &v ColourRGBA textBack = TextBackground(model, vsDraw, ll, background, inSelection, inHotspot, ll->styles[i], i); if (ts.representation) { - if (ll->chars[i] == '\t') { + if (ll->chars[i] == '\t' && vsDraw.tabDrawMode != TabDrawMode::ControlChar) { // Tab display if (drawWhitespaceBackground && vsDraw.WhiteSpaceVisible(inIndentation)) { textBack = vsDraw.ElementColourForced(Element::WhiteSpaceBack).Opaque(); @@ -2178,7 +2178,7 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi } ColourRGBA textBack = TextBackground(model, vsDraw, ll, background, inSelection, inHotspot, styleMain, i); if (ts.representation) { - if (ll->chars[i] == '\t') { + if (ll->chars[i] == '\t' && vsDraw.tabDrawMode != TabDrawMode::ControlChar) { // Tab display if (phasesDraw == PhasesDraw::One) { if (drawWhitespaceBackground && vsDraw.WhiteSpaceVisible(inIndentation)) diff --git a/src/Editor.cxx b/src/Editor.cxx index 5b42407e3..0289fa5e5 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -6984,7 +6984,7 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) { return static_cast(vs.tabDrawMode); case Message::SetTabDrawMode: - vs.tabDrawMode = static_cast(wParam); + SetAppearance(vs.tabDrawMode, static_cast(wParam)); Redraw(); break; -- cgit v1.2.3