feat(settings): persist the theme through the settings binding

The palette lives in Lua, so C++ stores the name only and ui.setTheme()
writes through here before rebuilding and repainting.
This commit is contained in:
2026-08-04 20:44:08 -04:00
parent 291f0f20b5
commit e85adfa757
7 changed files with 60 additions and 6 deletions
+2 -4
View File
@@ -42,7 +42,6 @@ local ui = {}
---@field on_cancel? UiHandler
---@field on_outside? UiHandler
local THEME_PATH = "/.lua/theme"
local THEMES = {
light = { background = { 255, 255, 255 }, color = { 0, 0, 0 }, accent = { 0, 120, 255 }, radius = 6 },
dark = { background = { 18, 18, 20 }, color = { 235, 235, 235 }, accent = { 166, 118, 255 }, radius = 6 },
@@ -113,7 +112,7 @@ function ui.setTheme(name)
if not THEMES[name] then
return nil, "Unknown theme"
end
local ok, err = fs.writeFile(THEME_PATH, name)
local ok, err = settings.setTheme(name)
if not ok then
return nil, err
end
@@ -126,8 +125,7 @@ function ui.setTheme(name)
return true
end
local savedTheme = fs.readFile(THEME_PATH, 32)
loadTheme(savedTheme and savedTheme:match "^%s*(.-)%s*$" or "light")
loadTheme(settings.getTheme())
local function clearState()
enterHandlers, exitHandlers, clickHandlers, painters = {}, {}, {}, {}