complete command names

we really need to make TAB and Return work for keyboard-selecting
a proffered completion
main
Daniel Barlow 2023-01-03 23:36:58 +00:00
parent c2c89b6dfd
commit 4d3a2bf237
1 changed files with 20 additions and 15 deletions

View File

@ -129,22 +129,27 @@
(if result.active "commander" "echo-area")))) (if result.active "commander" "echo-area"))))
(fn on-input [self str] (fn on-input [self str]
(match self.state (let [parent self.completions-widget
{:command c :this-param param-name} set-completions
(let [parent self.completions-widget (fn [completions]
{ : completer} (. c.params param-name) (parent:foreach #(parent:remove $1))
completions (completer str)] (each [text _w (pairs completions)]
(parent:foreach #(parent:remove $1)) (parent:add
(each [text _w (pairs completions)] (Gtk.Button {
(parent:add :label text
(Gtk.Button { :on_clicked
:label text #(update-widget-state self (self:on-input-finished text))
:on_clicked })))
#(update-widget-state self (self:on-input-finished text)) (parent:show_all))]
}))) (match self.state
(parent:show_all) {:command c :this-param param-name}
))) (let [{ : completer} (. c.params param-name)]
(set-completions (completer str)))
{:command nil}
(set-completions
(collect [k _ (pairs commands)]
(if (= (k:find str 1 true) 1) (values k k)))))))
(fn activate [{: state : entry : prompt &as self}] (fn activate [{: state : entry : prompt &as self}]
(tset state :active true) (tset state :active true)