[PATCH] Marker symbol draw on sublines
Mitchell <[email protected]> Tue, 3 Jun 2025 00:40:34 -0400
| Newsgroups | gmane.comp.lib.scintilla.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi Neil, Attached is a patch against Scintilla hg from May 25, 2025 that adds two messages to Scintilla: - SCI_MARKERSYMBOLSETDRAWONSUBLINE(int markerSymbol, bool draw) - SCI_MARKERSYMBOLGETDRAWONSUBLINE(int markerSymbol) -> bool The Set call enables markers with that symbol the be drawn on sublines, just like SC_MARK_BAR. The Get call is its compliment. It uses a std::set<MarkerSymbol> behind the scenes that contains SC_MARK_BAR by default. I chose to use marker symbols instead of marker numbers because (1) it easily supports the existing SC_MARK_BAR and (2) enabling it for individual marker numbers seems tedious. If you disagree, I can resubmit with support for marker numbers instead. If you prefer not to include this, that’s fine, as I can just patch my application to include SC_MARK_FULLRECT in the mask along with SC_MARK_BAR. Feel free to change the names; they’re a bit of a mouthful! Cheers, Mitchell -- You received this message because you are subscribed to the Google Groups "scintilla-interest" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion visit https://groups.google.com/d/msgid/scintilla-interest/92233943-945D-40EA-B9D9-05419A6F69DA%40foicica.com.
0001-Allow-drawing-more-marker-symbols-on-sublines.patch
(application/octet-stream, 8.1 KB)
From b8492e8d3db01bce1d3d68421fc974f0cd68b9f5 Mon Sep 17 00:00:00 2001 From: orbitalquark <[email protected]> Date: Tue, 3 Jun 2025 00:27:09 -0400 Subject: [PATCH] Allow drawing more marker symbols on sublines. --- call/ScintillaCall.cxx | 8 ++++++++ doc/ScintillaDoc.html | 9 +++++++++ include/Scintilla.h | 2 ++ include/Scintilla.iface | 6 ++++++ include/ScintillaCall.h | 2 ++ include/ScintillaMessages.h | 2 ++ src/Editor.cxx | 10 ++++++++++ src/ViewStyle.cxx | 9 +++------ src/ViewStyle.h | 1 + 9 files changed, 43 insertions(+), 6 deletions(-) diff --git a/call/ScintillaCall.cxx b/call/ScintillaCall.cxx index 11a1f1d5..a4fec2de 100644 --- a/call/ScintillaCall.cxx +++ b/call/ScintillaCall.cxx @@ -467,6 +467,14 @@ void ScintillaCall::MarkerSetLayer(int markerNumber, Scintilla::Layer layer) { Call(Message::MarkerSetLayer, markerNumber, static_cast<intptr_t>(layer)); } +bool ScintillaCall::MarkerSymbolGetDrawOnSubLines(Scintilla::MarkerSymbol markerSymbol) { + return Call(Message::MarkerSymbolGetDrawOnSubLines, static_cast<uintptr_t>(markerSymbol)); +} + +void ScintillaCall::MarkerSymbolSetDrawOnSubLines(Scintilla::MarkerSymbol markerSymbol, bool drawOnSublines) { + Call(Message::MarkerSymbolSetDrawOnSubLines, static_cast<uintptr_t>(markerSymbol), drawOnSublines); +} + void ScintillaCall::SetMarginTypeN(int margin, Scintilla::MarginType marginType) { Call(Message::SetMarginTypeN, margin, static_cast<intptr_t>(marginType)); } diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html index 17ee1673..d236cbc9 100644 --- a/doc/ScintillaDoc.html +++ b/doc/ScintillaDoc.html @@ -5649,6 +5649,8 @@ struct Sci_TextToFindFull { <a class="message" href="#SCI_MARKERSETLAYER">SCI_MARKERSETLAYER(int markerNumber, int layer)</a><br /> <a class="message" href="#SCI_MARKERGETLAYER">SCI_MARKERGETLAYER(int markerNumber) → int</a><br /> <a class="message" href="#SCI_MARKERSETALPHA">SCI_MARKERSETALPHA(int markerNumber, alpha alpha)</a><br /> + <a class="message" href="#SCI_MARKERSYMBOLGETDRAWONSUBLINE">SCI_MARKERSYMBOLGETDRAWONSUBLINE(int markerSymbol) → bool</a><br /> + <a class="message" href="#SCI_MARKERSYMBOLSETDRAWONSUBLINE">SCI_MARKERSYMBOLSETDRAWONSUBLINE(int markerSymbol, bool draw)</a><br /> <a class="message" href="#SCI_MARKERADD">SCI_MARKERADD(line line, int markerNumber) → int</a><br /> <a class="message" href="#SCI_MARKERADDSET">SCI_MARKERADDSET(line line, int markerSet)</a><br /> <a class="message" href="#SCI_MARKERDELETE">SCI_MARKERDELETE(line line, int @@ -5924,6 +5926,13 @@ struct Sci_TextToFindFull { </tbody> </table> + <p> + <b id="SCI_MARKERSYMBOLSETDRAWONSUBLINE">SCI_MARKERSYMBOLSETDRAWONSUBLINE(int markerSymbol, bool draw)</b><br /> + <b id="SCI_MARKERSYMBOLGETDRAWONSUBLINE">SCI_MARKERSYMBOLGETDRAWONSUBLINE(int markerSymbol) → bool</b><br /> + When lines are wrapped, only markers with the <code>SC_MARK_BAR</code> symbol are drawn on sublines. + Use <code>SCI_MARKERSYMBOLSETDRAWONSUBLINE</code> to draw markers with other symbols on sublines. + </p> + <p><b id="SCI_MARKERADD">SCI_MARKERADD(line line, int markerNumber) → int</b><br /> This message adds marker number <code class="parameter">markerNumber</code> to a line. The message returns -1 if this fails (illegal line number, out of memory) or it returns a marker handle number that diff --git a/include/Scintilla.h b/include/Scintilla.h index e2555b86..e1072072 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -188,6 +188,8 @@ typedef sptr_t (*SciFnDirectStatus)(sptr_t ptr, unsigned int iMessage, uptr_t wP #define SCI_MARKERSETALPHA 2476 #define SCI_MARKERGETLAYER 2734 #define SCI_MARKERSETLAYER 2735 +#define SCI_MARKERSYMBOLGETDRAWONSUBLINES 2817 +#define SCI_MARKERSYMBOLSETDRAWONSUBLINES 2818 #define SC_MAX_MARGIN 4 #define SC_MARGIN_SYMBOL 0 #define SC_MARGIN_NUMBER 1 diff --git a/include/Scintilla.iface b/include/Scintilla.iface index af34b71d..4d340948 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -476,6 +476,12 @@ get Layer MarkerGetLayer=2734(int markerNumber,) # Set the layer used for a marker that is drawn in the text area, not the margin. set void MarkerSetLayer=2735(int markerNumber, Layer layer) +# Get whether a marker symbol is drawn on wrapped lines. +get bool MarkerSymbolGetDrawOnSubLines=2817(MarkerSymbol markerSymbol,) + +# Set whether a marker symbol is drawn on sublines. +set void MarkerSymbolSetDrawOnSubLines=2818(MarkerSymbol markerSymbol, bool drawOnSublines) + val SC_MAX_MARGIN=4 enu MarginType=SC_MARGIN_ diff --git a/include/ScintillaCall.h b/include/ScintillaCall.h index a2387f87..1809ddcb 100644 --- a/include/ScintillaCall.h +++ b/include/ScintillaCall.h @@ -162,6 +162,8 @@ public: void MarkerSetAlpha(int markerNumber, Scintilla::Alpha alpha); Scintilla::Layer MarkerGetLayer(int markerNumber); void MarkerSetLayer(int markerNumber, Scintilla::Layer layer); + bool MarkerSymbolGetDrawOnSubLines(Scintilla::MarkerSymbol markerSymbol); + void MarkerSymbolSetDrawOnSubLines(Scintilla::MarkerSymbol markerSymbol, bool drawOnSublines); void SetMarginTypeN(int margin, Scintilla::MarginType marginType); Scintilla::MarginType MarginTypeN(int margin); void SetMarginWidthN(int margin, int pixelWidth); diff --git a/include/ScintillaMessages.h b/include/ScintillaMessages.h index 67b4f69c..8ca4a496 100644 --- a/include/ScintillaMessages.h +++ b/include/ScintillaMessages.h @@ -91,6 +91,8 @@ enum class Message { MarkerSetAlpha = 2476, MarkerGetLayer = 2734, MarkerSetLayer = 2735, + MarkerSymbolGetDrawOnSubLines = 2817, + MarkerSymbolSetDrawOnSubLines = 2818, SetMarginTypeN = 2240, GetMarginTypeN = 2241, SetMarginWidthN = 2242, diff --git a/src/Editor.cxx b/src/Editor.cxx index d941612b..859a76b6 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -7499,6 +7499,16 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) { return static_cast<sptr_t>(vs.markers[wParam].layer); } return 0; + case Message::MarkerSymbolGetDrawOnSubLines: + return vs.drawWrappedMarkerTypes.find(static_cast<MarkerSymbol>(wParam)) != vs.drawWrappedMarkerTypes.end(); + case Message::MarkerSymbolSetDrawOnSubLines: { + const MarkerSymbol symbol = static_cast<MarkerSymbol>(wParam); + if (lParam != 0) + vs.drawWrappedMarkerTypes.insert(symbol); + else + vs.drawWrappedMarkerTypes.erase(symbol); + } + break; case Message::MarkerAdd: { const int markerID = pdoc->AddMark(LineFromUPtr(wParam), static_cast<int>(lParam)); return markerID; diff --git a/src/ViewStyle.cxx b/src/ViewStyle.cxx index 92d084ee..9ae1e171 100644 --- a/src/ViewStyle.cxx +++ b/src/ViewStyle.cxx @@ -217,6 +217,8 @@ ViewStyle::ViewStyle(size_t stylesSize_) : hotspotUnderline = true; elementAllowsTranslucent.insert(Element::HotSpotActive); + drawWrappedMarkerTypes.insert(MarkerSymbol::Bar); + leftMarginWidth = 1; rightMarginWidth = 1; ms[0] = MarginStyle(MarginType::Number); @@ -362,13 +364,8 @@ void ViewStyle::CalculateMarginWidthAndMask() noexcept { maskDrawWrapped = 0; for (int markBit = 0; markBit <= MarkerMax; markBit++) { const int maskBit = 1U << markBit; - switch (markers[markBit].markType) { - case MarkerSymbol::Bar: + if (drawWrappedMarkerTypes.find(markers[markBit].markType) != drawWrappedMarkerTypes.end()) maskDrawWrapped |= maskBit; - break; - default: // Other marker types do not affect the masks - break; - } } } diff --git a/src/ViewStyle.h b/src/ViewStyle.h index 6985e3f0..9f9ae6bb 100644 --- a/src/ViewStyle.h +++ b/src/ViewStyle.h @@ -143,6 +143,7 @@ public: int rightMarginWidth; ///< Spacing margin on right of text int maskInLine = 0; ///< Mask for markers to be put into text because there is nowhere for them to go in margin int maskDrawInText = 0; ///< Mask for markers that always draw in text + std::set<MarkerSymbol> drawWrappedMarkerTypes; ///< Set of marker types to draw on wrapped lines int maskDrawWrapped = 0; ///< Mask for markers that draw on wrapped lines std::vector<MarginStyle> ms; int fixedColumnWidth = 0; ///< Total width of margins -- 2.47.0
marker-symbol-set-draw-on-subline.zip
(application/zip, 260.6 KB) - not displayed