diff options
| author | Jackson Moore <jacksonmoore@tuta.io> | 2026-09-04 14:18:34 +0200 |
|---|---|---|
| committer | Jackson Moore <jacksonmoore@tuta.io> | 2026-09-04 14:18:34 +0200 |
| commit | 5e2146af55a73b8d34596c2f28e6d7fc83a959ea (patch) | |
| tree | 54588fbe9c823795dbc300a670268efe9cc65a4d /lua | |
| parent | d1ba6bdac0924a5592e25e8bf80c595c1c05ce4c (diff) | |
Expose seven logical actions
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/clever_f/composition_root.lua | 45 |
1 files changed, 45 insertions, 0 deletions
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 |
