From 7f94250659318b6a828cd122e69e81e131c3380d Mon Sep 17 00:00:00 2001 From: Neil Date: Fri, 5 Jul 2019 11:33:53 +1000 Subject: Backport: Add SetAppearance method to make changes to appearance settings and only perform invalidation if the setting is actually changed. Backport of changeset 7699:ed73f7607752. --- src/Editor.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/Editor.h') diff --git a/src/Editor.h b/src/Editor.h index 4077fa1a4..54c50363d 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 + 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; -- cgit v1.2.3