honeylisp/wrap.fnl

73 lines
1.7 KiB
Plaintext
Raw Normal View History

(require "lite")
(require "util")
(local imgui (require "imgui"))
(local machine (require "machine"))
(local core (require "core"))
(local command (require "core.command"))
(local keymap (require "core.keymap"))
(fn upload [] (: (reload "test") :upload machine))
(command.add (fn [] machine.socket) {
"honeylisp:upload" upload
})
(command.add "core.docview" {
"fennel:eval" (fn []
(let [ldoc core.active_view.doc
(aline acol bline bcol) (ldoc:get_selection)
options {:env _G :compiler-env _G}
inject #(ldoc:insert bline bcol (fv (fennel.eval $1 options) {}))]
(if (and (= aline bline) (= acol bcol))
(inject (ldoc:get_text aline 1 aline 10000000))
(inject (ldoc:get_text aline acol bline bcol)))))
"lume:hotswap" (fn []
(local modname
(-> core.active_view.doc.filename
(: :gsub "%.%a+$" "")
(: :gsub "/" ".")
(: :gsub "^data%." "")
(: :gsub "%.init$" "")))
(core.log (.. "Hotswapping " modname))
(local (mod err) (lume.hotswap modname))
(when (not= err nil) (print err) (error err)))
})
(keymap.add {
"alt+e" "fennel:eval"
"alt+r" "lume:hotswap"
})
(fn love.load [])
(fn love.update [dt]
(imgui.NewFrame))
(fn love.draw []
(imgui.Render))
(fn love.quit []
(imgui.ShutDown))
(fn love.textinput [t]
(imgui.TextInput t))
(fn love.keypressed [key]
(imgui.KeyPressed key))
(fn love.keyreleased [key]
(imgui.KeyReleased key))
(fn love.mousemoved [x y]
(imgui.MouseMoved x y))
(fn love.mousepressed [x y button]
(imgui.MousePressed button))
(fn love.mousereleased [x y button]
(imgui.MouseReleased button))
(fn love.wheelmoved [x y]
(imgui.WheelMoved y))
{}