diff options
| author | Neil <nyamatongwe@gmail.com> | 2019-07-05 11:33:53 +1000 | 
|---|---|---|
| committer | Neil <nyamatongwe@gmail.com> | 2019-07-05 11:33:53 +1000 | 
| commit | 0cb68d97ca50d7783b5b13008934baeb6c982929 (patch) | |
| tree | c35594d7d46f3f24e4f2f1a21bf9233bc06e9bac | |
| parent | 8205a8d93cbf38fd168648b53abe6c219bca970e (diff) | |
| download | scintilla-mirror-0cb68d97ca50d7783b5b13008934baeb6c982929.tar.gz | |
Add SetAppearance method to make changes to appearance settings and only perform
invalidation if the setting is actually changed.
| -rw-r--r-- | src/Editor.h | 13 | 
1 files changed, 13 insertions, 0 deletions
| diff --git a/src/Editor.h b/src/Editor.h index f16a46693..13e201169 100644 --- a/src/Editor.h +++ b/src/Editor.h @@ -598,6 +598,19 @@ protected:	// ScintillaBase subclass needs access to much of Editor  	static sptr_t StringResult(sptr_t lParam, const char *val) noexcept;  	static sptr_t BytesResult(sptr_t lParam, const unsigned char *val, size_t len) noexcept; +	// Set a variable controlling appearance to a value and invalidates the display +	// if a change was made. Avoids extra text and the possibility of mistyping. +	template <typename T> +	bool SetAppearance(T &variable, T value) { +		// Using ! and == as more types have == defined than !=. +		const bool changed = !(variable == value); +		if (changed) { +			variable = value; +			InvalidateStyleRedraw(); +		} +		return changed; +	} +  public:  	~Editor() override; | 
