diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-06 12:42:32 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-06 14:56:36 -0300 |
| commit | 34a80c9f9b81b64d095a1d5123ae74a52bef4749 (patch) | |
| tree | 618eb5f3d1bd04e659ba6389977d017aff4f4033 /src/keys.zig | |
| parent | 9b60771ffcd254772b716fafe488b09d9c2d3e0c (diff) | |
| download | pardes-34a80c9f9b81b64d095a1d5123ae74a52bef4749.tar.gz pardes-34a80c9f9b81b64d095a1d5123ae74a52bef4749.zip | |
idioms #17, the rest of the core says its failures: tagline, keys, panes, Effect and the header text in mouse report a failed allocation or shell where they returned with nothing said, the headers' own text (flatSurface makes none) and the prints whose buffer provably fits (layout, modal, panes, keys, colors) catch unreachable with why
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/keys.zig')
| -rw-r--r-- | src/keys.zig | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/keys.zig b/src/keys.zig index e6b417a9..ece79651 100644 --- a/src/keys.zig +++ b/src/keys.zig @@ -90,8 +90,8 @@ pub fn questionChoices(p: *const Pardes, id: usize, buf: []u8) ?[]const u8 { const ask = p.repl_ask orelse return null; var w = std.Io.Writer.fixed(buf); for (ask.offered, 0..) |serial, i| if (serial != 0) { - if (w.buffered().len > 0) w.writeByte(' ') catch {}; - w.writeByte(@intCast('a' + i)) catch {}; + if (w.buffered().len > 0) w.writeByte(' ') catch unreachable; // 26 letters and spaces fit 64 + w.writeByte(@intCast('a' + i)) catch unreachable; }; return w.buffered(); }, @@ -112,7 +112,7 @@ pub fn answerQuestion(p: *Pardes, id: usize, choice: ?u8) bool { if (questionChoices(p, id, &offered)) |choices| { const chosen: ?u8 = if (choice) |c| (if (std.mem.indexOfScalar(u8, choices, c) != null and c != ' ') c else null) else null; var rec: [32]u8 = undefined; - ctlfs.events.notePath(p, "answer", std.fmt.bufPrint(&rec, "{d} {c}", .{ asked.serial, chosen orelse '-' }) catch ""); + ctlfs.events.notePath(p, "answer", std.fmt.bufPrint(&rec, "{d} {c}", .{ asked.serial, chosen orelse '-' }) catch unreachable); // a u32 and a letter } switch (asked.prompt) { .repl_choice => { @@ -258,7 +258,7 @@ pub fn handleKey(p: *Pardes, key: Key) void { // the active terminal into a fresh column if (hit(key, config.new_shell_below)) { const free = p.freeSlot() orelse return p.reportError(p.view().active, "Term", error.NoPaneSlots); - const nt = p.newShell(free, "") catch return; + const nt = p.newShell(free, "") catch |err| return p.reportError(p.view().active, "Term", err); nt.greet = true; // From a tag, as a 9P new is: acme's t->w == nil. exec.placeNew(p, p.view().active, if (p.view().header != null) null else p.view().active, free, .shell); @@ -340,7 +340,7 @@ pub fn handleKey(p: *Pardes, key: Key) void { if (t.what != .body) { // An explicit selection, else the word under the cursor in the // text as it is shown: a tag's prefix is part of what a word is. - const shown = p.scratch.allocator().dupe(u8, edit.flatSurface(p, t) catch return) catch return; + const shown = p.scratch.allocator().dupe(u8, edit.flatSurface(p, t) catch |err| return p.reportError(p.view().active, "exec", err)) catch |err| return p.reportError(p.view().active, "exec", err); const range = t.primaryRange(shown, 0); const lo = @min(range.anchor, range.head); const hi = @max(range.anchor, range.head); @@ -417,7 +417,7 @@ pub fn handleKey(p: *Pardes, key: Key) void { Macro.append(&m.command, p.gpa, key); if (t.mode == .insert) { m.last_insert.clearRetainingCapacity(); - m.last_insert.appendSlice(p.gpa, m.command.items) catch {}; + m.last_insert.appendSlice(p.gpa, m.command.items) catch |err| p.reportError(p.view().active, "macro", err); m.typed_from = m.last_insert.items.len; m.inserting = true; m.command.clearRetainingCapacity(); |
