diff --git a/command.fnl b/command.fnl new file mode 100644 index 0000000..1c87d88 --- /dev/null +++ b/command.fnl @@ -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 } diff --git a/dunlin.fnl b/dunlin.fnl index 4a323c4..6be809d 100644 --- a/dunlin.fnl +++ b/dunlin.fnl @@ -1,11 +1,6 @@ (local lgi (require :lgi)) (local { : Gtk : Gdk : WebKit2 : cairo } lgi) -(fn invoke-command [command] - ) - -(set _G.invoke-commad invoke-command) - (local frame (require :frame)) diff --git a/frame.fnl b/frame.fnl index ac8e045..16b0766 100644 --- a/frame.fnl +++ b/frame.fnl @@ -1,5 +1,7 @@ (local { : Gtk : Gdk : WebKit2 : cairo } (require :lgi)) +(local command (require :command)) + (fn new-frame [] (let [hpad 2 vpad 2 @@ -15,7 +17,7 @@ commander (Gtk.Entry { :on_activate (fn [event] - (_G.invoke-command event.text)) + (command.invoke event.text)) }) progress-bar (Gtk.ProgressBar { :orientation Gtk.Orientation.HORIZONTAL