aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2021-03-29 08:25:51 +1100
committerNeil <nyamatongwe@gmail.com>2021-03-29 08:25:51 +1100
commitab70e1041cb40c9d807a18ca7abb5c000adf2fdf (patch)
tree709d60718e9cf33924a625f82ff7999494027f6f /src
parent508d037ed3389c5678addebefb62485ebfc10bb7 (diff)
downloadscintilla-mirror-ab70e1041cb40c9d807a18ca7abb5c000adf2fdf.tar.gz
Add SCI_SETELEMENTCOLOUR and related APIs to change colours of visible elements.
Implement SC_ELEMENT_LIST* to change colours of autocompletion lists.
Diffstat (limited to 'src')
-rw-r--r--src/EditModel.cxx1
-rw-r--r--src/EditView.cxx1
-rw-r--r--src/Editor.cxx18
-rw-r--r--src/MarginView.cxx1
-rw-r--r--src/Platform.h4
-rw-r--r--src/PositionCache.cxx1
-rw-r--r--src/ScintillaBase.cxx9
-rw-r--r--src/ViewStyle.cxx15
-rw-r--r--src/ViewStyle.h6
9 files changed, 56 insertions, 0 deletions
diff --git a/src/EditModel.cxx b/src/EditModel.cxx
index 58b9306a2..11827c471 100644
--- a/src/EditModel.cxx
+++ b/src/EditModel.cxx
@@ -16,6 +16,7 @@
#include <string_view>
#include <vector>
#include <map>
+#include <set>
#include <optional>
#include <algorithm>
#include <memory>
diff --git a/src/EditView.cxx b/src/EditView.cxx
index f22b281c5..b2714f7ac 100644
--- a/src/EditView.cxx
+++ b/src/EditView.cxx
@@ -17,6 +17,7 @@
#include <string_view>
#include <vector>
#include <map>
+#include <set>
#include <forward_list>
#include <optional>
#include <algorithm>
diff --git a/src/Editor.cxx b/src/Editor.cxx
index ad56a8eb8..fa356fe15 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -17,6 +17,7 @@
#include <string_view>
#include <vector>
#include <map>
+#include <set>
#include <forward_list>
#include <optional>
#include <algorithm>
@@ -7185,6 +7186,23 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
InvalidateStyleRedraw();
break;
+ case SCI_SETELEMENTCOLOUR:
+ vs.elementColours[static_cast<int>(wParam)] = ColourAlpha(static_cast<int>(lParam));
+ break;
+
+ case SCI_GETELEMENTCOLOUR:
+ return vs.ElementColour(static_cast<int>(wParam)).value_or(ColourAlpha()).AsInteger();
+
+ case SCI_RESETELEMENTCOLOUR:
+ vs.elementColours[static_cast<int>(wParam)].reset();
+ break;
+
+ case SCI_GETELEMENTISSET:
+ return vs.ElementColour(static_cast<int>(wParam)).has_value();
+
+ case SCI_GETELEMENTALLOWSTRANSLUCENT:
+ return vs.ElementAllowsTranslucent(static_cast<int>(wParam));
+
#ifdef INCLUDE_DEPRECATED_FEATURES
case SCI_SETSTYLEBITS:
vs.EnsureStyle(0xff);
diff --git a/src/MarginView.cxx b/src/MarginView.cxx
index 7c7998e07..8b6f80695 100644
--- a/src/MarginView.cxx
+++ b/src/MarginView.cxx
@@ -17,6 +17,7 @@
#include <string_view>
#include <vector>
#include <map>
+#include <set>
#include <optional>
#include <algorithm>
#include <memory>
diff --git a/src/Platform.h b/src/Platform.h
index 98e6440aa..ffe52446c 100644
--- a/src/Platform.h
+++ b/src/Platform.h
@@ -304,6 +304,10 @@ public:
};
struct ListOptions {
+ std::optional<ColourAlpha> fore;
+ std::optional<ColourAlpha> back;
+ std::optional<ColourAlpha> foreSelected;
+ std::optional<ColourAlpha> backSelected;
};
class ListBox : public Window {
diff --git a/src/PositionCache.cxx b/src/PositionCache.cxx
index 50858edd7..c9b886119 100644
--- a/src/PositionCache.cxx
+++ b/src/PositionCache.cxx
@@ -15,6 +15,7 @@
#include <string_view>
#include <vector>
#include <map>
+#include <set>
#include <optional>
#include <algorithm>
#include <iterator>
diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx
index 1e55fcfbf..e2fb58206 100644
--- a/src/ScintillaBase.cxx
+++ b/src/ScintillaBase.cxx
@@ -15,6 +15,7 @@
#include <string_view>
#include <vector>
#include <map>
+#include <set>
#include <optional>
#include <algorithm>
#include <memory>
@@ -260,6 +261,14 @@ void ScintillaBase::AutoCompleteStart(Sci::Position lenEntered, const char *list
ac.Start(wMain, idAutoComplete, sel.MainCaret(), PointMainCaret(),
lenEntered, vs.lineHeight, IsUnicodeMode(), technology);
+ ListOptions options{
+ vs.ElementColour(SC_ELEMENT_LIST),
+ vs.ElementColour(SC_ELEMENT_LIST_BACK),
+ vs.ElementColour(SC_ELEMENT_LIST_SELECTED),
+ vs.ElementColour(SC_ELEMENT_LIST_SELECTED_BACK)
+ };
+ ac.lb->SetOptions(options);
+
const PRectangle rcClient = GetClientRectangle();
Point pt = LocationFromPosition(sel.MainCaret() - lenEntered);
PRectangle rcPopupBounds = wMain.GetMonitorRect(pt);
diff --git a/src/ViewStyle.cxx b/src/ViewStyle.cxx
index d1f866906..6aa459895 100644
--- a/src/ViewStyle.cxx
+++ b/src/ViewStyle.cxx
@@ -13,6 +13,7 @@
#include <string_view>
#include <vector>
#include <map>
+#include <set>
#include <optional>
#include <algorithm>
#include <memory>
@@ -517,6 +518,20 @@ void ViewStyle::AddMultiEdge(uptr_t wParam, sptr_t lParam) {
EdgeProperties(column, lParam));
}
+std::optional<ColourAlpha> ViewStyle::ElementColour(int index) const noexcept {
+ auto search = elementColours.find(index);
+ if (search != elementColours.end()) {
+ if (search->second.has_value()) {
+ return search->second;
+ }
+ }
+ return {};
+}
+
+bool ViewStyle::ElementAllowsTranslucent(int index) const noexcept {
+ return elementAllowsTranslucent.count(index) > 0;
+}
+
bool ViewStyle::SetWrapState(int wrapState_) noexcept {
WrapMode wrapStateWanted;
switch (wrapState_) {
diff --git a/src/ViewStyle.h b/src/ViewStyle.h
index b07c34a08..d33feb485 100644
--- a/src/ViewStyle.h
+++ b/src/ViewStyle.h
@@ -158,6 +158,9 @@ public:
int ctrlCharPadding; // the padding around control character text blobs
int lastSegItalicsOffset; // the offset so as not to clip italic characters at EOLs
+ std::map<int, std::optional<ColourAlpha>> elementColours;
+ std::set<int> elementAllowsTranslucent;
+
// Wrapping support
WrapMode wrapState;
int wrapVisualFlags;
@@ -195,6 +198,9 @@ public:
void AddMultiEdge(uptr_t wParam, sptr_t lParam);
+ std::optional<ColourAlpha> ElementColour(int index) const noexcept;
+ bool ElementAllowsTranslucent(int index) const noexcept;
+
bool SetWrapState(int wrapState_) noexcept;
bool SetWrapVisualFlags(int wrapVisualFlags_) noexcept;
bool SetWrapVisualFlagsLocation(int wrapVisualFlagsLocation_) noexcept;