honeylisp/wrap.fnl
Jeremy Penner 1a93fc7e84 A bunch of stuff
- refactor assembler to be more modular / extensible
- fix a bunch of bugs
- better error reporting
- stop using imgui in favour of lite commands
- in-editor hotswap & eval hotkeys
- machine:write in batches so bytes aren't dropped
- first cut at stack VM primitives
2020-09-20 13:55:06 -04:00

73 lines
1.7 KiB
Fennel

(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))
{}