diff options
| -rw-r--r-- | src/Editor.cxx | 8 | ||||
| -rw-r--r-- | src/ViewStyle.cxx | 27 | ||||
| -rw-r--r-- | src/ViewStyle.h | 3 | 
3 files changed, 25 insertions, 13 deletions
| diff --git a/src/Editor.cxx b/src/Editor.cxx index 458d34ccf..35ca7bb77 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -7196,14 +7196,18 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {  		break;  	case SCI_SETELEMENTCOLOUR: -		vs.elementColours[static_cast<int>(wParam)] = ColourAlpha(static_cast<int>(lParam)); +		if (vs.SetElementColour(static_cast<int>(wParam), ColourAlpha(static_cast<int>(lParam)))) { +			InvalidateStyleRedraw(); +		}  		break;  	case SCI_GETELEMENTCOLOUR:  		return vs.ElementColour(static_cast<int>(wParam)).value_or(ColourAlpha()).AsInteger();  	case SCI_RESETELEMENTCOLOUR: -		vs.ResetElement(static_cast<int>(wParam)); +		if (vs.ResetElement(static_cast<int>(wParam))) { +			InvalidateStyleRedraw(); +		}  		break;  	case SCI_GETELEMENTISSET: diff --git a/src/ViewStyle.cxx b/src/ViewStyle.cxx index 4d555b1c2..a8fcd2d8c 100644 --- a/src/ViewStyle.cxx +++ b/src/ViewStyle.cxx @@ -560,8 +560,20 @@ bool ViewStyle::ElementAllowsTranslucent(int element) const {  	return elementAllowsTranslucent.count(element) > 0;  } -void ViewStyle::ResetElement(int element) { +bool ViewStyle::ResetElement(int element) { +	ElementMap::const_iterator search = elementColours.find(element); +	const bool changed = (search != elementColours.end()) && (search->second.has_value());  	elementColours.erase(element); +	return changed; +} + +bool ViewStyle::SetElementColour(int element, ColourAlpha colour) { +	ElementMap::const_iterator search = elementColours.find(element); +	const bool changed = +		(search == elementColours.end()) || +		(search->second.has_value() && !(*search->second == colour)); +	elementColours[element] = colour; +	return changed;  }  void ViewStyle::SetElementRGB(int element, int rgb) { @@ -583,17 +595,12 @@ bool ViewStyle::ElementIsSet(int element) const {  }  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; -		} -	} +	const bool changed = +		(search == elementBaseColours.end()) || +		(search->second.has_value() && !(*search->second == colour));  	elementBaseColours[element] = colour; -	return different; +	return changed;  }  bool ViewStyle::SetWrapState(int wrapState_) noexcept { diff --git a/src/ViewStyle.h b/src/ViewStyle.h index 6aab53f64..13c489aa2 100644 --- a/src/ViewStyle.h +++ b/src/ViewStyle.h @@ -233,7 +233,8 @@ public:  	std::optional<ColourAlpha> ElementColour(int element) const;  	bool ElementAllowsTranslucent(int element) const; -	void ResetElement(int element); +	bool ResetElement(int element); +	bool SetElementColour(int element, ColourAlpha colour);  	void SetElementRGB(int element, int rgb);  	void SetElementAlpha(int element, int alpha);  	bool ElementIsSet(int element) const; | 
