diff --git a/command.fnl b/command.fnl index c250f9d..17cd078 100644 --- a/command.fnl +++ b/command.fnl @@ -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 diff --git a/frame.fnl b/frame.fnl index e7eae03..2250a51 100644 --- a/frame.fnl +++ b/frame.fnl @@ -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)) diff --git a/keymap.fnl b/keymap.fnl index fc69554..28e649b 100644 --- a/keymap.fnl +++ b/keymap.fnl @@ -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"))))))) })) diff --git a/musing.md b/musing.md index 46b7e35..141a4a9 100644 --- a/musing.md +++ b/musing.md @@ -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