diff --git a/core/src/mock/mock_processor.cpp b/core/src/mock/mock_processor.cpp index 570553264d..5da42206fa 100644 --- a/core/src/mock/mock_processor.cpp +++ b/core/src/mock/mock_processor.cpp @@ -125,8 +125,16 @@ namespace km { { assert(state); assert(action_item); - if ((!state) || (!action_item)) + if ((!state) || (!action_item)) { return false; + } + // For this mock processor we only support queuing PERSIST_OPT action items. + if (action_item->type == KM_CORE_IT_PERSIST_OPT && action_item->option) { + state->actions().push_persist(update_option(static_cast(action_item->option->scope), + action_item->option->key, + action_item->option->value)); + return true; + } return false; } @@ -166,6 +174,18 @@ namespace km { u"F2 pressed test save.")); break; } + case KM_CORE_VKEY_F3: + { + state->actions().push_persist( + update_option(KM_CORE_OPT_KEYBOARD, + u"__test_point_3", + u"F3 pressed test save 1.")); + state->actions().push_persist( + update_option(KM_CORE_OPT_KEYBOARD, + u"__test_point_4", + u"F3 pressed test save 2.")); + break; + } case KM_CORE_VKEY_F4: state->context().push_marker(KM_CORE_VKEY_QUOTE); diff --git a/core/src/state.cpp b/core/src/state.cpp index 8eb99d1b0a..3bf9efb358 100644 --- a/core/src/state.cpp +++ b/core/src/state.cpp @@ -36,6 +36,23 @@ void actions::push_capslock(bool turnOn) { emplace_back(std::move(ai)); } +actions::actions(actions const &other) +: std::vector(other) +, _option_items_stack(other._option_items_stack) +{ + // Update all option pointers to point to the new stack. + size_t opt_index = 0; + for (auto &item : *this) { + if (item.type == KM_CORE_IT_PERSIST_OPT) { + if (opt_index < _option_items_stack.size()) { + item.option = &_option_items_stack[opt_index++]; + } else { + // no matching item in the stack; clear pointer. + item.option = nullptr; + } + } + } +} state::state(km::core::abstract_processor & ap, km_core_option_item const *env) : _processor(ap) diff --git a/core/src/state.hpp b/core/src/state.hpp index da2cf6bb75..15210a3a60 100644 --- a/core/src/state.hpp +++ b/core/src/state.hpp @@ -10,6 +10,7 @@ #include #include +#include #include "keyman_core.h" @@ -27,7 +28,7 @@ using action = km_core_action_item; class actions : public std::vector { - std::vector