summaryrefslogtreecommitdiff
path: root/init.lua
diff options
context:
space:
mode:
authort <t@tjp.lol>2026-10-27 20:41:49 -0600
committert <t@tjp.lol>2026-10-27 21:11:55 -0600
commitff6d9a4c30ec4218c559960741745a4b190fb063 (patch)
tree40cafda55d349d5ab3020dc36f07626bb0c4f4be /init.lua
parent009d5705a59bcf86f3579a78e25c8b3fcd4cd476 (diff)
Add idle RSVP focus view and persist reading speedHEADmain
Diffstat (limited to 'init.lua')
-rw-r--r--init.lua13
1 files changed, 13 insertions, 0 deletions
diff --git a/init.lua b/init.lua
index 532152a..a9cf18f 100644
--- a/init.lua
+++ b/init.lua
@@ -6,10 +6,23 @@ local function activate()
local ext = panto.ext
local settings, err = config.read(ext.config and ext.config.rsvp)
if not settings then error("panto-rsvp: " .. err) end
+ local restored, state_err
+ local state_ok, saved_wpm, read_err = pcall(function() return ext.state.get("rsvp.wpm") end)
+ if not state_ok then
+ state_err = "WPM restore failed: " .. tostring(saved_wpm)
+ elseif read_err ~= nil then
+ state_err = "WPM restore failed: " .. tostring(read_err)
+ elseif type(saved_wpm) == "number" and saved_wpm == saved_wpm and saved_wpm > 0
+ and saved_wpm < math.huge then
+ restored = math.max(settings.min_wpm, saved_wpm)
+ end
+ if restored then settings.wpm = restored end
local uv = require("luv")
local player = Player.new {
settings = settings,
+ persistence_error = state_err,
+ save_wpm = function(speed) return ext.state.set("rsvp.wpm", speed) end,
highlight = function(body) return ext.highlight(body, "markdown") end,
width = panto.text.width,
truncate = panto.text.truncate,