From cc2caae3720d90f50e2dc188866070caf5b6ba6f Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Sat, 31 Dec 2022 13:36:25 +0000 Subject: [PATCH] all commands are called with frame as well as declared params the commander is per-frame, so this is in the nature of a "context" parameter --- command.fnl | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/command.fnl b/command.fnl index ade0c84..c636be3 100644 --- a/command.fnl +++ b/command.fnl @@ -1,5 +1,6 @@ (local { : Gtk } (require :lgi)) (local { : view } (require :fennel)) +(local lume (require :lume)) (local commands {}) @@ -50,8 +51,9 @@ (fn invoke-command [command params] (command.function params)) -(fn next-action [state input-string] - (let [state-for-next-param +(fn next-action [self input-string] + (let [state self.state + state-for-next-param (fn [c params] (match (next-param c params) k1 { @@ -60,7 +62,9 @@ :collected-params params :active true } - _ (do (invoke-command c params) {:active false})))] + _ (let [params (lume.extend {} {:frame self.frame} params)] + (invoke-command c params) + {:active false})))] (match state {:active false} state @@ -92,7 +96,7 @@ ))) (fn on-activate [self str] - (let [s (next-action self.state str) + (let [s (next-action self str) param (if s.active (. (. s.command :params) s.this-param))] (set self.state s) {