dunlin

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 055e8b792fe28f1dd22653cff84c917d3d317dba
parent 1f93dc23100a37523a71dea892153d7d4f9edbd2
Author: Daniel Barlow <dan@telent.net>
Date:   Sun,  1 Jan 2023 19:12:54 +0000

hide commander and print messages in echo area

Diffstat:
Mcommand.fnl | 6++++--
Mframe.fnl | 9+++++++--
Mkeymap.fnl | 2+-
Mmusing.md | 2++
4 files changed, 14 insertions(+), 5 deletions(-)

diff --git 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 @@ -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 @@ -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 @@ -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