diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/Editor.cxx | 6 | ||||
| -rw-r--r-- | src/Editor.h | 1 | ||||
| -rw-r--r-- | src/ViewStyle.cxx | 32 | ||||
| -rw-r--r-- | src/ViewStyle.h | 4 | 
4 files changed, 42 insertions, 1 deletions
diff --git a/src/Editor.cxx b/src/Editor.cxx index f843a08d2..477173c6b 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -5089,6 +5089,10 @@ void Editor::SetFocusState(bool focusState) {  	ShowCaretAtCurrentPosition();  } +void Editor::UpdateBaseElements() { +	// Overridden by subclasses +} +  Sci::Position Editor::PositionAfterArea(PRectangle rcArea) const {  	// The start of the document line after the display line after the area  	// This often means that the line after a modification is restyled which helps @@ -7199,7 +7203,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {  		return vs.ElementColour(static_cast<int>(wParam)).value_or(ColourAlpha()).OpaqueRGB();  	case SCI_RESETELEMENTCOLOUR: -		vs.elementColours[static_cast<int>(wParam)].reset(); +		vs.ResetElement(static_cast<int>(wParam));  		break;  	case SCI_GETELEMENTISSET: diff --git a/src/Editor.h b/src/Editor.h index ae3f0ef5a..42944929b 100644 --- a/src/Editor.h +++ b/src/Editor.h @@ -526,6 +526,7 @@ protected:	// ScintillaBase subclass needs access to much of Editor  	virtual void SetMouseCapture(bool on) = 0;  	virtual bool HaveMouseCapture() = 0;  	void SetFocusState(bool focusState); +	virtual void UpdateBaseElements();  	Sci::Position PositionAfterArea(PRectangle rcArea) const;  	void StyleToPositionInView(Sci::Position pos); diff --git a/src/ViewStyle.cxx b/src/ViewStyle.cxx index 58af810b8..16701983e 100644 --- a/src/ViewStyle.cxx +++ b/src/ViewStyle.cxx @@ -523,6 +523,12 @@ std::optional<ColourAlpha> ViewStyle::ElementColour(int element) const {  			return search->second;  		}  	} +	ElementMap::const_iterator searchBase = elementBaseColours.find(element); +	if (searchBase != elementBaseColours.end()) { +		if (searchBase->second.has_value()) { +			return searchBase->second; +		} +	}  	return {};  } @@ -530,6 +536,32 @@ bool ViewStyle::ElementAllowsTranslucent(int element) const {  	return elementAllowsTranslucent.count(element) > 0;  } +void ViewStyle::ResetElement(int element) { +	elementColours.erase(element); +} + +bool ViewStyle::ElementIsSet(int element) const { +	ElementMap::const_iterator search = elementColours.find(element); +	if (search != elementColours.end()) { +		return search->second.has_value(); +	} +	return false; +} + +bool ViewStyle::SetElementBase(int element, ColourAlpha colour) { +	bool different = false; +	ElementMap::const_iterator search = elementBaseColours.find(element); +	if (search == elementBaseColours.end()) { +		different = true; +	} else { +		if (search->second.has_value() && !(*search->second == colour)) { +			different = true; +		} +	} +	elementBaseColours[element] = colour; +	return different; +} +  bool ViewStyle::SetWrapState(int wrapState_) noexcept {  	WrapMode wrapStateWanted;  	switch (wrapState_) { diff --git a/src/ViewStyle.h b/src/ViewStyle.h index 4118f0daf..a9fe58131 100644 --- a/src/ViewStyle.h +++ b/src/ViewStyle.h @@ -203,6 +203,7 @@ public:  	using ElementMap = std::map<int, std::optional<ColourAlpha>>;  	ElementMap elementColours; +	ElementMap elementBaseColours;  	std::set<int> elementAllowsTranslucent;  	WrapAppearance wrap; @@ -243,6 +244,9 @@ public:  	std::optional<ColourAlpha> ElementColour(int element) const;  	bool ElementAllowsTranslucent(int element) const; +	void ResetElement(int element); +	bool ElementIsSet(int element) const; +	bool SetElementBase(int element, ColourAlpha colour);  	bool SetWrapState(int wrapState_) noexcept;  	bool SetWrapVisualFlags(int wrapVisualFlags_) noexcept;  | 
