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 | 7f94250659318b6a828cd122e69e81e131c3380d (patch) | |
| tree | 1ef122bae4ba8c4dd0f16b970a5fdbda990b348b /src | |
| parent | 90d51fc95c2529a79a6be24832a835b4cac3be5d (diff) | |
| download | scintilla-mirror-7f94250659318b6a828cd122e69e81e131c3380d.tar.gz | |
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.
Diffstat (limited to 'src')
| -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 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 <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; |
