Compare commits

...

2 Commits

2 changed files with 20 additions and 6 deletions

View File

@ -105,13 +105,14 @@
{
:active s.active
:error s.error
:prompt (or s.this-param "")
:prompt (if s.active (or s.this-param "Command?" "") "")
:default (and param (param))
}))
(local prompt (Gtk.Label { :label ""}))
(fn update-widget-state [w result]
(set w.placeholder_text
(or result.prompt ""))
(set prompt.label (or result.prompt ""))
(set w.sensitive result.active)
(set w.text
(or result.default result.error "")))
@ -125,10 +126,21 @@
(update-widget-state w (on-input event.text))))
w))
(local box
(let [box
(Gtk.Box {
:orientation Gtk.Orientation.HORIZONTAL
})]
(box:pack_start prompt false false 15)
(box:pack_start widget true true 5)
box))
(fn activate []
(tset state :active true)
(set widget.sensitive true)
(set widget.text "")
(set prompt.label (or state.this-param "Command" ""))
(widget:grab_focus)
state)
@ -152,7 +164,9 @@
: active?
: define-command
: on-input
: reset-state
: invoke-interactively
: widget
:widget box
:_ {
: reset-state
}
}

View File

@ -3,7 +3,7 @@
(local Command (require :command))
(var happened false)
(fn before [] (set happened false) (Command.reset-state))
(fn before [] (set happened false) (Command._.reset-state))
(Command.define-command "no-args-command" #(set happened true) [])