fix(launcher): localize image-missing placeholder + drop dead icons.lua

- markdown.lua: M.render now accepts an optional `t` 6th arg (ctx.t).
  When present, the image-missing fallback string is looked up via the
  new `image_missing_fmt` key in strings.lua. Callers without t (the
  launcher-test bytecopy) get the hardcoded English string verbatim,
  matching previous behavior.
- panels/detail.lua: both md.render call sites now thread ctx.t through.
- strings.lua: add image_missing_fmt = "[image missing: %s]".
- icons.lua: deleted. The v0.2.0 status-glyph helper was replaced by
  dep_glyph_* string keys in v0.3.0; grep confirmed no remaining refs.
- manifest.module: bump 0.3.2 -> 0.3.3.
This commit is contained in:
Calic
2026-06-13 13:31:36 +02:00
parent a7dc368712
commit 6917529778
5 changed files with 14 additions and 89 deletions

View File

@@ -1,84 +0,0 @@
-- icons.lua — inline status-icon primitives for the launcher.
--
-- The engine ships text + rect bindings; no sprites, no draw_circle yet,
-- so every icon is composed from draw_rect + draw_text. Each helper
-- returns the rect it occupied so the caller can stash it for hit-tests
-- (tooltip + update-badge click).
local M = {}
M.SPINNER_COLOR = 0xC0C0C0FF
M.WARN_COLOR = 0xFFD000FF
M.UPDATE_COLOR = 0x4090FFFF
M.ERROR_COLOR = 0xFF4040FF
M.LOCAL_COLOR = 0x707070FF -- muted gray for "local-only" repos
M.ICON_W = 16
M.ICON_H = 16
local SPINNER_GLYPHS = { "|", "/", "-", "\\" }
-- Spinner: rotating ASCII glyph cycled at ~7.5 Hz at 60 fps (every 8
-- frames). Returns its bounding rect so the caller can hit-test for
-- tooltip ("checking for updates...").
function M.draw_spinner(x, y, frame)
local glyph = SPINNER_GLYPHS[(math.floor(frame / 8) % 4) + 1]
engine.render.draw_text(glyph, x + 4, y, 12, M.SPINNER_COLOR)
return { x = x, y = y, w = M.ICON_W, h = M.ICON_H }
end
-- Warn: yellow square with "!" centered.
function M.draw_warn(x, y)
engine.render.draw_rect(x, y, M.ICON_W, M.ICON_H, M.WARN_COLOR)
engine.render.draw_text("!", x + 5, y, 14, 0x000000FF)
return { x = x, y = y, w = M.ICON_W, h = M.ICON_H }
end
-- Update badge: blue pill "^v0.5.5". Width depends on the version
-- string; returned rect carries the dynamic width so callers can do
-- right-to-left layout and click-hit-tests.
function M.draw_update_badge(x, y, version_str)
local label = "^" .. version_str
local tw, _ = engine.render.measure_text(label, 12)
local w = tw + 10
engine.render.draw_rect(x, y, w, M.ICON_H, M.UPDATE_COLOR)
engine.render.draw_text(label, x + 5, y + 1, 12, 0xFFFFFFFF)
return { x = x, y = y, w = w, h = M.ICON_H }
end
-- Error: red square with white "!" — same shape as warn but different
-- color so colorblind users still see the shape difference via the
-- background tint contrast.
function M.draw_error(x, y)
engine.render.draw_rect(x, y, M.ICON_W, M.ICON_H, M.ERROR_COLOR)
engine.render.draw_text("!", x + 5, y, 14, 0xFFFFFFFF)
return { x = x, y = y, w = M.ICON_W, h = M.ICON_H }
end
-- Local-only: muted-gray pill with "L" — module exists in the local
-- install but the remote returns 404 even with credentials, so the
-- update channel doesn't apply. Informational, not a warning.
function M.draw_local(x, y)
engine.render.draw_rect(x, y, M.ICON_W, M.ICON_H, M.LOCAL_COLOR)
engine.render.draw_text("L", x + 5, y, 12, 0xFFFFFFFF)
return { x = x, y = y, w = M.ICON_W, h = M.ICON_H }
end
-- Tooltip: small dark panel anchored to the right of (mx, my).
-- Centered vertically on the cursor. Clamped to screen via the
-- screen-size args.
function M.draw_tooltip(mx, my, text, screen_w, screen_h)
if not text or text == "" then return end
local tw, th = engine.render.measure_text(text, 12)
local pad_x, pad_y = 6, 3
local w, h = tw + 2 * pad_x, th + 2 * pad_y
local x = mx + 14
local y = my - h / 2
if x + w > screen_w then x = mx - w - 8 end
if y < 0 then y = 0 end
if y + h > screen_h then y = screen_h - h end
engine.render.draw_rect(x, y, w, h, 0x202020E0)
engine.render.draw_text(text, x + pad_x, y + pad_y, 12, 0xFFFFFFFF)
end
return M

