add visit-location command
though it does hardcode the URL, making it less than generally useful
This commit is contained in:
parent
a34e63877d
commit
87448bd5ee
@ -31,5 +31,6 @@
|
|||||||
(let [b (new-buffer name)]
|
(let [b (new-buffer name)]
|
||||||
(tset buffers name b)
|
(tset buffers name b)
|
||||||
b))
|
b))
|
||||||
|
:current (fn [] (let [k (next buffers)] (. buffers k)))
|
||||||
:find (fn [self term] (. buffers term))
|
:find (fn [self term] (. buffers term))
|
||||||
})
|
})
|
||||||
|
20
command.fnl
20
command.fnl
@ -1,15 +1,33 @@
|
|||||||
(local { : Gtk } (require :lgi))
|
(local { : Gtk } (require :lgi))
|
||||||
|
(local { : view } (require :fennel))
|
||||||
|
|
||||||
(local commands {})
|
(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]
|
(fn define-command [name function params]
|
||||||
|
;; required parameter names and default arguments
|
||||||
(let [v {:name name :function function :params params}]
|
(let [v {:name name :function function :params params}]
|
||||||
(tset commands name v)))
|
(tset commands name v)))
|
||||||
|
|
||||||
(define-command "quit-browser" #(Gtk.main_quit) {})
|
(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]
|
(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]
|
(fn invoke [s args]
|
||||||
(match (. commands s)
|
(match (. commands s)
|
||||||
|
@ -44,9 +44,7 @@
|
|||||||
:content contentwidget
|
:content contentwidget
|
||||||
:show-buffer (fn [self b]
|
:show-buffer (fn [self b]
|
||||||
(each [_ w (pairs (contentwidget:get_children))]
|
(each [_ w (pairs (contentwidget:get_children))]
|
||||||
(print "hide " w)
|
|
||||||
(w:hide))
|
(w:hide))
|
||||||
(print "show " (view b))
|
|
||||||
(contentwidget:pack_start b.webview true true 0)
|
(contentwidget:pack_start b.webview true true 0)
|
||||||
(b.webview:show))
|
(b.webview:show))
|
||||||
}]
|
}]
|
||||||
|
Loading…
Reference in New Issue
Block a user