honeylisp/presentation/commands.fnl

38 lines
1.3 KiB
Plaintext
Raw Permalink Normal View History

2021-06-22 02:09:09 +00:00
(local util (require :lib.util))
2021-06-19 01:31:21 +00:00
(local core (require :core))
(local command (require :core.command))
(local keymap (require :core.keymap))
2021-07-04 02:13:04 +00:00
(local style (require :core.style))
2021-06-19 01:31:21 +00:00
(local SlideshowView (require :presentation.engine))
2021-06-22 02:09:09 +00:00
(fn set-scale [multiplier]
(set _G.SCALE (* (love.graphics.getDPIScale) multiplier))
2021-07-04 02:13:04 +00:00
(util.hotswap :core.style)
(when (= multiplier 1)
(set style.code_font (renderer.font.load (.. EXEDIR "/data/fonts/monospace.ttf") 15))))
2021-06-22 02:09:09 +00:00
2021-06-19 01:31:21 +00:00
(command.add nil {
"presentation:start" (fn []
(let [node (core.root_view:get_active_node)]
2021-06-22 02:09:09 +00:00
(node:add_view (SlideshowView (util.reload :presentation.slides))))
2021-06-19 01:31:21 +00:00
)
2021-06-22 02:09:09 +00:00
"presentation:scale-up" #(set-scale 2)
"presentation:restore-scale" #(set-scale 1)
2021-06-19 01:31:21 +00:00
})
(command.add :presentation.engine {
"presentation:next" #(core.active_view:advance)
"presentation:prev" #(core.active_view:back)
"presentation:next-slide" #(core.active_view:next-slide)
"presentation:prev-slide" #(core.active_view:prev-slide)
"presentation:toggle-timer" #(core.active_view:toggle-timer)
"presentation:reset-timer" #(core.active_view:reset-timer)
2021-06-19 01:31:21 +00:00
})
(keymap.add {
2021-06-22 02:09:09 +00:00
"left" "presentation:prev"
"right" "presentation:next"
"ctrl+left" "presentation:prev-slide"
"ctrl+right" "presentation:next-slide"
"alt+t" "presentation:toggle-timer"
2021-06-19 01:31:21 +00:00
})