deactivate commander at startup
use M-x to activate it
This commit is contained in:
parent
ce009f2c7b
commit
491f3225b0
13
command.fnl
13
command.fnl
@ -25,7 +25,7 @@
|
|||||||
(. commands name))
|
(. commands name))
|
||||||
|
|
||||||
(local default-state {
|
(local default-state {
|
||||||
:active true
|
:active false
|
||||||
:command nil
|
:command nil
|
||||||
:collected-params {}
|
:collected-params {}
|
||||||
:this-param nil
|
:this-param nil
|
||||||
@ -90,4 +90,13 @@
|
|||||||
:default (and param (param))
|
:default (and param (param))
|
||||||
}))
|
}))
|
||||||
|
|
||||||
{ : define-command : on-input : reset-state }
|
(fn activate []
|
||||||
|
(tset state :active true)
|
||||||
|
state)
|
||||||
|
|
||||||
|
{
|
||||||
|
: activate
|
||||||
|
: define-command
|
||||||
|
: on-input
|
||||||
|
: reset-state
|
||||||
|
}
|
||||||
|
18
frame.fnl
18
frame.fnl
@ -17,6 +17,7 @@
|
|||||||
:orientation Gtk.Orientation.VERTICAL
|
:orientation Gtk.Orientation.VERTICAL
|
||||||
})
|
})
|
||||||
commander (Gtk.Entry {
|
commander (Gtk.Entry {
|
||||||
|
:sensitive false
|
||||||
})
|
})
|
||||||
progress-bar (Gtk.ProgressBar {
|
progress-bar (Gtk.ProgressBar {
|
||||||
:orientation Gtk.Orientation.HORIZONTAL
|
:orientation Gtk.Orientation.HORIZONTAL
|
||||||
@ -30,9 +31,20 @@
|
|||||||
(tset commander :on_activate
|
(tset commander :on_activate
|
||||||
(fn [event]
|
(fn [event]
|
||||||
(let [result (Command.on-input event.text)]
|
(let [result (Command.on-input event.text)]
|
||||||
(print "result" (view result))
|
(set commander.placeholder_text
|
||||||
(set commander.placeholder_text (or result.prompt ""))
|
(or result.prompt ""))
|
||||||
(set commander.text (or result.default "")))))
|
(set commander.sensitive result.active)
|
||||||
|
(set commander.text
|
||||||
|
(or result.default result.error "")))))
|
||||||
|
|
||||||
|
(tset window :on_key_release_event
|
||||||
|
(fn [window event]
|
||||||
|
(when (and event.state.MOD1_MASK
|
||||||
|
(= event.keyval (string.byte "x")))
|
||||||
|
(set commander.sensitive true)
|
||||||
|
(set commander.text "")
|
||||||
|
(commander:grab_focus)
|
||||||
|
(Command.activate))))
|
||||||
|
|
||||||
(doto container
|
(doto container
|
||||||
(: :pack_start commander false false vpad)
|
(: :pack_start commander false false vpad)
|
||||||
|
@ -14,7 +14,8 @@
|
|||||||
|
|
||||||
(before)
|
(before)
|
||||||
(let [(ok err)
|
(let [(ok err)
|
||||||
(match-try (Command.on-input "not-a-command")
|
(match-try (Command.activate)
|
||||||
|
{:active true} (Command.on-input "not-a-command")
|
||||||
(where {:error e :active false} (e:match "can't find command")) true
|
(where {:error e :active false} (e:match "can't find command")) true
|
||||||
(catch
|
(catch
|
||||||
x (values nil (view x))))]
|
x (values nil (view x))))]
|
||||||
@ -22,7 +23,8 @@
|
|||||||
|
|
||||||
(before)
|
(before)
|
||||||
(let [(ok err)
|
(let [(ok err)
|
||||||
(match-try (Command.on-input "multiply")
|
(match-try (Command.activate)
|
||||||
|
{:active true} (Command.on-input "multiply")
|
||||||
{:active true :prompt p1} (Command.on-input "2")
|
{:active true :prompt p1} (Command.on-input "2")
|
||||||
{:active true :prompt p2} (Command.on-input "3")
|
{:active true :prompt p2} (Command.on-input "3")
|
||||||
(where {:active false} (= happened 6)) true
|
(where {:active false} (= happened 6)) true
|
||||||
|
Loading…
Reference in New Issue
Block a user