diff options
-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; |