summaryrefslogtreecommitdiff
path: root/src/mouse.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/mouse.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/mouse.zig')
-rw-r--r--src/mouse.zig6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/mouse.zig b/src/mouse.zig
index 936e504d..4c909104 100644
--- a/src/mouse.zig
+++ b/src/mouse.zig
@@ -97,7 +97,7 @@ fn headerPoint(p: *Pardes, column: ?usize, mcol: u16, mrow: u16, clamp: bool) ?s
const t = if (column) |c| &v.col_tags[c] else &p.global_tag;
const x = if (column) |c| v.col_x[c] + TAG_TEXT_INSET else TAG_TEXT_INSET;
const focused = v.header != null and p.headerColumn() == column;
- const text = edit.flatSurface(p, t) catch unreachable; // a header's text is its own
+ const text = edit.flatSurface(p, t) catch return null;
const base = if (column != null) p.topBarHeight() else 0;
const rows = if (column != null) layout.columnBarHeight(p) else p.topBarHeight();
const row: u16 = if (clamp) @min(mrow -| base, rows -| 1) else mrow -| base;
@@ -118,7 +118,7 @@ fn headerSweepRun(p: *Pardes, sweep: HeaderSweep) void {
const v = p.view();
const column = sweep.column(p) catch return; // error.Gone: its column closed under the sweep
const t = if (column) |c| &v.col_tags[c] else &p.global_tag;
- const text = edit.flatSurface(p, t) catch unreachable; // a header's text is its own
+ const text = edit.flatSurface(p, t) catch |err| return p.reportError(v.active, "edit", err);
const swept = sweep.span(text.len);
const selected = if (swept.lo < swept.hi) text[swept.lo..swept.hi] else click: {
const line = std.mem.count(u8, text[0..swept.lo], "\n");
@@ -1304,7 +1304,7 @@ fn dragRelease(p: *Pardes, button: Mouse.Button) void {
if (line >= 0) {
pane.sel[b].state = .none;
var buf: [48]u8 = undefined;
- const target = std.fmt.bufPrint(&buf, "@p{d}:{d}", .{ pane.serial, @as(usize, @intCast(line)) + 1 }) catch unreachable; // 33 bytes at most
+ const target = std.fmt.bufPrint(&buf, "@p{d}:{d}", .{ pane.serial, @as(usize, @intCast(line)) + 1 }) catch unreachable; // a u32 and a usize fit 48
exec.runBuiltin(p, config.look_cmd, s.id, "", target);
return;
}