hide commander and print messages in echo area

main
Daniel Barlow 2023-01-01 19:12:54 +00:00
parent 1f93dc2310
commit 055e8b792f
4 changed files with 14 additions and 5 deletions

View File

@ -111,12 +111,14 @@
:default (and param (param.default self.frame))
}))
(fn update-widget-state [{ : entry : completions-widget : prompt} result]
(fn update-widget-state [{ : widget : entry : completions-widget : prompt} result]
(set prompt.label (or result.prompt ""))
(set entry.sensitive result.active)
(if (not result.active)
(completions-widget:hide))
(set entry.text (or result.default result.error "")))
(set entry.text (or result.default result.error ""))
(widget.parent:set_visible_child_name
(if result.active "commander" "echo-area")))
(fn on-input [self str]
(match self.state

View File

@ -17,7 +17,10 @@
:transition_duration 100
})
commander (Command.commander self)
echo-area (Gtk.Label { :label "echo area visible, commander hidden" })
echo-area (Gtk.Label {
:xalign 0
:margin_start 10
})
window (Gtk.Window {
:title "Dunlin"
:default_width 800
@ -59,7 +62,7 @@
(when (not (commander:active?))
(match (recogniser:accept-event event)
[name params] (commander:invoke-interactively name params)
(nil prompt) (print "prompted" prompt)))
(nil prompt) (tset echo-area :label prompt)))
(when (and (commander:active?)
(= keymap.keyval.Escape event.keyval))
(commander:deactivate))
@ -78,6 +81,8 @@
:window window
:buffer nil
:content contentwidget
:message (fn [self message]
(tset echo-area :label message))
:show-buffer (fn [self b]
(each [_ w (pairs (contentwidget:get_children))]
(w:hide))

View File

@ -126,7 +126,7 @@
_
(let [syms (lume.map key-sequence index->string)]
(set key-sequence [])
(values nil (.. "No binding for " (table.concat syms " "))))))))
(values nil (.. (table.concat syms " ") " is undefined")))))))
}))

View File

@ -102,3 +102,5 @@ but philosophically those things are not related to the command system.
- hide commander when inactive and replace it with echo area
- move it to bottom?
commander can't hide itself, it needs to ask its parent to hide it