aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2021-05-11 10:06:28 +1000
committerNeil <nyamatongwe@gmail.com>2021-05-11 10:06:28 +1000
commit002f1a013736a89223dc1ede2724f8492e12ce1f (patch)
tree26232075fd5f586fae60fc75f8f97dd811855115
parent59052f9ae48d6e24a270303d9f2af4097ca62086 (diff)
downloadscintilla-mirror-002f1a013736a89223dc1ede2724f8492e12ce1f.tar.gz
Implement SCI_GETELEMENTBASECOLOUR to return the default values for element
colours.
-rw-r--r--doc/ScintillaDoc.html15
-rw-r--r--doc/ScintillaHistory.html3
-rw-r--r--include/Scintilla.h1
-rw-r--r--include/Scintilla.iface3
-rw-r--r--src/Editor.cxx3
-rw-r--r--test/simpleTests.py28
6 files changed, 46 insertions, 7 deletions
diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html
index 7e120c44c..fcce51dd0 100644
--- a/doc/ScintillaDoc.html
+++ b/doc/ScintillaDoc.html
@@ -128,7 +128,7 @@
<h1>Scintilla Documentation</h1>
- <p>Last edited 10 May 2021 NH</p>
+ <p>Last edited 11 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 />
@@ -3247,6 +3247,7 @@ struct Sci_TextToFind {
<a class="message" href="#SCI_RESETELEMENTCOLOUR">SCI_RESETELEMENTCOLOUR(int element)</a><br />
<a class="message" href="#SCI_GETELEMENTISSET">SCI_GETELEMENTISSET(int element) &rarr; bool</a><br />
<a class="message" href="#SCI_GETELEMENTALLOWSTRANSLUCENT">SCI_GETELEMENTALLOWSTRANSLUCENT(int element) &rarr; bool</a><br />
+ <a class="message" href="#SCI_GETELEMENTBASECOLOUR">SCI_GETELEMENTBASECOLOUR(int element) &rarr; colouralpha</a><br />
</code>
<p>
@@ -3275,6 +3276,18 @@ struct Sci_TextToFind {
and newer versions of Scintilla may implement translucency for elements that did not previously support it.
</p>
+ <p>
+ <b id="SCI_GETELEMENTBASECOLOUR">SCI_GETELEMENTBASECOLOUR(int element) &rarr; colouralpha</b><br />
+ Returns the default colour of an element.
+ This may be a value defined by Scintilla or it may be derived from the operating system or platform.
+ Which values are set from the operating system may differ between operating systems and operating system versions.
+ 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>
+
<table class="standard" summary="Elements">
<thead align="left">
<tr>
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html
index bf43a17b6..64260aa88 100644
--- a/doc/ScintillaHistory.html
+++ b/doc/ScintillaHistory.html
@@ -586,6 +586,9 @@
translucently over text or opaquely underneath other drawing.
</li>
<li>
+ Add SCI_GETELEMENTBASECOLOUR to return the default values for element colours.
+ </li>
+ <li>
Make idle actions wrapping and background styling smoother by
measuring per-byte instead of per-line and allowing just one line to be
processed in a time slice.
diff --git a/include/Scintilla.h b/include/Scintilla.h
index 1a352ae85..820dc470a 100644
--- a/include/Scintilla.h
+++ b/include/Scintilla.h
@@ -289,6 +289,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SCI_RESETELEMENTCOLOUR 2755
#define SCI_GETELEMENTISSET 2756
#define SCI_GETELEMENTALLOWSTRANSLUCENT 2757
+#define SCI_GETELEMENTBASECOLOUR 2758
#define SCI_SETSELFORE 2067
#define SCI_SETSELBACK 2068
#define SCI_GETSELALPHA 2477
diff --git a/include/Scintilla.iface b/include/Scintilla.iface
index ac5a72346..a51c0d611 100644
--- a/include/Scintilla.iface
+++ b/include/Scintilla.iface
@@ -705,6 +705,9 @@ get bool GetElementIsSet=2756(Element element,)
# Get whether an element supports translucency.
get bool GetElementAllowsTranslucent=2757(Element element,)
+# Get the colour of an element.
+get colouralpha GetElementBaseColour=2758(Element element,)
+
# Set the foreground colour of the main and additional selections and whether to use this setting.
fun void SetSelFore=2067(bool useSetting, colour fore)
diff --git a/src/Editor.cxx b/src/Editor.cxx
index 17749d799..458d34ccf 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -7212,6 +7212,9 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_GETELEMENTALLOWSTRANSLUCENT:
return vs.ElementAllowsTranslucent(static_cast<int>(wParam));
+ case SCI_GETELEMENTBASECOLOUR:
+ return vs.elementBaseColours[static_cast<int>(wParam)].value_or(ColourAlpha()).AsInteger();
+
case SCI_SETFONTLOCALE:
if (lParam) {
vs.SetFontLocaleName(CharPtrFromSPtr(lParam));
diff --git a/test/simpleTests.py b/test/simpleTests.py
index d6c00170c..0f3516553 100644
--- a/test/simpleTests.py
+++ b/test/simpleTests.py
@@ -1938,7 +1938,7 @@ class TestElements(unittest.TestCase):
pass
def testIsSet(self):
- self.assertEquals(self.ed.GetElementIsSet(self.ed.SC_ELEMENT_LIST), 0)
+ self.assertEquals(self.ed.GetElementIsSet(self.ed.SC_ELEMENT_SELECTION_TEXT), 0)
def testAllowsTranslucent(self):
self.assertEquals(self.ed.GetElementAllowsTranslucent(self.ed.SC_ELEMENT_LIST), 0)
@@ -1950,11 +1950,27 @@ class TestElements(unittest.TestCase):
self.assertEquals(self.ed.GetElementIsSet(self.ed.SC_ELEMENT_LIST_BACK), 1)
def testReset(self):
- self.ed.SetElementColour(self.ed.SC_ELEMENT_LIST_BACK, self.testColourAlpha)
- self.assertEquals(self.ed.GetElementColour(self.ed.SC_ELEMENT_LIST_BACK), self.testColourAlpha)
- self.ed.ResetElementColour(self.ed.SC_ELEMENT_LIST_BACK)
- self.assertEquals(self.ed.GetElementColour(self.ed.SC_ELEMENT_LIST_BACK), 0)
- self.assertEquals(self.ed.GetElementIsSet(self.ed.SC_ELEMENT_LIST_BACK), 0)
+ self.ed.SetElementColour(self.ed.SC_ELEMENT_SELECTION_ADDITIONAL_TEXT, self.testColourAlpha)
+ self.assertEquals(self.ed.GetElementColour(self.ed.SC_ELEMENT_SELECTION_ADDITIONAL_TEXT), self.testColourAlpha)
+ self.ed.ResetElementColour(self.ed.SC_ELEMENT_SELECTION_ADDITIONAL_TEXT)
+ self.assertEquals(self.ed.GetElementColour(self.ed.SC_ELEMENT_SELECTION_ADDITIONAL_TEXT), 0)
+ self.assertEquals(self.ed.GetElementIsSet(self.ed.SC_ELEMENT_SELECTION_ADDITIONAL_TEXT), 0)
+
+ def testBaseColour(self):
+ if sys.platform == "win32":
+ # SC_ELEMENT_LIST* base colours only currently implemented on Win32
+ opaque = 0xff000000
+ dropAlpha = 0x00ffffff
+ text = self.ed.GetElementBaseColour(self.ed.SC_ELEMENT_LIST)
+ back = self.ed.GetElementBaseColour(self.ed.SC_ELEMENT_LIST_BACK)
+ self.assertEquals(text & opaque, opaque)
+ self.assertEquals(back & opaque, opaque)
+ self.assertNotEquals(text & dropAlpha, back & dropAlpha)
+ selText = self.ed.GetElementBaseColour(self.ed.SC_ELEMENT_LIST_SELECTED)
+ selBack = self.ed.GetElementBaseColour(self.ed.SC_ELEMENT_LIST_SELECTED_BACK)
+ self.assertEquals(selText & opaque, opaque)
+ self.assertEquals(selBack & opaque, opaque)
+ self.assertNotEquals(selText & dropAlpha, selBack & dropAlpha)
class TestIndices(unittest.TestCase):
def setUp(self):