mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 21:06:59 -04:00
Fixed undo issue for combined editor;
Added keyword usage statistics git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@516 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -17,6 +17,8 @@ DECLARE_TYPEOF_COLLECTION(KeywordModeP);
|
||||
DECLARE_TYPEOF_COLLECTION(KeywordParamP);
|
||||
DECLARE_TYPEOF_COLLECTION(const Keyword*);
|
||||
DECLARE_POINTER_TYPE(KeywordParamValue);
|
||||
class Value;
|
||||
DECLARE_DYNAMIC_ARG(Value*, value_being_updated);
|
||||
|
||||
// ----------------------------------------------------------------------------- : Reflection
|
||||
|
||||
@@ -329,6 +331,8 @@ KeywordTrie* KeywordTrie::insertAnyStar() {
|
||||
|
||||
// ----------------------------------------------------------------------------- : KeywordDatabase
|
||||
|
||||
IMPLEMENT_DYNAMIC_ARG(KeywordUsageStatistics*, keyword_usage_statistics, nullptr);
|
||||
|
||||
KeywordDatabase::KeywordDatabase()
|
||||
: root(nullptr)
|
||||
{}
|
||||
@@ -440,6 +444,17 @@ String KeywordDatabase::expand(const String& text,
|
||||
Context& ctx) const {
|
||||
assert(combine_script);
|
||||
|
||||
// Clean up usage statistics
|
||||
KeywordUsageStatistics* stat = keyword_usage_statistics();
|
||||
Value* stat_key = value_being_updated();
|
||||
if (stat && stat_key) {
|
||||
for (size_t i = stat->size() - 1 ; i + 1 > 0 ; --i) { // loop backwards
|
||||
if ((*stat)[i].first == stat_key) {
|
||||
stat->erase(stat->begin() + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Remove all old reminder texts
|
||||
String s = remove_tag_contents(text, _("<atom-reminder"));
|
||||
s = remove_tag_contents(s, _("<atom-keyword")); // OLD, TODO: REMOVEME
|
||||
@@ -614,6 +629,11 @@ String KeywordDatabase::expand(const String& text,
|
||||
result += _("</kw-"); result += expand_type; result += _(">");
|
||||
}
|
||||
|
||||
// Add to usage statistics
|
||||
if (stat && stat_key) {
|
||||
stat->push_back(make_pair(stat_key, kw));
|
||||
}
|
||||
|
||||
// After keyword
|
||||
s = s.substr(end);
|
||||
untagged = untagged.substr(start_u + len_u);
|
||||
|
||||
Reference in New Issue
Block a user