dunlin

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 38786d3790aa8f16da9f420ceae667c87a5c0f04
parent aa26c2da3f7378e3535be88938c810b77b40602f
Author: Daniel Barlow <dan@telent.net>
Date:   Mon, 19 Dec 2022 20:57:23 +0000

add command line

Diffstat:
Acommand.fnl | 17+++++++++++++++++
Mdunlin.fnl | 5-----
Mframe.fnl | 4+++-
3 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/command.fnl 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 @@ -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 @@ -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