From cde0b8cd56d4faae2ed6a276e7baee5666fb0ee1 Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Fri, 23 Dec 2022 15:21:06 +0000 Subject: [PATCH] pass keymap into the frame --- dunlin.fnl | 20 +++++++++++++++++++- frame.fnl | 19 ++----------------- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/dunlin.fnl b/dunlin.fnl index 98d7f73..3beb469 100644 --- a/dunlin.fnl +++ b/dunlin.fnl @@ -2,10 +2,28 @@ (local lfs (require :lfs)) (local { : Gtk : Gdk : WebKit2 : cairo } lgi) +(local Command (require :command)) (local Frame (require :frame)) (local Buffer (require :buffer)) -(let [f (Frame.new) +;;; when we decide how to do an init file/rc file, this will go in it + +(local my-keymap { + "g" #(Command.invoke-interactively + "visit-location" + {:buffer "main"}) + "M-q" #(Command.invoke-interactively + "quit-browser" + {}) + "C-x" { + "C-c" + #(Command.invoke-interactively + "quit-browser" + {}) + } + }) + +(let [f (Frame.new my-keymap) b (Buffer.new "main")] (f:show-buffer b) (b:visit (.. "file://" (lfs.currentdir) "/doc/index.html"))) diff --git a/frame.fnl b/frame.fnl index 41785c8..20f90b5 100644 --- a/frame.fnl +++ b/frame.fnl @@ -5,25 +5,10 @@ (var frames []) -(fn new-frame [] +(fn new-frame [global-keymap] (let [hpad 2 vpad 2 - recogniser (keymap.recogniser - { - "g" #(Command.invoke-interactively - "visit-location" - {:buffer "main"}) - "M-q" #(Command.invoke-interactively - "quit-browser" - {}) - "c" { - "x" - #(Command.invoke-interactively - "quit-browser" - {}) - } - - }) + recogniser (keymap.recogniser global-keymap) window (Gtk.Window { :title "Dunlin" :default_width 800