From 57f5c36ccf0ddc9be4b348bbe39cf3347ea8381c Mon Sep 17 00:00:00 2001 From: Neil Date: Thu, 29 Jul 2021 12:43:47 +1000 Subject: Add SC_ELEMENT_FOLD_LINE to set the colour of fold lines. --- doc/ScintillaDoc.html | 24 +++++++++++++++++++----- doc/ScintillaHistory.html | 3 +++ include/Scintilla.h | 1 + include/Scintilla.iface | 1 + include/ScintillaTypes.h | 1 + src/EditView.cxx | 6 ++++-- 6 files changed, 29 insertions(+), 7 deletions(-) diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html index 531fca5aa..511632937 100644 --- a/doc/ScintillaDoc.html +++ b/doc/ScintillaDoc.html @@ -128,7 +128,7 @@

Scintilla Documentation

-

Last edited 17 July 2021 NH

+

Last edited 29 July 2021 NH

Scintilla 5 has moved the lexers from Scintilla into a new Lexilla project.
@@ -2395,8 +2395,8 @@ struct Sci_TextToFind { SCI_SETWHITESPACEBACK(bool useSetting, colour back)
By default, the colour of visible white space is determined by the lexer in use. The foreground and/or background colour of all visible white space can be set globally, overriding - the lexer's colours with SC_ELEMENT_WHITE_SPACE - and SC_ELEMENT_WHITE_SPACE_BACK. + the lexer's colours with SC_ELEMENT_WHITE_SPACE + and SC_ELEMENT_WHITE_SPACE_BACK. .
SCI_SETWHITESPACEFORE and SCI_SETWHITESPACEBACK also change the white space colours but the element APIs are preferred with SC_ELEMENT_WHITE_SPACE @@ -3496,6 +3496,14 @@ struct Sci_TextToFind { Background colour of active hot spot + + SC_ELEMENT_FOLD_LINE + 80 + Translucent + All + + Colour of fold lines + @@ -7007,6 +7015,7 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){ SCI_SETAUTOMATICFOLD(int automaticFold)
SCI_GETAUTOMATICFOLD → int
SCI_SETFOLDFLAGS(int flags)
+ SC_ELEMENT_FOLD_LINE : colouralpha
SCI_GETLASTCHILD(line line, int level) → line
SCI_GETFOLDPARENT(line line) → line
SCI_SETFOLDEXPANDED(line line, bool @@ -7086,9 +7095,14 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){ update to match your changes.

SCI_SETFOLDFLAGS(int flags)
+ SC_ELEMENT_FOLD_LINE : colouralpha
In addition to showing markers in the folding margin, you can indicate folds to the user by - drawing lines in the text area. The lines are drawn in the foreground colour set for
STYLE_DEFAULT. Bits set in + drawing lines in the text area. + The lines are drawn in the SC_ELEMENT_FOLD_LINE + colour if set. + If it is not set then the foreground colour set for STYLE_DEFAULT is used. + Bits set in flags determine where folding lines are drawn:

diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index 1b88ebab1..f0c6ded0b 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -575,6 +575,9 @@ Released 26 July 2021.
  • + Add SC_ELEMENT_FOLD_LINE to set the colour of fold lines. +
  • +
  • Fix display of fold lines when wrapped so they are only drawn once per line, not on each subline.
  • diff --git a/include/Scintilla.h b/include/Scintilla.h index 97fbd3be0..3af22dfc5 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -291,6 +291,7 @@ typedef sptr_t (*SciFnDirectStatus)(sptr_t ptr, unsigned int iMessage, uptr_t wP #define SC_ELEMENT_WHITE_SPACE_BACK 61 #define SC_ELEMENT_HOT_SPOT_ACTIVE 70 #define SC_ELEMENT_HOT_SPOT_ACTIVE_BACK 71 +#define SC_ELEMENT_FOLD_LINE 80 #define SCI_SETELEMENTCOLOUR 2753 #define SCI_GETELEMENTCOLOUR 2754 #define SCI_RESETELEMENTCOLOUR 2755 diff --git a/include/Scintilla.iface b/include/Scintilla.iface index cc7dedf36..d8a1bdec1 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -697,6 +697,7 @@ val SC_ELEMENT_WHITE_SPACE=60 val SC_ELEMENT_WHITE_SPACE_BACK=61 val SC_ELEMENT_HOT_SPOT_ACTIVE=70 val SC_ELEMENT_HOT_SPOT_ACTIVE_BACK=71 +val SC_ELEMENT_FOLD_LINE=80 # Set the colour of an element. Translucency (alpha) may or may not be significant # and this may depend on the platform. The alpha byte should commonly be 0xff for opaque. diff --git a/include/ScintillaTypes.h b/include/ScintillaTypes.h index 830ccadba..ab4a55131 100644 --- a/include/ScintillaTypes.h +++ b/include/ScintillaTypes.h @@ -180,6 +180,7 @@ enum class Element { WhiteSpaceBack = 61, HotSpotActive = 70, HotSpotActiveBack = 71, + FoldLine = 80, }; enum class Layer { diff --git a/src/EditView.cxx b/src/EditView.cxx index f4d37e221..7eea729fd 100644 --- a/src/EditView.cxx +++ b/src/EditView.cxx @@ -2289,19 +2289,21 @@ static void DrawFoldLines(Surface *surface, const EditModel &model, const ViewSt const FoldLevel levelNext = model.pdoc->GetFoldLevel(line + 1); if (LevelIsHeader(level) && (LevelNumber(level) < LevelNumber(levelNext))) { + const ColourRGBA foldLineColour = vsDraw.ElementColour(Element::FoldLine).value_or( + vsDraw.styles[StyleDefault].fore); // Paint the line above the fold if ((subLine == 0) && ((expanded && (FlagSet(model.foldFlags, FoldFlag::LineBeforeExpanded))) || (!expanded && (FlagSet(model.foldFlags, FoldFlag::LineBeforeContracted))))) { - surface->FillRectangleAligned(Side(rcLine, Edge::top, 1.0), Fill(vsDraw.styles[StyleDefault].fore)); + surface->FillRectangleAligned(Side(rcLine, Edge::top, 1.0), foldLineColour); } // Paint the line below the fold if (lastSubLine && ((expanded && (FlagSet(model.foldFlags, FoldFlag::LineAfterExpanded))) || (!expanded && (FlagSet(model.foldFlags, FoldFlag::LineAfterContracted))))) { - surface->FillRectangleAligned(Side(rcLine, Edge::bottom, 1.0), Fill(vsDraw.styles[StyleDefault].fore)); + surface->FillRectangleAligned(Side(rcLine, Edge::bottom, 1.0), foldLineColour); } } } -- cgit v1.2.3