add command line
This commit is contained in:
parent
aa26c2da3f
commit
38786d3790
17
command.fnl
Normal file
17
command.fnl
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
(local { : Gtk } (require :lgi))
|
||||||
|
|
||||||
|
(local commands {})
|
||||||
|
|
||||||
|
(fn define-command [name function params]
|
||||||
|
(let [v {:name name :function function :params params}]
|
||||||
|
(tset commands name v)))
|
||||||
|
|
||||||
|
(define-command "quit-browser" #(Gtk.main_quit) {})
|
||||||
|
|
||||||
|
(fn invoke [s]
|
||||||
|
(match (. commands s)
|
||||||
|
{:function f :params p} (f)
|
||||||
|
nil (print "undefined command " s)))
|
||||||
|
|
||||||
|
|
||||||
|
{ : invoke }
|
@ -1,11 +1,6 @@
|
|||||||
(local lgi (require :lgi))
|
(local lgi (require :lgi))
|
||||||
(local { : Gtk : Gdk : WebKit2 : cairo } lgi)
|
(local { : Gtk : Gdk : WebKit2 : cairo } lgi)
|
||||||
|
|
||||||
(fn invoke-command [command]
|
|
||||||
)
|
|
||||||
|
|
||||||
(set _G.invoke-commad invoke-command)
|
|
||||||
|
|
||||||
(local frame (require :frame))
|
(local frame (require :frame))
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
(local { : Gtk : Gdk : WebKit2 : cairo } (require :lgi))
|
(local { : Gtk : Gdk : WebKit2 : cairo } (require :lgi))
|
||||||
|
|
||||||
|
(local command (require :command))
|
||||||
|
|
||||||
(fn new-frame []
|
(fn new-frame []
|
||||||
(let [hpad 2
|
(let [hpad 2
|
||||||
vpad 2
|
vpad 2
|
||||||
@ -15,7 +17,7 @@
|
|||||||
commander (Gtk.Entry {
|
commander (Gtk.Entry {
|
||||||
:on_activate
|
:on_activate
|
||||||
(fn [event]
|
(fn [event]
|
||||||
(_G.invoke-command event.text))
|
(command.invoke event.text))
|
||||||
})
|
})
|
||||||
progress-bar (Gtk.ProgressBar {
|
progress-bar (Gtk.ProgressBar {
|
||||||
:orientation Gtk.Orientation.HORIZONTAL
|
:orientation Gtk.Orientation.HORIZONTAL
|
||||||
|
Loading…
Reference in New Issue
Block a user