add command line

main
Daniel Barlow 2022-12-19 20:57:23 +00:00
parent aa26c2da3f
commit 38786d3790
3 changed files with 20 additions and 6 deletions

17
command.fnl Normal file
View 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 }

View File

@ -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))

View File

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