2020-09-17 02:34:36 +00:00
|
|
|
(require "lite")
|
|
|
|
(require "util")
|
2020-09-27 18:53:16 +00:00
|
|
|
(local lume (require "lume"))
|
2020-09-17 02:34:36 +00:00
|
|
|
(local imgui (require "imgui"))
|
2020-09-27 18:53:16 +00:00
|
|
|
(local serial (require "serial"))
|
|
|
|
(local gsplus (require "machine"))
|
2020-09-20 17:55:06 +00:00
|
|
|
(local core (require "core"))
|
|
|
|
(local command (require "core.command"))
|
|
|
|
(local keymap (require "core.keymap"))
|
2020-09-27 18:53:16 +00:00
|
|
|
(local translate (require "core.doc.translate"))
|
2020-09-17 02:34:36 +00:00
|
|
|
|
2020-09-27 18:53:16 +00:00
|
|
|
(var machine (if (and (pcall #(serial:connect)) (serial:connected?)) serial gsplus))
|
2020-09-20 17:55:06 +00:00
|
|
|
|
2020-09-27 18:53:16 +00:00
|
|
|
(command.add #(not= machine serial) {
|
|
|
|
"serial:switch-machine" #(set machine serial)
|
|
|
|
})
|
|
|
|
(command.add #(not= machine gsplus) {
|
|
|
|
"gsplus:switch-machine" #(set machine gsplus)
|
|
|
|
})
|
|
|
|
(command.add #(machine:connected?) {
|
|
|
|
"honeylisp:upload" (fn []
|
|
|
|
(local p (reload "test"))
|
|
|
|
(p:upload machine)
|
|
|
|
(core.log (string.format "%x" (p:lookup-addr p.start-symbol))))
|
|
|
|
})
|
|
|
|
(command.add (fn [] true) {
|
|
|
|
"honeylisp:rebuild" #(reload "test")
|
2020-09-20 17:55:06 +00:00
|
|
|
})
|
2020-10-04 19:10:56 +00:00
|
|
|
|
|
|
|
(fn selected-symbol []
|
|
|
|
(local ldoc core.active_view.doc)
|
|
|
|
(var (aline acol bline bcol) (ldoc:get_selection))
|
|
|
|
(when (and (= aline bline) (= acol bcol))
|
|
|
|
(set (aline acol) (translate.start_of_word ldoc aline acol))
|
|
|
|
(set (bline bcol) (translate.end_of_word ldoc bline bcol)))
|
|
|
|
(ldoc:get_text aline acol bline bcol))
|
|
|
|
|
2020-09-20 17:55:06 +00:00
|
|
|
(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)))
|
2020-09-27 18:53:16 +00:00
|
|
|
"honeylisp:address" (fn []
|
2020-10-04 19:10:56 +00:00
|
|
|
(local word (selected-symbol))
|
2020-09-27 18:53:16 +00:00
|
|
|
(local p (require "test"))
|
|
|
|
(core.log (string.format "%s %x" word (or (p:lookup-addr word) -1)))
|
|
|
|
)
|
2020-09-20 17:55:06 +00:00
|
|
|
})
|
|
|
|
(keymap.add {
|
|
|
|
"alt+e" "fennel:eval"
|
|
|
|
"alt+r" "lume:hotswap"
|
2020-10-04 19:10:56 +00:00
|
|
|
"alt+a" "honeylisp:address"
|
2020-09-20 17:55:06 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
(fn love.load [])
|
2020-09-17 02:34:36 +00:00
|
|
|
|
|
|
|
(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))
|
2020-09-20 17:55:06 +00:00
|
|
|
|
|
|
|
{}
|