(local lgi (require :lgi))
(local lfs (require :lfs))
(local { : Gtk : Gdk : WebKit2 : cairo } lgi)

(local Command (require :command))
(local Frame (require :frame))
(local Buffer (require :buffer))

;;; when we decide how to do an init file/rc file, this will go in it

(local my-keymap {
                  "g" ["visit-location" {:buffer #$1.buffer }]
                  "M-q" ["quit-browser" {}]
                  "C-x" {
                         "C-c" ["quit-browser" {}]
                         "b" ["switch-to-buffer" {}]
                         }
                  })

(let [f (Frame.new my-keymap)
      b (Buffer.new "main")]
  (f:show-buffer b)
  (b:visit (.. "file://" (lfs.currentdir) "/doc/index.html")))

(let [socketdir (or (os.getenv "XDG_RUNTIME_DIR") (os.getenv "HOME"))]
  ((. (require :socket-repl) :start)
   (.. socketdir "/dunlin.sock")))

(Gtk.main)
