From 6e69d3d53ee9037dd8bedb1267413937f9a7e817 Mon Sep 17 00:00:00 2001 From: Jackson Moore Date: Fri, 4 Sep 2026 13:33:32 +0200 Subject: Read primary invocation state --- lua/clever_f/sequence_coordinator.lua | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'lua/clever_f') 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 -- cgit v1.2.3