summaryrefslogtreecommitdiff
path: root/lua/clever_f/sequence_coordinator.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/clever_f/sequence_coordinator.lua')
-rw-r--r--lua/clever_f/sequence_coordinator.lua27
1 files changed, 27 insertions, 0 deletions
diff --git a/lua/clever_f/sequence_coordinator.lua b/lua/clever_f/sequence_coordinator.lua
index 0da3ef3..10949bd 100644
--- a/lua/clever_f/sequence_coordinator.lua
+++ b/lua/clever_f/sequence_coordinator.lua
@@ -48,6 +48,33 @@ function SequenceCoordinator:validate_primary_descriptor(value)
return M.validate_primary_descriptor(value)
end
+local function require_primary_reader(host)
+ if type(host) ~= "table"
+ or type(host.read_mode) ~= "function"
+ or type(host.read_cursor) ~= "function"
+ or type(host.read_count) ~= "function"
+ or type(host.read_macro_state) ~= "function"
+ then
+ fail("SequenceCoordinator host must provide primary action state", 3)
+ end
+ return host
+end
+
+function SequenceCoordinator:read_primary_invocation()
+ local host = require_primary_reader(coordinator_records[self].host)
+ local context = domain.ModeContext.from_full_mode(host:read_mode())
+ local position = domain.Position.coerce(host:read_cursor())
+ local count = domain.Count.new(host:read_count())
+ local macro_state = domain.MacroState.new(host:read_macro_state())
+ return {
+ context = context,
+ position = position,
+ origin = position,
+ count = count,
+ macro_state = macro_state,
+ }
+end
+
function SequenceCoordinator:primary(value)
return self:validate_primary_descriptor(value)
end