honeylisp/editor/init.fnl

46 lines
1.4 KiB
Plaintext
Raw Normal View History

2020-10-12 15:48:14 +00:00
(require :editor.lite)
(local TileView (require :editor.tileedit))
2020-10-19 00:13:26 +00:00
(local MapEditView (require :editor.mapedit))
2020-10-12 15:48:14 +00:00
(local core (require :core))
(local command (require :core.command))
(local keymap (require :core.keymap))
(command.add nil {
"honeylisp:edit-tiles" (fn []
(local node (core.root_view:get_active_node))
2020-10-19 00:13:26 +00:00
(node:add_view (TileView)))
"honeylisp:edit-map" (fn []
(local node (core.root_view:get_active_node))
(node:add_view (MapEditView))
)
2020-10-12 15:48:14 +00:00
})
(command.add :editor.tileedit {
"tileedit:save" (fn [] (core.active_view:save) (core.log "Saved tiles"))
"tileedit:next-tile" #(core.active_view:select-rel 1)
"tileedit:previous-tile" #(core.active_view:select-rel -1)
"tileedit:copy" #(system.set_clipboard (: (core.active_view:tile) :tohex))
"tileedit:paste"
#(when (= (length (system.get_clipboard)) 64)
(core.active_view:update-tile (: (system.get_clipboard) :fromhex)))
2020-10-12 15:48:14 +00:00
})
(keymap.add {
"ctrl+s" "tileedit:save"
"left" "tileedit:previous-tile"
"right" "tileedit:next-tile"
"ctrl+c" "tileedit:copy"
"ctrl+v" "tileedit:paste"
2020-10-12 15:48:14 +00:00
})
2020-10-19 00:13:26 +00:00
(command.add :editor.mapedit {
"mapedit:next-tile" #(core.active_view:select-rel 1)
"mapedit:previous-tile" #(core.active_view:select-rel -1)
"mapedit:save" (fn [] (core.active_view:save) (core.log "Saved map"))
})
(keymap.add {
"ctrl+s" "mapedit:save"
"left" "mapedit:previous-tile"
"right" "mapedit:next-tile"
})