summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Core.zig27
-rw-r--r--src/File.zig10
-rw-r--r--src/colors.zig6
-rw-r--r--src/edit.zig2
-rw-r--r--src/keys.zig4
-rw-r--r--src/layout.zig4
-rw-r--r--src/look.zig48
-rw-r--r--src/modal.zig2
-rw-r--r--src/mouse.zig6
-rw-r--r--src/panes.zig2
-rw-r--r--src/tagline.zig6
-rw-r--r--src/terminal.zig2
12 files changed, 59 insertions, 60 deletions
diff --git a/src/Core.zig b/src/Core.zig
index 413de233..775d1e9a 100644
--- a/src/Core.zig
+++ b/src/Core.zig
@@ -531,7 +531,7 @@ fn initSession(gpa: std.mem.Allocator, opts: Options) !*Pardes {
if (opts.file_line > 0) {
var said: pardes.Kind.Buf(160) = .{};
var place: [20]u8 = undefined;
- _ = pardes.Kind.address(p, 0, std.fmt.bufPrint(&place, "{d}", .{opts.file_line}) catch unreachable, &said); // a usize
+ _ = pardes.Kind.address(p, 0, std.fmt.bufPrint(&place, "{d}", .{opts.file_line}) catch unreachable, &said); // a usize fits 20
}
} else |_| {}
break :initial_doc made;
@@ -1296,10 +1296,10 @@ fn sayShellFailure(p: *Pardes, id: u8, err: anyerror) void {
p.reportFailure(id, "shell: directory missing (no such directory)");
} else if (err == error.InterpreterNotFound) {
// The script is there; the program its `#!` names is not.
- var said: [320]u8 = undefined;
+ var said: pardes.Kind.Buf(320) = .{};
var interp: [256]u8 = undefined;
const name = tape.value(.interpreter, missingInterpreter, .{ pane.shell orelse p.shellBin(), &interp });
- p.reportFailure(id, if (name) |n| std.fmt.bufPrint(&said, "shell: interpreter {s} not found", .{n}) catch unreachable else "shell: interpreter not found");
+ p.reportFailure(id, if (name) |n| said.print("shell: interpreter {s} not found", .{n}) else "shell: interpreter not found");
} else {
p.reportError(id, "shell", err);
}
@@ -1338,13 +1338,12 @@ pub fn saveFailed(p: *Pardes, id: u8, path: []const u8, err: anyerror) void {
// A write into a directory that is not there: said so, in the words
// a mount reads as ENOENT; EACCES when one above refuses.
const parent = parentTrouble(path, err);
- const shown = path[0..@min(path.len, limits.host_path_cap)]; // what fits `what`
if (parent.denied)
- p.reportFailure(id, std.fmt.bufPrint(&what, "Save {s}: permission denied", .{shown}) catch unreachable)
+ p.reportFailure(id, std.fmt.bufPrint(&what, "Save {s}: permission denied", .{path[0..@min(path.len, limits.host_path_cap)]}) catch unreachable) // cap + 24 fits cap + 32
else if (parent.missing)
- p.reportFailure(id, std.fmt.bufPrint(&what, "Save {s}: no such directory", .{shown}) catch unreachable)
+ p.reportFailure(id, std.fmt.bufPrint(&what, "Save {s}: no such directory", .{path[0..@min(path.len, limits.host_path_cap)]}) catch unreachable) // cap + 24 fits cap + 32
else
- p.reportError(id, std.fmt.bufPrint(&what, "Save {s}", .{shown}) catch unreachable, err);
+ p.reportError(id, std.fmt.bufPrint(&what, "Save {s}", .{path[0..@min(path.len, limits.host_path_cap)]}) catch unreachable, err); // cap + 5 fits cap + 32
p.noteLateFailure(id);
}
@@ -1356,17 +1355,17 @@ pub fn dumpFailed(p: *Pardes, path: []const u8, err: anyerror) void {
const taped = tape.enter(p, .{ .dump_failed = .{ .path = path, .err = err } });
defer tape.leave(p, taped);
var what: [limits.host_path_cap + 8]u8 = undefined;
- const operation = std.fmt.bufPrint(&what, "Dump {s}", .{path[0..@min(path.len, limits.host_path_cap)]}) catch unreachable;
+ const operation = std.fmt.bufPrint(&what, "Dump {s}", .{path[0..@min(path.len, limits.host_path_cap)]}) catch unreachable; // cap + 5 fits cap + 8
// Into a DumpDir that is not there: said so, ENOENT, as a Save is;
// one that is there but no directory (`/dev/null`) says that.
const parent = parentTrouble(path, err);
- var said: [limits.host_path_cap + 48]u8 = undefined;
+ var said: pardes.Kind.Buf(limits.host_path_cap + 48) = .{};
if (parent.denied and parent.kind == null)
- p.reportFailure(v.active, std.fmt.bufPrint(&said, "{s}: permission denied", .{operation}) catch unreachable) // `what` and 19 bytes
+ p.reportFailure(v.active, said.print("{s}: permission denied", .{operation}))
else if (parent.kind != null and parent.kind != .directory)
- p.reportFailure(v.active, std.fmt.bufPrint(&said, "{s}: {s} is not a directory", .{ operation, parent.dir }) catch "Dump: not a directory")
+ p.reportFailure(v.active, said.print("{s}: {s} is not a directory", .{ operation, parent.dir }))
else if (parent.missing)
- p.reportFailure(v.active, std.fmt.bufPrint(&said, "{s}: no such directory", .{operation}) catch unreachable)
+ p.reportFailure(v.active, said.print("{s}: no such directory", .{operation}))
else
p.reportError(v.active, operation, err);
// In the words the message row has, so the write's err is the one
@@ -1734,8 +1733,8 @@ pub fn windowOpacityDone(p: *Pardes, applied: u8, failure: ?[]const u8) void {
// Do not claim a value the compositor refused; an explicit retry of
// the same command will arm a new request.
p.settings.window_opacity = applied;
- var buf: [256]u8 = undefined;
- p.setMessage(p.view().active, std.fmt.bufPrint(&buf, "WindowOpacity: {s}", .{reason[0..@min(reason.len, 240)]}) catch unreachable); // 255 bytes
+ var buf: [240 + 16]u8 = undefined;
+ p.setMessage(p.view().active, std.fmt.bufPrint(&buf, "WindowOpacity: {s}", .{reason[0..@min(reason.len, 240)]}) catch unreachable); // 240 + 15 fits 240 + 16
}
/// Recompute geometry, push grid-size changes to each emulator and pty,
diff --git a/src/File.zig b/src/File.zig
index 01c605bf..1c40379d 100644
--- a/src/File.zig
+++ b/src/File.zig
@@ -1512,9 +1512,9 @@ pub fn deleted(p: *Pardes, id: u8) void {
if (f.disk_gone) return;
f.disk_gone = true;
var said: [limits.host_path_cap + 64]u8 = undefined;
- p.setMessage(id, std.fmt.bufPrint(&said, "{s} deleted on disk (Save writes it again)", .{f.path[0..@min(f.path.len, limits.host_path_cap)]}) catch unreachable);
+ p.setMessage(id, std.fmt.bufPrint(&said, "{s} deleted on disk (Save writes it again)", .{f.path[0..@min(f.path.len, limits.host_path_cap)]}) catch unreachable); // cap + 52 fits cap + 64
var rec: [32]u8 = undefined;
- pardes.ctlfs.events.notePath(p, "changed", std.fmt.bufPrint(&rec, "{d} deleted", .{pane.serial}) catch unreachable); // a u32
+ pardes.ctlfs.events.notePath(p, "changed", std.fmt.bufPrint(&rec, "{d} deleted", .{pane.serial}) catch unreachable); // a u32 fits 32
}
/// A file rewritten on disk. A clean buffer takes the new text, committed
@@ -1539,15 +1539,15 @@ pub fn changed(p: *Pardes, id: u8, bytes: []const u8) void {
f.disk_newer = disk;
f.disk_newer_warned = false;
var said: [limits.host_path_cap + 64]u8 = undefined;
- p.setMessage(id, std.fmt.bufPrint(&said, "{s} changed on disk (get reloads it, Save overwrites it)", .{f.path[0..@min(f.path.len, limits.host_path_cap)]}) catch unreachable);
+ p.setMessage(id, std.fmt.bufPrint(&said, "{s} changed on disk (get reloads it, Save overwrites it)", .{f.path[0..@min(f.path.len, limits.host_path_cap)]}) catch unreachable); // cap + 52 fits cap + 64
var rec: [16]u8 = undefined;
- pardes.ctlfs.events.notePath(p, "changed", std.fmt.bufPrint(&rec, "{d}", .{pane.serial}) catch unreachable); // a u32
+ pardes.ctlfs.events.notePath(p, "changed", std.fmt.bufPrint(&rec, "{d}", .{pane.serial}) catch unreachable); // a u32 fits 16
return;
};
f.disk_newer = null;
// Logged as the dirty case is, with what became of it.
var rec: [32]u8 = undefined;
- pardes.ctlfs.events.notePath(p, "changed", std.fmt.bufPrint(&rec, "{d} reloaded", .{pane.serial}) catch unreachable); // a u32
+ pardes.ctlfs.events.notePath(p, "changed", std.fmt.bufPrint(&rec, "{d} reloaded", .{pane.serial}) catch unreachable); // a u32 fits 32
const new = p.gpa.dupe(u8, bytes) catch |err| return p.reportError(id, "reload", err);
pushUndo(p, pane);
setContent(p, f, new);
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;
}
diff --git a/src/edit.zig b/src/edit.zig
index d4795c94..4253d293 100644
--- a/src/edit.zig
+++ b/src/edit.zig
@@ -119,7 +119,7 @@ pub fn applyPaste(p: *Pardes, whole: []const u8) Error!void {
const bytes = if (whole.len > limit) whole[0..modal.graphemeStart(whole, limit)] else whole;
if (whole.len > limit) {
var said: [96]u8 = undefined;
- p.setMessage(v.active, std.fmt.bufPrint(&said, "paste cut at its limit, {d} KiB: the rest left out", .{limit / 1024}) catch unreachable); // 67 bytes at most
+ p.setMessage(v.active, std.fmt.bufPrint(&said, "paste cut at its limit, {d} KiB: the rest left out", .{limit / 1024}) catch unreachable); // a usize and 47 bytes fit 96
}
// A prompt answering for a header takes the paste, as it takes keys.
const asking = if (p.panes[v.active]) |active| active.prompt != .none else false;
diff --git a/src/keys.zig b/src/keys.zig
index ece79651..5ebdc046 100644
--- a/src/keys.zig
+++ b/src/keys.zig
@@ -91,7 +91,7 @@ pub fn questionChoices(p: *const Pardes, id: usize, buf: []u8) ?[]const u8 {
var w = std.Io.Writer.fixed(buf);
for (ask.offered, 0..) |serial, i| if (serial != 0) {
if (w.buffered().len > 0) w.writeByte(' ') catch unreachable; // 26 letters and spaces fit 64
- w.writeByte(@intCast('a' + i)) catch unreachable;
+ w.writeByte(@intCast('a' + i)) catch unreachable; // [26]u32 offered: 51 bytes fit 64
};
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 unreachable); // a u32 and a letter
+ ctlfs.events.notePath(p, "answer", std.fmt.bufPrint(&rec, "{d} {c}", .{ asked.serial, chosen orelse '-' }) catch unreachable); // a u32 and a letter fit 32
}
switch (asked.prompt) {
.repl_choice => {
diff --git a/src/layout.zig b/src/layout.zig
index 0b11fe1b..3475dbbf 100644
--- a/src/layout.zig
+++ b/src/layout.zig
@@ -493,7 +493,7 @@ pub fn dropColumnUnannounced(p: *Pardes, c: usize) void {
/// as /layout and /col name it.
pub fn noteColumn(p: *Pardes, what: []const u8, serial: u32) void {
var buf: [16]u8 = undefined;
- pardes.ctlfs.events.notePath(p, what, std.fmt.bufPrint(&buf, "{d}", .{serial}) catch unreachable); // a u32
+ pardes.ctlfs.events.notePath(p, what, std.fmt.bufPrint(&buf, "{d}", .{serial}) catch unreachable); // a u32 fits 16
}
/// Fold column `c` into the one on its right, its panes below theirs.
@@ -1741,7 +1741,7 @@ pub fn newColumn(p: *Pardes, from_id: usize) void {
const c = insertColumnUnannounced(p, col, false) orelse {
var said: [96]u8 = undefined;
return p.reportFailure(from_id, if (p.view().ncol >= MAX_COLS)
- std.fmt.bufPrint(&said, "Newcol: no space for a column: {d} max", .{MAX_COLS}) catch unreachable
+ std.fmt.bufPrint(&said, "Newcol: no space for a column: {d} max", .{MAX_COLS}) catch unreachable // an integer and 34 bytes fit 96
else
"Newcol: no space for a column: this one is too narrow to split");
};
diff --git a/src/look.zig b/src/look.zig
index 8f5ed900..aee96513 100644
--- a/src/look.zig
+++ b/src/look.zig
@@ -635,7 +635,7 @@ pub fn runSearch(p: *Pardes, id: usize, pat_raw: []const u8, start: SearchStart,
const loc: []const u8 = if (has_path)
std.Io.Dir.path.basename(pane.file.?.path)
else
- std.fmt.bufPrint(&idbuf, config.pane_addr ++ "{d}", .{pane.serial}) catch unreachable; // `@p` and a u32: 12 bytes
+ std.fmt.bufPrint(&idbuf, config.pane_addr ++ "{d}", .{pane.serial}) catch unreachable; // `@p` and a u32 fit 16
const cl: usize = @intCast(@max(0, pane.body.cur_row));
const cc: usize = @intCast(@max(0, pane.body.cur_col));
for (lines, 0..) |ln, i| {
@@ -1131,7 +1131,7 @@ fn canonicalLookLocation(p: *Pardes, id: usize, text: []const u8) ?[]const u8 {
if (pane.file) |file| return locationText(p, file.path, target.at);
if (pane.addon) |k| if (k.path.len > 0) return locationText(p, k.path, target.at);
var path: [32]u8 = undefined;
- return locationText(p, std.fmt.bufPrint(&path, config.pane_addr ++ "{d}", .{pane.serial}) catch unreachable, target.at); // 12 bytes
+ return locationText(p, std.fmt.bufPrint(&path, config.pane_addr ++ "{d}", .{pane.serial}) catch unreachable, target.at); // `@p` and a u32 fit 32
},
}
}
@@ -1168,8 +1168,8 @@ fn lookOpenFailed(p: *Pardes, id: usize, path: []const u8, err: anyerror) void {
const remote_missing = err == error.Remote and std.mem.indexOf(u8, @import("9p_io.zig").Client.lastSaid(), "not exist") != null;
if (err == error.FileNotFound or err == error.NotFound or remote_missing)
return missed(p, id, "{s}: no such file", .{missText(path, &cut)});
- var said: [miss_path_cap + 16]u8 = undefined;
- p.reportError(id, std.fmt.bufPrint(&said, "look: {s}", .{missText(path, &cut)}) catch unreachable, err); // missText fits miss_path_cap
+ var said: Kind.Buf(miss_path_cap + 16) = .{};
+ p.reportError(id, said.print("look: {s}", .{missText(path, &cut)}), err);
}
fn missedLine(p: *Pardes, id: usize, path: []const u8, line: usize) void {
@@ -1216,16 +1216,16 @@ test "a zero column after a path is found, in every spelling a look takes" {
fn missed(p: *Pardes, id: usize, comptime fmt: []const u8, args: anytype) void {
p.look_missed = true;
- var said: [miss_path_cap + 64]u8 = undefined;
- const why = std.fmt.bufPrint(&said, fmt, args) catch &said; // a longer miss is cut at the buffer's end
- var msg: [said.len + 8]u8 = undefined;
+ var said: Kind.Buf(miss_path_cap + 64) = .{};
+ const why = said.print(fmt, args);
+ var msg: Kind.Buf(miss_path_cap + 72) = .{};
// Shown on the pane; logged once, as the err below, not a msg too.
p.fs.unlogged = true;
- p.setMessage(id, std.fmt.bufPrint(&msg, "Look: {s}", .{why}) catch unreachable); // `why` fits `said`
+ p.setMessage(id, msg.print("Look: {s}", .{why}));
p.fs.unlogged = false;
const serial = if (p.panes[id]) |pane| pane.serial else 0;
- var rec: [said.len + 32]u8 = undefined;
- pardes.ctlfs.events.noteErrCounted(p, std.fmt.bufPrint(&rec, "{d} look: {s}", .{ serial, why }) catch unreachable); // a u32 and `why`
+ var rec: Kind.Buf(miss_path_cap + 96) = .{};
+ pardes.ctlfs.events.noteErrCounted(p, rec.print("{d} look: {s}", .{ serial, why }));
}
/// After a look at `path:N` focused its pane: a line past the end focuses
@@ -1295,9 +1295,9 @@ fn lookUnresolved(p: *Pardes, id: usize, pane: *Pane, trimmed: []const u8, text:
// that is gone, else the file named.
if (filesystem.dotRelative(trimmed)) {
const dir = Pardes.paneDir(pane);
- var said: [4200]u8 = undefined;
+ var said: [4096 + 104]u8 = undefined;
const gone = if (filesystem.localPath(dir)) |local| exec.kindOf(local) != .directory else false;
- if (gone) return p.reportFailure(id, std.fmt.bufPrint(&said, "look: {s}: no such directory", .{dir[0..@min(dir.len, 4096)]}) catch unreachable); // 4123 bytes at most
+ if (gone) return p.reportFailure(id, std.fmt.bufPrint(&said, "look: {s}: no such directory", .{dir[0..@min(dir.len, 4096)]}) catch unreachable); // 4096 + 27 fits 4096 + 104
// A file not there is a miss, as `x` and `/abs/x` are: said and
// logged, the write answered with nothing.
var cut: [miss_path_cap + "…".len]u8 = undefined;
@@ -1411,7 +1411,7 @@ fn lookAddress(p: *Pardes, id: usize, path: []const u8, expr: []const u8) void {
if ((by_serial or path.len == 0) and pane.isTerminal()) return lookTerminalAddress(p, id, target, expr);
// Named as the pane is, the bare `:addr` (path empty) included.
var serial_name: [32]u8 = undefined;
- const subject = if (pane.addon) |k| k.path else if (path.len > 0) path else std.fmt.bufPrint(&serial_name, config.pane_addr ++ "{d}", .{pane.serial}) catch unreachable; // 12 bytes
+ const subject = if (pane.addon) |k| k.path else if (path.len > 0) path else std.fmt.bufPrint(&serial_name, config.pane_addr ++ "{d}", .{pane.serial}) catch unreachable; // `@p` and a u32 fit 32
var cut: [miss_path_cap + "…".len]u8 = undefined;
return missed(p, id, "{s} is no text to address", .{missText(subject, &cut)});
};
@@ -1427,8 +1427,8 @@ fn lookAddress(p: *Pardes, id: usize, path: []const u8, expr: []const u8) void {
// A line past the end says so as `file:N` does, whichever way it
// was written: `<file>:N has no line N`.
if (std.fmt.parseInt(usize, expr, 10)) |line| {
- var placed: [miss_path_cap + "…".len + 24]u8 = undefined;
- const place = std.fmt.bufPrint(&placed, "{s}:{d}", .{ name, line }) catch unreachable; // missText and a usize
+ var placed: Kind.Buf(miss_path_cap + "…".len + 24) = .{};
+ const place = placed.print("{s}:{d}", .{ name, line });
if (!opened_here) return missedLine(p, target, place, line);
p.removePane(target, null) catch |err| p.reportError(id, "look", err);
if (p.panes[id] != null) v.active = id;
@@ -1464,7 +1464,7 @@ fn lookKind(p: *Pardes, id: usize, target: usize, expr_raw: []const u8, opened:
return;
}
var serial_name: [32]u8 = undefined;
- const subject = if (slot.path.len > 0) slot.path else std.fmt.bufPrint(&serial_name, config.pane_addr ++ "{d}", .{p.panes[target].?.serial}) catch unreachable; // 12 bytes
+ const subject = if (slot.path.len > 0) slot.path else std.fmt.bufPrint(&serial_name, config.pane_addr ++ "{d}", .{p.panes[target].?.serial}) catch unreachable; // `@p` and a u32 fit 32
var cut: [miss_path_cap + "…".len]u8 = undefined;
const name = missText(subject, &cut);
if (opened) {
@@ -1479,8 +1479,8 @@ fn lookKind(p: *Pardes, id: usize, target: usize, expr_raw: []const u8, opened:
/// A place as `address` takes it: `12`, `12:3`.
fn spotText(at: Spot, buf: *[41]u8) []const u8 {
- if (at.col == 0) return std.fmt.bufPrint(buf, "{d}", .{at.line}) catch unreachable; // two usizes fit 41
- return std.fmt.bufPrint(buf, "{d}:{d}", .{ at.line, at.col }) catch unreachable;
+ if (at.col == 0) return std.fmt.bufPrint(buf, "{d}", .{at.line}) catch unreachable; // a usize fits 41
+ return std.fmt.bufPrint(buf, "{d}:{d}", .{ at.line, at.col }) catch unreachable; // two usizes fit 41
}
fn closeAndMiss(p: *Pardes, id: usize, opened: usize, name: []const u8, why: []const u8) void {
@@ -1571,9 +1571,9 @@ pub fn reopenAt(p: *Pardes, from: usize, path: []const u8, at: Spot) void {
// Said when the file no longer has the line, closed or open: the place
// is its last line now.
if (at.line > n or at.end_line > n) {
- var said: [miss_path_cap + 64]u8 = undefined;
+ var said: Kind.Buf(miss_path_cap + 64) = .{};
var cut: [miss_path_cap + "…".len]u8 = undefined;
- p.setMessage(id, std.fmt.bufPrint(&said, "{s} has {d} lines now: at its last", .{ missText(path, &cut), n }) catch unreachable); // missText and a usize
+ p.setMessage(id, said.print("{s} has {d} lines now: at its last", .{ missText(path, &cut), n }));
}
}
@@ -1755,8 +1755,8 @@ pub fn lookAt(p: *Pardes, id: usize, operand_raw: []const u8) void {
// A directory that is not there (the pane's own, gone): said,
// ENOENT, no terminal made in it.
if (filesystem.localPath(dir)) |local| if (exec.kindOf(local) != .directory) {
- var said: [4200]u8 = undefined;
- return p.reportFailure(id, std.fmt.bufPrint(&said, "look: {s}: no such directory", .{dir[0..@min(dir.len, 4096)]}) catch unreachable); // 4123 bytes at most
+ var said: [4096 + 104]u8 = undefined;
+ return p.reportFailure(id, std.fmt.bufPrint(&said, "look: {s}: no such directory", .{dir[0..@min(dir.len, 4096)]}) catch unreachable); // 4096 + 27 fits 4096 + 104
};
// acme's: a pane listing it (Dir.zig).
panes.Dir.look(p, id, dir);
@@ -1829,9 +1829,9 @@ pub fn lookAt(p: *Pardes, id: usize, operand_raw: []const u8) void {
if (made.addon.?.refused.len > 0) {
made.vweight = 0;
p.unplaced.set(free);
- var said: [miss_path_cap + 160]u8 = undefined;
+ var said: Kind.Buf(miss_path_cap + 160) = .{};
var cut: [miss_path_cap + "…".len]u8 = undefined;
- return p.reportFailure(id, std.fmt.bufPrint(&said, "look: {s}: {s}", .{ missText(target.path, &cut), made.addon.?.refused.slice() }) catch unreachable); // missText and a Buf(96)
+ return p.reportFailure(id, said.print("look: {s}: {s}", .{ missText(target.path, &cut), made.addon.?.refused.slice() }));
}
exec.placeNew(p, id, id, free, .doc);
if (target.at.line > 0) lookKind(p, id, free, spotText(target.at, &place), true);
diff --git a/src/modal.zig b/src/modal.zig
index a6781af3..89046820 100644
--- a/src/modal.zig
+++ b/src/modal.zig
@@ -1459,7 +1459,7 @@ pub fn incrementDecimal(alloc: std.mem.Allocator, frag: []const u8, amount: i64)
if (!neg and neg_after) flen += 1;
var buf: [48]u8 = undefined;
// "{d}" prints '+' for positive signed ints — format the magnitude unsigned
- const mag = std.fmt.bufPrint(&buf, "{d}", .{@abs(nv)}) catch unreachable; // a u128 is 39 digits
+ const mag = std.fmt.bufPrint(&buf, "{d}", .{@abs(nv)}) catch unreachable; // a u128's 39 digits fit 48
const sign_len: usize = @intFromBool(neg_after);
const want = if (pad) flen - sign_len else mag.len;
const digits_len = @max(want, mag.len);
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;
}
diff --git a/src/panes.zig b/src/panes.zig
index b9504b1c..a90613d0 100644
--- a/src/panes.zig
+++ b/src/panes.zig
@@ -1052,7 +1052,7 @@ pub fn startPrompt(p: *Pardes, pane: *Pane, t: *Text, request: union(enum) {
if (request == .save and p.fs.serving) {
if (pane.prompt == .save) return;
var rec: [32]u8 = undefined;
- ctlfs.events.notePath(p, "ask", std.fmt.bufPrint(&rec, "{d} save path", .{pane.serial}) catch unreachable); // a u32
+ ctlfs.events.notePath(p, "ask", std.fmt.bufPrint(&rec, "{d} save path", .{pane.serial}) catch unreachable); // a u32 and 10 bytes fit 32
}
const marker = switch (request) {
.search => |marker| marker,
diff --git a/src/tagline.zig b/src/tagline.zig
index e847921e..b9abf5f0 100644
--- a/src/tagline.zig
+++ b/src/tagline.zig
@@ -81,7 +81,7 @@ pub fn revealHeader(p: *Pardes) void {
v.header_top = 0;
return;
};
- const text = edit.flatSurface(p, t) catch unreachable; // a header's text is its own (flatSurface makes none)
+ const text = edit.flatSurface(p, t) catch |err| return p.reportError(v.active, "tag", err);
const cur: usize = @intCast(@max(0, t.cur_row));
const rows: usize = if (p.headerColumn() != null) layout.columnBarHeight(p) else p.topBarHeight();
if (cur < v.header_top) v.header_top = cur;
@@ -415,7 +415,7 @@ pub fn enterHeader(p: *Pardes, column: ?usize) void {
p.view().header = if (column) |c| .{ .column = c } else .workspace;
if (column) |c| p.setActiveColumn(c);
const t = focusedHeader(p) orelse return exitHeader(p);
- takeKeyboard(t, edit.flatSurface(p, t) catch unreachable); // a header's text is its own
+ takeKeyboard(t, edit.flatSurface(p, t) catch |err| return p.reportError(p.view().active, "tag", err));
}
/// The span a header's selection covers on line `row` of its text, in
@@ -443,7 +443,7 @@ pub fn workspaceBlank(p: *Pardes, col: u16, row: u16, tag_hit: ?pardes.TagHit) b
const v = p.view();
if (row >= p.topBarHeight() or col >= v.screen_w) return false;
if (col < TAG_TEXT_INSET) return true;
- const text = edit.flatSurface(p, &p.global_tag) catch unreachable; // a header's text is its own
+ const text = edit.flatSurface(p, &p.global_tag) catch return false;
const scroll: usize = if (v.header != null and p.headerColumn() == null) v.header_scroll else 0;
const at = @as(usize, Layer.columnAt(p, .workspace, 0, tag_hit, false, 0) orelse (col - TAG_TEXT_INSET)) + scroll;
return at >= panes.File.displayWidth(modal.lineSlice(text, 0)) + 2;
diff --git a/src/terminal.zig b/src/terminal.zig
index 097005bc..8249ee09 100644
--- a/src/terminal.zig
+++ b/src/terminal.zig
@@ -205,7 +205,7 @@ pub const State = struct {
var text: std.Io.Writer.Hashing(pardes.walk.Hasher) = .initHasher(h.*, &buf);
if (screen.pages.getBottomRight(.active)) |br|
screen.dumpString(&text.writer, .{ .tl = screen.pages.getTopLeft(.active), .br = br, .unwrap = false }) catch unreachable; // a hashing writer never fails
- text.writer.flush() catch unreachable;
+ text.writer.flush() catch unreachable; // a hashing writer never fails
h.* = text.hasher;
}