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
This commit is contained in:
parent
b8d86c65cb
commit
cc2caae372
12
command.fnl
12
command.fnl
@ -1,5 +1,6 @@
|
|||||||
(local { : Gtk } (require :lgi))
|
(local { : Gtk } (require :lgi))
|
||||||
(local { : view } (require :fennel))
|
(local { : view } (require :fennel))
|
||||||
|
(local lume (require :lume))
|
||||||
|
|
||||||
(local commands {})
|
(local commands {})
|
||||||
|
|
||||||
@ -50,8 +51,9 @@
|
|||||||
(fn invoke-command [command params]
|
(fn invoke-command [command params]
|
||||||
(command.function params))
|
(command.function params))
|
||||||
|
|
||||||
(fn next-action [state input-string]
|
(fn next-action [self input-string]
|
||||||
(let [state-for-next-param
|
(let [state self.state
|
||||||
|
state-for-next-param
|
||||||
(fn [c params]
|
(fn [c params]
|
||||||
(match (next-param c params)
|
(match (next-param c params)
|
||||||
k1 {
|
k1 {
|
||||||
@ -60,7 +62,9 @@
|
|||||||
:collected-params params
|
:collected-params params
|
||||||
:active true
|
: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
|
(match state
|
||||||
{:active false} state
|
{:active false} state
|
||||||
@ -92,7 +96,7 @@
|
|||||||
)))
|
)))
|
||||||
|
|
||||||
(fn on-activate [self str]
|
(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))]
|
param (if s.active (. (. s.command :params) s.this-param))]
|
||||||
(set self.state s)
|
(set self.state s)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user