summaryrefslogtreecommitdiff
path: root/src/colors.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-06 13:16:18 -0300
committerGabriel Schneider <[email protected]>2026-11-06 14:56:36 -0300
commita821fe82d8de3d407ebe104358b97719bd983727 (patch)
tree46301f10f599983fc1be9b9ac38df8d2e6d0bf71 /src/colors.zig
parentd78fa4f9d90437dac60d9150e3a6eca868895856 (diff)
downloadpardes-a821fe82d8de3d407ebe104358b97719bd983727.tar.gz
pardes-a821fe82d8de3d407ebe104358b97719bd983727.zip
idioms #19, unreachable only where the type bounds it: the prints that carry a path, a name, a miss or a reason (Core's shell and Dump words, colors' theme file, look's misses and refusals) cut through Kind.Buf at their old size, the header texts flatSurface could still fail on and colors' putName handle the failure again, and every kept site (integers, a same-statement cut into a [K + room] buffer, the hashing and discarding writers) says its bound on its line
Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/colors.zig')
-rw-r--r--src/colors.zig6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/colors.zig b/src/colors.zig
index 65fd4056..f9e5495f 100644
--- a/src/colors.zig
+++ b/src/colors.zig
@@ -673,10 +673,10 @@ fn themeFileError(p: *Pardes, request: ThemeFileRequest, err: anyerror) void {
}
fn themeFileFailure(p: *Pardes, request: ThemeFileRequest, why: []const u8) void {
- var said: [520]u8 = undefined;
+ var said: pardes.Kind.Buf(520) = .{};
var cut: [200]u8 = undefined;
const path = @import("ninep/tree.zig").fitErr(request.path, &cut);
- p.reportFailure(request.pane, std.fmt.bufPrint(&said, "theme file {s}: {s}", .{ path, why }) catch unreachable); // two 200-byte parts fit 520
+ p.reportFailure(request.pane, said.print("theme file {s}: {s}", .{ path, why }));
revertThemeFile(p);
}
@@ -778,7 +778,7 @@ pub fn themesNear(buf: []u8, name: []const u8) []const u8 {
fn putName(w: *std.Io.Writer, cap: usize, name: []const u8) bool {
const sep: []const u8 = if (w.buffered().len > 0) " " else "";
if (w.buffered().len + sep.len + name.len > cap) return false;
- w.print("{s}{s}", .{ sep, name }) catch unreachable; // fits: checked above
+ w.print("{s}{s}", .{ sep, name }) catch return false;
return true;
}