add visit-location command

though it does hardcode the URL, making it less than generally useful
main
Daniel Barlow 2022-12-20 11:14:27 +00:00
parent a34e63877d
commit 87448bd5ee
3 changed files with 20 additions and 3 deletions

View File

@ -31,5 +31,6 @@
(let [b (new-buffer name)]
(tset buffers name b)
b))
:current (fn [] (let [k (next buffers)] (. buffers k)))
:find (fn [self term] (. buffers term))
})

View File

@ -1,15 +1,33 @@
(local { : Gtk } (require :lgi))
(local { : view } (require :fennel))
(local commands {})
(local Buffer (require :buffer))
;; when a command is invoked from a binding, the binding may provide
;; some or all of the parameter values. when there are missing params,
;; or when invoked from the commander, `invoke` prompts for the
;; missing params, offering default values which were specified by
;; define-command
(fn define-command [name function params]
;; required parameter names and default arguments
(let [v {:name name :function function :params params}]
(tset commands name v)))
(define-command "quit-browser" #(Gtk.main_quit) {})
(define-command
"visit-location"
(fn [{:url url :buffer buffer}]
(buffer:visit url))
{:buffer (fn [] (Buffer.current))
:url #(do "http://www.example.com")
})
(fn prompt-missing-args [params explicit-args]
explicit-args)
(collect [k v (pairs params)]
(values k (or (. explicit-args k) (v)))))
(fn invoke [s args]
(match (. commands s)

View File

@ -44,9 +44,7 @@
:content contentwidget
:show-buffer (fn [self b]
(each [_ w (pairs (contentwidget:get_children))]
(print "hide " w)
(w:hide))
(print "show " (view b))
(contentwidget:pack_start b.webview true true 0)
(b.webview:show))
}]