View File

@@ -1,6 +1,6 @@
{ {
"id": "lib-management.launcher", "id": "lib-management.launcher",
"version": "0.3.2", "version": "0.3.3",
"kind": "module", "kind": "module",
"api": "^0.1", "api": "^0.1",
"ci_frames": 10, "ci_frames": 10,

View File

@@ -176,7 +176,11 @@ local function render_spans(spans, x, y, max_w, size)
return cur_y + line_h return cur_y + line_h
end end
function M.render(blocks, x, y, max_w, module_id_for_imgs) -- `t` (optional, 6th arg) is the launcher's ctx.t string-lookup function.
-- When present, M.render uses it to localize the image-missing placeholder
-- via the `image_missing_fmt` key. Callers that don't have a t (e.g. tests)
-- may pass nil; the hardcoded English fallback then renders verbatim.
function M.render(blocks, x, y, max_w, module_id_for_imgs, t)
local cur_y = y local cur_y = y
for _, b in ipairs(blocks) do for _, b in ipairs(blocks) do
if b.type == "h1" then if b.type == "h1" then
@@ -216,7 +220,9 @@ function M.render(blocks, x, y, max_w, module_id_for_imgs)
-- assume a 16:9 max_w-wide image for layout. -- assume a 16:9 max_w-wide image for layout.
cur_y = cur_y + math.floor(max_w * 9 / 16) + PARA_GAP cur_y = cur_y + math.floor(max_w * 9 / 16) + PARA_GAP
else else
engine.render.draw_text("[image missing: " .. b.src .. "]", local missing_text = t and t("image_missing_fmt", b.src)
or ("[image missing: " .. b.src .. "]")
engine.render.draw_text(missing_text,
x, cur_y, BODY_SIZE, COLOR_DIM) x, cur_y, BODY_SIZE, COLOR_DIM)
local _, h = engine.render.measure_text("[image]", BODY_SIZE) local _, h = engine.render.measure_text("[image]", BODY_SIZE)
cur_y = cur_y + h + PARA_GAP cur_y = cur_y + h + PARA_GAP

View File

@@ -90,7 +90,7 @@ function M.render(ctx)
local scroll = clamp_scroll(ctx) local scroll = clamp_scroll(ctx)
engine.render.begin_view(view, scroll_cam(view, scroll)) engine.render.begin_view(view, scroll_cam(view, scroll))
local body = ctx.news_body_blocks or {} local body = ctx.news_body_blocks or {}
local end_y = md.render(body, p.x + PADDING, p.y + PADDING, p.w - 2 * PADDING, nil) local end_y = md.render(body, p.x + PADDING, p.y + PADDING, p.w - 2 * PADDING, nil, ctx.t)
engine.render.end_view() engine.render.end_view()
ctx.detail_content_h = (end_y - view.y) + PADDING ctx.detail_content_h = (end_y - view.y) + PADDING
ctx.detail_view_h = view.h ctx.detail_view_h = view.h
@@ -137,7 +137,7 @@ function M.render(ctx)
-- Description (rendered MD). -- Description (rendered MD).
ensure_md(ctx.launcher_dir) ensure_md(ctx.launcher_dir)
cur_y = md.render(mc.blocks, p.x + PADDING, cur_y, cur_y = md.render(mc.blocks, p.x + PADDING, cur_y,
p.w - 2 * PADDING, entry.id) p.w - 2 * PADDING, entry.id, ctx.t)
cur_y = cur_y + 12 cur_y = cur_y + 12

View File

@@ -22,4 +22,7 @@ return {
no = "No", no = "No",
-- News entry default title -- News entry default title
news_default_title = "News", news_default_title = "News",
-- Markdown image-missing placeholder (rendered by markdown.lua when
-- engine.module.load_texture returns nil for an inline image source).
image_missing_fmt = "[image missing: %s]",
} }