aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2021-05-14 13:54:44 +1000
committerNeil <nyamatongwe@gmail.com>2021-05-14 13:54:44 +1000
commit17d2d5c793eaa95b170684213b18ff2e3f5ce291 (patch)
tree35f64342cf85c11800ae711c0def0a1be435d20b
parentc173fc47fda7bb86399bd777540bb17f8e05172d (diff)
downloadscintilla-mirror-17d2d5c793eaa95b170684213b18ff2e3f5ce291.tar.gz
Add SC_ELEMENT_WHITE_SPACE_BACK to set the background colour of visible
whitespace.
-rw-r--r--doc/ScintillaDoc.html55
-rw-r--r--include/Scintilla.h1
-rw-r--r--include/Scintilla.iface1
-rw-r--r--src/EditView.cxx13
-rw-r--r--src/Editor.cxx5
-rw-r--r--src/ViewStyle.cxx8
-rw-r--r--src/ViewStyle.h5
7 files changed, 60 insertions, 28 deletions
diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html
index e91c80783..380a8e81d 100644
--- a/doc/ScintillaDoc.html
+++ b/doc/ScintillaDoc.html
@@ -128,7 +128,7 @@
<h1>Scintilla Documentation</h1>
- <p>Last edited 11 May 2021 NH</p>
+ <p>Last edited 13 May 2021 NH</p>
<p style="background:#90F0C0">Scintilla 5 has moved the lexers from Scintilla into a new
<a href="Lexilla.html">Lexilla</a> project.<br />
@@ -2302,9 +2302,10 @@ struct Sci_TextToFind {
<code><a class="message" href="#SCI_SETVIEWWS">SCI_SETVIEWWS(int viewWS)</a><br />
<a class="message" href="#SCI_GETVIEWWS">SCI_GETVIEWWS &rarr; int</a><br />
<a class="element" href="#SC_ELEMENT_WHITE_SPACE">SC_ELEMENT_WHITE_SPACE : colouralpha</a><br />
- <a class="message" href="#SCI_SETWHITESPACEFORE">SCI_SETWHITESPACEFORE(bool
+ <a class="discouraged message" href="#SCI_SETWHITESPACEFORE">SCI_SETWHITESPACEFORE(bool
useSetting, colour fore)</a><br />
- <a class="message" href="#SCI_SETWHITESPACEBACK">SCI_SETWHITESPACEBACK(bool
+ <a class="element" href="#SC_ELEMENT_WHITE_SPACE_BACK">SC_ELEMENT_WHITE_SPACE_BACK : colouralpha</a><br />
+ <a class="discouraged message" href="#SCI_SETWHITESPACEBACK">SCI_SETWHITESPACEBACK(bool
useSetting, colour back)</a><br />
<a class="message" href="#SCI_SETWHITESPACESIZE">SCI_SETWHITESPACESIZE(int
size)</a><br />
@@ -2368,13 +2369,16 @@ struct Sci_TextToFind {
<p>
<b id="SC_ELEMENT_WHITE_SPACE">SC_ELEMENT_WHITE_SPACE : colouralpha</b><br />
<b id="SCI_SETWHITESPACEFORE">SCI_SETWHITESPACEFORE(bool useSetting, <a class="jump" href="#colour">colour</a> fore)</b><br />
+ <b id="SC_ELEMENT_WHITE_SPACE_BACK">SC_ELEMENT_WHITE_SPACE_BACK : colouralpha</b><br />
<b id="SCI_SETWHITESPACEBACK">SCI_SETWHITESPACEBACK(bool useSetting, <a class="jump" href="#colour">colour</a> back)</b><br />
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 <a href="#SCI_SETELEMENTCOLOUR"><code>SC_ELEMENT_WHITE_SPACE</code></a> and
- <code>SCI_SETWHITESPACEBACK</code>.<br />
- <code>SCI_SETWHITESPACEFORE</code> also changes the white space colour but <code>SC_ELEMENT_WHITE_SPACE</code>
- is preferred and allows setting translucency.</p>
+ the lexer's colours with <a href="#SCI_SETELEMENTCOLOUR"><code>SC_ELEMENT_WHITE_SPACE</code></a>
+ and <a href="#SCI_SETELEMENTCOLOUR"><code>SC_ELEMENT_WHITE_SPACE_BACK</code></a>.
+ .<br />
+ <code>SCI_SETWHITESPACEFORE</code> and <code>SCI_SETWHITESPACEBACK</code> also
+ change the white space colours but the element APIs are preferred with <code>SC_ELEMENT_WHITE_SPACE</code>
+ allowing translucency.</p>
<p><b id="SCI_SETWHITESPACESIZE">SCI_SETWHITESPACESIZE(int size)</b><br />
<b id="SCI_GETWHITESPACESIZE">SCI_GETWHITESPACESIZE &rarr; int</b><br />
@@ -3288,8 +3292,8 @@ struct Sci_TextToFind {
When undefined the return value is 0 which is equivalent to completely transparent black.
These colours may be useful when defining styles with similarities such as synthesizing dark
mode styles that use the same colours as the system</p>
- <p>On Win32, autocompletion list colours like <code>SC_ELEMENT_LIST</code> are currently available.
- On Cocoa, selection background colours like <code>SC_ELEMENT_SELECTION_BACK</code> are currently available.
+ <p>On Win32, autocompletion list colours like <code>SC_ELEMENT_LIST</code> are currently provided by the platform layer and
+ on Cocoa, selection background colours like <code>SC_ELEMENT_SELECTION_BACK</code> are provided.
</p>
<table class="standard" summary="Elements">
@@ -3301,7 +3305,9 @@ struct Sci_TextToFind {
<th>Translucent?</th>
- <th>Platforms</th>
+ <th>Active</th>
+
+ <th>Base</th>
<th>Description</th>
</tr>
@@ -3312,6 +3318,7 @@ struct Sci_TextToFind {
<td>0</td>
<td>Opaque</td>
<td>Win32</td>
+ <td>Win32</td>
<td>Text colour in autocompletion lists</td>
</tr>
<tr>
@@ -3319,6 +3326,7 @@ struct Sci_TextToFind {
<td>1</td>
<td>Opaque</td>
<td>Win32</td>
+ <td>Win32</td>
<td>Background colour of autocompletion lists</td>
</tr>
<tr>
@@ -3326,6 +3334,7 @@ struct Sci_TextToFind {
<td>2</td>
<td>Opaque</td>
<td>Win32</td>
+ <td>Win32</td>
<td>Text colour of selected item in autocompletion lists</td>
</tr>
<tr>
@@ -3333,6 +3342,7 @@ struct Sci_TextToFind {
<td>3</td>
<td>Opaque</td>
<td>Win32</td>
+ <td>Win32</td>
<td>Background colour of selected item in autocompletion lists</td>
</tr>
<tr class="section">
@@ -3340,6 +3350,7 @@ struct Sci_TextToFind {
<td>10</td>
<td>Translucent</td>
<td>All</td>
+ <td></td>
<td>Text colour of main selection</td>
</tr>
<tr>
@@ -3347,6 +3358,7 @@ struct Sci_TextToFind {
<td>11</td>
<td>Translucent</td>
<td>All</td>
+ <td>Cocoa</td>
<td>Background colour of main selection</td>
</tr>
<tr>
@@ -3354,6 +3366,7 @@ struct Sci_TextToFind {
<td>12</td>
<td>Translucent</td>
<td>All</td>
+ <td></td>
<td>Text colour of additional selections</td>
</tr>
<tr>
@@ -3361,6 +3374,7 @@ struct Sci_TextToFind {
<td>13</td>
<td>Translucent</td>
<td>All</td>
+ <td>Cocoa</td>
<td>Background colour of additional selections</td>
</tr>
<tr>
@@ -3368,6 +3382,7 @@ struct Sci_TextToFind {
<td>14</td>
<td>Translucent</td>
<td>All</td>
+ <td></td>
<td>Text colour of selections when another window contains the primary selection</td>
</tr>
<tr>
@@ -3375,6 +3390,7 @@ struct Sci_TextToFind {
<td>15</td>
<td>Translucent</td>
<td>All</td>
+ <td></td>
<td>Background colour of selections when another window contains the primary selection</td>
</tr>
<tr>
@@ -3382,6 +3398,7 @@ struct Sci_TextToFind {
<td>16</td>
<td>Translucent</td>
<td>All</td>
+ <td></td>
<td>Text colour of selections when another window has focus</td>
</tr>
<tr>
@@ -3389,6 +3406,7 @@ struct Sci_TextToFind {
<td>17</td>
<td>Translucent</td>
<td>All</td>
+ <td>Cocoa</td>
<td>Background colour of selections when another window has focus</td>
</tr>
<tr class="section">
@@ -3396,6 +3414,7 @@ struct Sci_TextToFind {
<td>40</td>
<td>Translucent</td>
<td>All</td>
+ <td></td>
<td>Colour of caret for main selection</td>
</tr>
<tr>
@@ -3403,6 +3422,7 @@ struct Sci_TextToFind {
<td>41</td>
<td>Translucent</td>
<td>All</td>
+ <td></td>
<td>Colour of caret for additional selections</td>
</tr>
<tr>
@@ -3410,22 +3430,33 @@ struct Sci_TextToFind {
<td>42</td>
<td>Translucent</td>
<td>All</td>
+ <td></td>
<td>Colour of carets when another window has focus</td>
</tr>
- <tr>
+ <tr class="section">
<th align="left"><code>SC_ELEMENT_CARET_LINE_BACK</code></th>
<td>50</td>
<td>Translucent</td>
<td>All</td>
+ <td></td>
<td>Colour of caret line background</td>
</tr>
- <tr>
+ <tr class="section">
<th align="left"><code>SC_ELEMENT_WHITE_SPACE</code></th>
<td>60</td>
<td>Translucent</td>
<td>All</td>
+ <td></td>
<td>Colour of visible white space</td>
</tr>
+ <tr>
+ <th align="left"><code>SC_ELEMENT_WHITE_SPACE_BACK</code></th>
+ <td>61</td>
+ <td>Opaque</td>
+ <td>All</td>
+ <td></td>
+ <td>Colour of visible white space background</td>
+ </tr>
</tbody>
</table>
diff --git a/include/Scintilla.h b/include/Scintilla.h
index b4ec3b462..2c91400af 100644
--- a/include/Scintilla.h
+++ b/include/Scintilla.h
@@ -288,6 +288,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SC_ELEMENT_CARET_SECONDARY 42
#define SC_ELEMENT_CARET_LINE_BACK 50
#define SC_ELEMENT_WHITE_SPACE 60
+#define SC_ELEMENT_WHITE_SPACE_BACK 61
#define SCI_SETELEMENTCOLOUR 2753
#define SCI_GETELEMENTCOLOUR 2754
#define SCI_RESETELEMENTCOLOUR 2755
diff --git a/include/Scintilla.iface b/include/Scintilla.iface
index 38b548d0d..730c7bb12 100644
--- a/include/Scintilla.iface
+++ b/include/Scintilla.iface
@@ -695,6 +695,7 @@ val SC_ELEMENT_CARET_ADDITIONAL=41
val SC_ELEMENT_CARET_SECONDARY=42
val SC_ELEMENT_CARET_LINE_BACK=50
val SC_ELEMENT_WHITE_SPACE=60
+val SC_ELEMENT_WHITE_SPACE_BACK=61
# 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/src/EditView.cxx b/src/EditView.cxx
index 4a10f6584..7797236c8 100644
--- a/src/EditView.cxx
+++ b/src/EditView.cxx
@@ -1726,8 +1726,9 @@ void EditView::DrawBackground(Surface *surface, const EditModel &model, const Vi
if (ts.representation) {
if (ll->chars[i] == '\t') {
// Tab display
- if (drawWhitespaceBackground && vsDraw.WhiteSpaceVisible(inIndentation))
- textBack = *vsDraw.whitespaceBack;
+ if (drawWhitespaceBackground && vsDraw.WhiteSpaceVisible(inIndentation)) {
+ textBack = vsDraw.ElementColour(SC_ELEMENT_WHITE_SPACE_BACK)->Opaque();
+ }
} else {
// Blob display
inIndentation = false;
@@ -1745,7 +1746,8 @@ void EditView::DrawBackground(Surface *surface, const EditModel &model, const Vi
rcSegment.top,
ll->positions[cpos + ts.start + 1] + xStart - static_cast<XYPOSITION>(subLineStart),
rcSegment.bottom);
- surface->FillRectangleAligned(rcSpace, Fill(*vsDraw.whitespaceBack));
+ surface->FillRectangleAligned(rcSpace,
+ vsDraw.ElementColour(SC_ELEMENT_WHITE_SPACE_BACK)->Opaque());
}
} else {
inIndentation = false;
@@ -1972,7 +1974,7 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi
// Tab display
if (phasesDraw == PhasesDraw::one) {
if (drawWhitespaceBackground && vsDraw.WhiteSpaceVisible(inIndentation))
- textBack = *vsDraw.whitespaceBack;
+ textBack = vsDraw.ElementColour(SC_ELEMENT_WHITE_SPACE_BACK)->Opaque();
surface->FillRectangleAligned(rcSegment, Fill(textBack));
}
if (inIndentation && vsDraw.viewIndentationGuides == IndentView::real) {
@@ -2034,7 +2036,7 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi
if (vsDraw.WhiteSpaceVisible(inIndentation)) {
const XYPOSITION xmid = (ll->positions[cpos + ts.start] + ll->positions[cpos + ts.start + 1]) / 2;
if ((phasesDraw == PhasesDraw::one) && drawWhitespaceBackground) {
- textBack = *vsDraw.whitespaceBack;
+ textBack = vsDraw.ElementColour(SC_ELEMENT_WHITE_SPACE_BACK)->Opaque();
const PRectangle rcSpace(
ll->positions[cpos + ts.start] + xStart - static_cast<XYPOSITION>(subLineStart),
rcSegment.top,
@@ -2514,7 +2516,6 @@ Sci::Position EditView::FormatRange(bool draw, const Sci_RangeToFormat *pfr, Sur
// Don't show the selection when printing
vsPrint.elementColours.clear();
vsPrint.elementBaseColours.clear();
- vsPrint.whitespaceBack.reset();
vsPrint.caretLine.alwaysShow = false;
// Don't highlight matching braces using indicators
vsPrint.braceHighlightIndicatorSet = false;
diff --git a/src/Editor.cxx b/src/Editor.cxx
index 62cb170d3..9b5bfd6ee 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -7518,8 +7518,9 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
break;
case SCI_SETWHITESPACEBACK:
- vs.whitespaceBack = OptionalColour(wParam, lParam);
- InvalidateStyleRedraw();
+ if (vs.SetElementColourOptional(SC_ELEMENT_WHITE_SPACE_BACK, wParam, lParam)) {
+ InvalidateStyleRedraw();
+ }
break;
case SCI_SETSELECTIONLAYER:
diff --git a/src/ViewStyle.cxx b/src/ViewStyle.cxx
index 3785dec37..489758c71 100644
--- a/src/ViewStyle.cxx
+++ b/src/ViewStyle.cxx
@@ -108,7 +108,6 @@ ViewStyle::ViewStyle(const ViewStyle &source) : markers(MARKER_MAX + 1), indicat
textStart = source.textStart;
zoomLevel = source.zoomLevel;
viewWhitespace = source.viewWhitespace;
- whitespaceBack = source.whitespaceBack;
tabDrawMode = source.tabDrawMode;
whitespaceSize = source.whitespaceSize;
viewIndentationGuides = source.viewIndentationGuides;
@@ -265,7 +264,6 @@ void ViewStyle::Init(size_t stylesSize_) {
textStart = marginInside ? fixedColumnWidth : leftMarginWidth;
zoomLevel = 0;
viewWhitespace = WhiteSpace::invisible;
- whitespaceBack.reset();
tabDrawMode = TabDrawMode::longArrow;
whitespaceSize = 1;
elementColours.erase(SC_ELEMENT_WHITE_SPACE);
@@ -522,8 +520,8 @@ bool ViewStyle::SelectionTextDrawn() const {
ElementIsSet(SC_ELEMENT_SELECTION_NO_FOCUS_TEXT);
}
-bool ViewStyle::WhitespaceBackgroundDrawn() const noexcept {
- return (viewWhitespace != WhiteSpace::invisible) && (whitespaceBack);
+bool ViewStyle::WhitespaceBackgroundDrawn() const {
+ return (viewWhitespace != WhiteSpace::invisible) && (ElementIsSet(SC_ELEMENT_WHITE_SPACE_BACK));
}
bool ViewStyle::WhiteSpaceVisible(bool inIndent) const noexcept {
@@ -532,7 +530,7 @@ bool ViewStyle::WhiteSpaceVisible(bool inIndent) const noexcept {
viewWhitespace == WhiteSpace::visibleAlways;
}
-ColourAlpha ViewStyle::WrapColour() const noexcept {
+ColourAlpha ViewStyle::WrapColour() const {
return ElementColour(SC_ELEMENT_WHITE_SPACE).value_or(styles[STYLE_DEFAULT].fore);
}
diff --git a/src/ViewStyle.h b/src/ViewStyle.h
index b726cc559..cf8da4fe6 100644
--- a/src/ViewStyle.h
+++ b/src/ViewStyle.h
@@ -153,7 +153,6 @@ public:
int textStart; ///< Starting x position of text within the view
int zoomLevel;
WhiteSpace viewWhitespace;
- std::optional<ColourAlpha> whitespaceBack;
TabDrawMode tabDrawMode;
int whitespaceSize;
IndentView viewIndentationGuides;
@@ -220,8 +219,8 @@ public:
std::optional<ColourAlpha> Background(int marksOfLine, bool caretActive, bool lineContainsCaret) const;
bool SelectionBackgroundDrawn() const noexcept;
bool SelectionTextDrawn() const;
- bool WhitespaceBackgroundDrawn() const noexcept;
- ColourAlpha WrapColour() const noexcept;
+ bool WhitespaceBackgroundDrawn() const;
+ ColourAlpha WrapColour() const;
void AddMultiEdge(uptr_t wParam, sptr_t lParam);