diff --git a/src/data/keyword.cpp b/src/data/keyword.cpp index 000cb4e4..683bcc2b 100644 --- a/src/data/keyword.cpp +++ b/src/data/keyword.cpp @@ -14,7 +14,7 @@ IMPLEMENT_REFLECTION(KeywordParam) { REFLECT(name); REFLECT(description); REFLECT(match); - REFLECT(in_reminder); + REFLECT(script); } IMPLEMENT_REFLECTION(KeywordMode) { REFLECT(name); @@ -25,8 +25,32 @@ IMPLEMENT_REFLECTION(KeywordExpansion) { REFLECT(after); REFLECT(reminder); } + +// backwards compatability +template void read_compat(T&, const Keyword*) {} +void read_compat(Reader& tag, Keyword* k) { + String separator, parameter, reminder; + REFLECT(separator); + REFLECT(parameter); + REFLECT(reminder); + if (!separator.empty() || !parameter.empty() || !reminder.empty()) { + // old style keyword declaration, no separate expansion + KeywordExpansionP e(new KeywordExpansion); + size_t start = separator.find_first_of('['); + size_t end = separator.find_first_of(']'); + if (start != String.npos && end != String.npos) { + e->after += separator.substr(start + 1, end - start - 1); + } + if (!parameter.empty()) { + e->after += _("") + parameter + _(""); + } + e->reminder.set(reminder); + } +} + IMPLEMENT_REFLECTION(Keyword) { REFLECT(keyword); + read_compat(tag, this); REFLECT(expansions); REFLECT(rules); REFLECT(mode); diff --git a/src/data/keyword.hpp b/src/data/keyword.hpp index 9e858825..540a9126 100644 --- a/src/data/keyword.hpp +++ b/src/data/keyword.hpp @@ -26,7 +26,7 @@ class KeywordParam { String description; ///< Description of the type String match; ///< Uncompiled regex wxRegEx matchRe; ///< Regular expression to match - OptionalScript in_reminder; ///< Transformation of the value for showing in the reminder text + OptionalScript script; ///< Transformation of the value for showing in the reminder text DECLARE_REFLECTION(); }; @@ -50,7 +50,7 @@ class KeywordExpansion { String after; ///< Components after the keyword: parameters and separators vector parameters; ///< The types of parameters wxRegEx splitter; ///< Regular expression to split/match the components, automatically generated - OptionalScript reminder; ///< Reminder text of the keyword + StringScript reminder; ///< Reminder text of the keyword DECLARE_REFLECTION(); }; diff --git a/src/data/settings.cpp b/src/data/settings.cpp index 06f20fd4..4705a0de 100644 --- a/src/data/settings.cpp +++ b/src/data/settings.cpp @@ -13,9 +13,10 @@ #include #include #include +#include