commit cc2caae3720d90f50e2dc188866070caf5b6ba6f
parent b8d86c65cb083fce2cd3aed79511e6e7c1385bf2
Author: Daniel Barlow <dan@telent.net>
Date: Sat, 31 Dec 2022 13:36:25 +0000
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
Diffstat:
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git 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)
{