From ed79628fba21909b3183e2499d4240ebc21011be Mon Sep 17 00:00:00 2001 From: Forketyfork Date: Sat, 30 May 2026 21:13:45 +0200 Subject: [PATCH 1/2] refactor: remove unused declarations flagged by the linter Issue: The dead-code linter reported four public declarations that no code references: two SDL renderer flag constants in c.zig, fillCircle in gfx/primitives.zig, and keyToChar in input/mapper.zig. Solution: Remove all four after confirming no callers exist anywhere in the repo. VSync is configured through SDL_SetRenderVSync rather than the renderer flags, and key encoding goes through encodeKey rather than the char-mapping helper, so nothing depends on the removed code. --- src/c.zig | 8 -------- src/gfx/primitives.zig | 13 ------------ src/input/mapper.zig | 45 ------------------------------------------ 3 files changed, 66 deletions(-) diff --git a/src/c.zig b/src/c.zig index 31497cd5..c206582d 100644 --- a/src/c.zig +++ b/src/c.zig @@ -38,14 +38,6 @@ pub const SDL_SetTextureBlendMode = c_import.SDL_SetTextureBlendMode; pub const SDL_SetTextureAlphaMod = c_import.SDL_SetTextureAlphaMod; pub const SDL_SetRenderVSync = c_import.SDL_SetRenderVSync; pub const SDL_RenderTexture = c_import.SDL_RenderTexture; -pub const SDL_RENDERER_ACCELERATED: c_import.Uint32 = if (@hasDecl(c_import, "SDL_RENDERER_ACCELERATED")) - c_import.SDL_RENDERER_ACCELERATED -else - 0x0000_0002; -pub const SDL_RENDERER_PRESENTVSYNC: c_import.Uint32 = if (@hasDecl(c_import, "SDL_RENDERER_PRESENTVSYNC")) - c_import.SDL_RENDERER_PRESENTVSYNC -else - 0x0000_0004; pub const SDL_SetRenderDrawBlendMode = c_import.SDL_SetRenderDrawBlendMode; pub const SDL_SetRenderClipRect = c_import.SDL_SetRenderClipRect; pub const SDL_GetRenderClipRect = c_import.SDL_GetRenderClipRect; diff --git a/src/gfx/primitives.zig b/src/gfx/primitives.zig index 3756a6b5..03aafacf 100644 --- a/src/gfx/primitives.zig +++ b/src/gfx/primitives.zig @@ -180,19 +180,6 @@ pub fn fillRoundedRect(renderer: *c.SDL_Renderer, rect: Rect, radius: c_int) voi } } -pub fn fillCircle(renderer: *c.SDL_Renderer, cx: f32, cy: f32, radius: f32) void { - const r_int: c_int = @intFromFloat(radius); - var dy: c_int = -r_int; - while (dy <= r_int) : (dy += 1) { - const dy_f: f32 = @floatFromInt(dy); - const dx_sq = radius * radius - dy_f * dy_f; - if (dx_sq > 0) { - const dx = @sqrt(dx_sq); - _ = c.SDL_RenderLine(renderer, cx - dx, cy + dy_f, cx + dx, cy + dy_f); - } - } -} - pub fn renderBezierArrow( renderer: *c.SDL_Renderer, x1: f32, diff --git a/src/input/mapper.zig b/src/input/mapper.zig index 02604632..390c2831 100644 --- a/src/input/mapper.zig +++ b/src/input/mapper.zig @@ -79,51 +79,6 @@ fn computeCsiModifier(mod: c.SDL_Keymod) u8 { return result; } -pub fn keyToChar(key: c.SDL_Keycode, mod: c.SDL_Keymod) ?u8 { - const shift = (mod & c.SDL_KMOD_SHIFT) != 0; - - if (key >= c.SDLK_A and key <= c.SDLK_Z) { - const base: u8 = @intCast(key - c.SDLK_A); - return if (shift) 'A' + base else 'a' + base; - } - - if (key >= c.SDLK_0 and key <= c.SDLK_9) { - if (shift) { - return switch (key) { - c.SDLK_0 => ')', - c.SDLK_1 => '!', - c.SDLK_2 => '@', - c.SDLK_3 => '#', - c.SDLK_4 => '$', - c.SDLK_5 => '%', - c.SDLK_6 => '^', - c.SDLK_7 => '&', - c.SDLK_8 => '*', - c.SDLK_9 => '(', - else => null, - }; - } - const base: u8 = @intCast(key - c.SDLK_0); - return '0' + base; - } - - return switch (key) { - c.SDLK_SPACE => ' ', - c.SDLK_MINUS => if (shift) '_' else '-', - c.SDLK_EQUALS => if (shift) '+' else '=', - c.SDLK_LEFTBRACKET => if (shift) '{' else '[', - c.SDLK_RIGHTBRACKET => if (shift) '}' else ']', - c.SDLK_BACKSLASH => if (shift) '|' else '\\', - c.SDLK_SEMICOLON => if (shift) ':' else ';', - c.SDLK_APOSTROPHE => if (shift) '"' else '\'', - c.SDLK_GRAVE => if (shift) '~' else '`', - c.SDLK_COMMA => if (shift) '<' else ',', - c.SDLK_PERIOD => if (shift) '>' else '.', - c.SDLK_SLASH => if (shift) '?' else '/', - else => null, - }; -} - /// Encodes an SDL key with modifiers into a terminal escape sequence. /// cursor_keys: when true (DECCKM mode set), arrow keys use SS3 sequences (\x1bO...) /// kitty_enabled: when true, use Kitty keyboard protocol for modified special keys From 090d60cfccd2f428667b01ad045e8c4b748629bd Mon Sep 17 00:00:00 2001 From: Forketyfork Date: Sat, 30 May 2026 21:18:41 +0200 Subject: [PATCH 2/2] docs: drop fillCircle from architecture helper list The gfx/* module table in ARCHITECTURE.md still advertised filled circles and fillCircle() after the function was removed. Update the description and helper list so the rendering utility surface matches the code. Addresses review comment on PR #327. --- docs/ARCHITECTURE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 8b604ddf..bba1ca5d 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -408,7 +408,7 @@ Rotate: rename active file to architect-.log and continue in new | `session/*` (shell, pty, vt_stream, cwd) | Shell spawning, PTY abstraction, VT parsing, working directory detection | `spawn()`, `Pty`, `VtStream.processBytes()`, `getCwd()` | std (posix), ghostty-vt | | `render/renderer.zig` | Scene rendering: terminals, borders, animations, terminal scrollbar painting | `render()`, `RenderCache`, per-session texture management | `font`, `font_cache`, `gfx/*`, `anim/easing`, `app/app_state`, `ui/components/scrollbar`, `c` | | `font.zig` + `font_cache.zig` | Font rendering, HarfBuzz shaping, glyph LRU cache, shared font cache | `Font`, `openFont()`, `renderGlyph()`, `FontCache`, `getOrCreate()` | `font_paths`, `c` (SDL3_ttf) | -| `gfx/*` (box_drawing, primitives) | Procedural box-drawing characters (U+2500-U+257F), rounded/thick border helpers, filled circles, bezier arrow rendering | `renderBoxDrawing()`, `drawRoundedRect()`, `drawThickBorder()`, `fillCircle()`, `fillRoundedRect()`, `renderBezierArrow()` | `c` | +| `gfx/*` (box_drawing, primitives) | Procedural box-drawing characters (U+2500-U+257F), rounded/thick border helpers, bezier arrow rendering | `renderBoxDrawing()`, `drawRoundedRect()`, `drawThickBorder()`, `fillRoundedRect()`, `renderBezierArrow()` | `c` | | `ui/root.zig` | UI component registry, z-index dispatch, action drain | `UiRoot`, `register()`, `handleEvent()`, `update()`, `render()`, `needsFrame()` | `ui/component`, `ui/types` | | `ui/component.zig` | UI component vtable interface | `UiComponent`, `VTable` (handleEvent, update, render, hitTest, wantsFrame, deinit) | `ui/types`, `c` | | `ui/types.zig` | Shared UI type definitions | `UiHost`, `UiAction`, `UiActionQueue`, `UiAssets`, `SessionUiInfo` | `app/app_state`, `colors`, `font`, `geom` |