From 5e2146af55a73b8d34596c2f28e6d7fc83a959ea Mon Sep 17 00:00:00 2001 From: Jackson Moore Date: Fri, 4 Sep 2026 14:18:34 +0200 Subject: Expose seven logical actions --- lua/clever_f/composition_root.lua | 45 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'lua/clever_f') diff --git a/lua/clever_f/composition_root.lua b/lua/clever_f/composition_root.lua index ecd1047..83cfe96 100644 --- a/lua/clever_f/composition_root.lua +++ b/lua/clever_f/composition_root.lua @@ -10,6 +10,39 @@ local M = {} local CompositionRoot = {} CompositionRoot.__index = CompositionRoot M.CompositionRoot = CompositionRoot +M.ACTION_NAMES = { + "StartFindForward", + "StartFindBackward", + "StartTillForward", + "StartTillBackward", + "Reset", + "RepeatSameDirection", + "RepeatOppositeDirection", +} + +local ACTION_INVOCATIONS = { + StartFindForward = function(facade) + return facade:primary("f") + end, + StartFindBackward = function(facade) + return facade:primary("F") + end, + StartTillForward = function(facade) + return facade:primary("t") + end, + StartTillBackward = function(facade) + return facade:primary("T") + end, + Reset = function(facade) + return facade:reset() + end, + RepeatSameDirection = function(facade) + return facade:repeat_same_direction() + end, + RepeatOppositeDirection = function(facade) + return facade:repeat_opposite_direction() + end, +} local root_records = setmetatable({}, { __mode = "k" }) @@ -80,6 +113,17 @@ function CompositionRoot.is(value) return type(value) == "table" and root_records[value] ~= nil end +local function register_logical_actions(record) + local registrations = {} + for _, name in ipairs(M.ACTION_NAMES) do + local invoke = ACTION_INVOCATIONS[name] + registrations[name] = record.host:register_action(name, function(...) + return invoke(record.facade, ...) + end) + end + return registrations +end + function CompositionRoot:activate() local record = root_records[self] if record.activation == nil then @@ -97,6 +141,7 @@ function CompositionRoot:activate() feedback = feedback_activation, highlights = highlights, colorscheme_registration = colorscheme_registration, + actions = register_logical_actions(record), } end return record.activation -- cgit v1.2.3