Revert "inline temps and whitespace, improve update-widget-state"
This reverts commit 9775e00545
.
This commit is contained in:
parent
561c717609
commit
d39d7059b9
38
command.fnl
38
command.fnl
@ -24,15 +24,21 @@
|
||||
|
||||
(define-command
|
||||
"switch-to-buffer"
|
||||
[[:buffer Buffer.match #(. (Buffer.next $1.buffer) :name)]]
|
||||
(fn [{: frame : buffer}]
|
||||
[[:buffer
|
||||
Buffer.match
|
||||
#(. (Buffer.next $1.buffer) :name)]
|
||||
]
|
||||
(fn [{:frame frame :buffer buffer}]
|
||||
(frame:show-buffer buffer)))
|
||||
|
||||
(define-command
|
||||
"visit-location"
|
||||
[[:buffer Buffer.match #$1.buffer.name]
|
||||
[:url #{$1 $1} #($1.buffer:location)]]
|
||||
(fn [{: url : buffer}]
|
||||
[[:buffer
|
||||
Buffer.match
|
||||
#$1.buffer.name]
|
||||
[:url #{$1 $1} #($1.buffer:location)]
|
||||
]
|
||||
(fn [{:url url :buffer buffer}]
|
||||
(buffer:visit url)))
|
||||
|
||||
(define-command
|
||||
@ -87,7 +93,8 @@
|
||||
|
||||
{:command c :this-param k :collected-params p}
|
||||
(let [{ : completer} (. c.params k)
|
||||
value (. (completer input-string) input-string)]
|
||||
vals (completer input-string)
|
||||
value (. vals input-string)]
|
||||
(tset p k value)
|
||||
(state-for-next-param c p))
|
||||
|
||||
@ -103,20 +110,20 @@
|
||||
param (if s.active (. (. s.command :params) s.this-param))]
|
||||
(set self.state s)
|
||||
{
|
||||
:active s.active
|
||||
:error s.error
|
||||
:prompt (if s.active (or s.this-param "Command?" "") "")
|
||||
:default (and param (param.default self.frame))
|
||||
}))
|
||||
|
||||
(fn update-widget-state [{ : state : widget : entry : completions-widget : prompt} result]
|
||||
(fn update-widget-state [{ : widget : entry : completions-widget : prompt} result]
|
||||
(set prompt.label (or result.prompt ""))
|
||||
(set entry.sensitive state.active)
|
||||
(if (not state.active)
|
||||
(set entry.sensitive result.active)
|
||||
(if (not result.active)
|
||||
(completions-widget:hide))
|
||||
(set entry.text (or result.default result.error ""))
|
||||
(match widget.parent
|
||||
p (p:set_visible_child_name
|
||||
(if state.active "commander" "echo-area"))))
|
||||
(widget.parent:set_visible_child_name
|
||||
(if result.active "commander" "echo-area")))
|
||||
|
||||
(fn on-input [self str]
|
||||
(match self.state
|
||||
@ -140,16 +147,17 @@
|
||||
(tset state :active true)
|
||||
(update-widget-state
|
||||
self
|
||||
{
|
||||
{:active true
|
||||
:prompt (or state.this-param "Command" "")
|
||||
})
|
||||
(entry:grab_focus))
|
||||
(entry:grab_focus)
|
||||
state)
|
||||
|
||||
(fn deactivate [{: state : entry : prompt &as self}]
|
||||
(doto state
|
||||
(lume.clear)
|
||||
(tset :active false))
|
||||
(update-widget-state self {}))
|
||||
(update-widget-state self {:active false}))
|
||||
|
||||
(fn invoke-interactively [self name params]
|
||||
(let [c (find-command name)
|
||||
|
Loading…
Reference in New Issue
Block a user