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
main
Daniel Barlow 2022-12-31 13:36:25 +00:00
parent b8d86c65cb
commit cc2caae372
1 changed files with 8 additions and 4 deletions

View File

@ -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)
{