summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Effect.zig4
-rw-r--r--src/colors.zig4
-rw-r--r--src/keys.zig12
-rw-r--r--src/layout.zig4
-rw-r--r--src/modal.zig2
-rw-r--r--src/mouse.zig4
-rw-r--r--src/panes.zig6
-rw-r--r--src/tagline.zig10
8 files changed, 23 insertions, 23 deletions
diff --git a/src/Effect.zig b/src/Effect.zig
index 487fda82..4dfa72e1 100644
--- a/src/Effect.zig
+++ b/src/Effect.zig
@@ -164,7 +164,7 @@ pub fn perform(p: *Pardes, e: Effect) void {
return;
}
if (!pane.isTerminal()) return;
- const text = panes.terminal.screenTextAlloc(pane, p.gpa) catch return;
+ const text = panes.terminal.screenTextAlloc(pane, p.gpa) catch |err| return p.reportError(st.pane, "Save", err);
defer p.gpa.free(text);
if (writeChecked(p, st.pane, st.serial, st.path.slice(), text, 0)) |still|
ctlfs.events.noteLogAs(p, .save, still, st.path.slice());
@@ -276,7 +276,7 @@ pub fn writeChecked(p: *Pardes, id: u8, serial: u32, path: []const u8, bytes: []
fn promoteSaved(p: *Pardes, id: u8, path: []const u8) void {
const pane = p.panes[id] orelse return;
const f = if (pane.file) |*file| file else return;
- const owned = p.gpa.dupe(u8, path) catch return;
+ const owned = p.gpa.dupe(u8, path) catch |err| return p.reportError(id, "Save", err);
p.gpa.free(f.path);
f.path = owned;
f.output = null;
diff --git a/src/colors.zig b/src/colors.zig
index 7bac64ea..bf68c256 100644
--- a/src/colors.zig
+++ b/src/colors.zig
@@ -676,7 +676,7 @@ fn themeFileFailure(p: *Pardes, request: ThemeFileRequest, why: []const u8) void
var said: [520]u8 = undefined;
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 "theme file: not loaded");
+ p.reportFailure(request.pane, std.fmt.bufPrint(&said, "theme file {s}: {s}", .{ path, why }) catch unreachable); // two 200-byte parts fit 520
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 return false;
+ w.print("{s}{s}", .{ sep, name }) catch unreachable; // fits: checked above
return true;
}
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();
diff --git a/src/layout.zig b/src/layout.zig
index a0d7cbd5..0b11fe1b 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 return);
+ pardes.ctlfs.events.notePath(p, what, std.fmt.bufPrint(&buf, "{d}", .{serial}) catch unreachable); // a u32
}
/// 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 "Newcol: no space for a column"
+ std.fmt.bufPrint(&said, "Newcol: no space for a column: {d} max", .{MAX_COLS}) catch unreachable
else
"Newcol: no space for a column: this one is too narrow to split");
};
diff --git a/src/modal.zig b/src/modal.zig
index c510adc1..a6781af3 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 return null;
+ const mag = std.fmt.bufPrint(&buf, "{d}", .{@abs(nv)}) catch unreachable; // a u128 is 39 digits
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 8e50478f..936e504d 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 return null;
+ const text = edit.flatSurface(p, t) catch unreachable; // a header's text is its own
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 |err| return p.reportError(v.active, "edit", err);
+ const text = edit.flatSurface(p, t) catch unreachable; // a header's text is its own
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");
diff --git a/src/panes.zig b/src/panes.zig
index 1ec78bbc..ffaaba37 100644
--- a/src/panes.zig
+++ b/src/panes.zig
@@ -893,7 +893,7 @@ pub fn newScratchBelow(p: *Pardes, from_id: usize) void {
/// A scratch for New (`.scratch`) or 9P's pane/new (`.fs`).
pub fn newScratchFor(p: *Pardes, from_id: usize, kind: exec.NewPane) void {
const free = p.freeSlot() orelse return p.reportError(from_id, "New", error.NoPaneSlots);
- _ = newScratch(p, from_id, free, kind) catch return;
+ _ = newScratch(p, from_id, free, kind) catch |err| return p.reportError(from_id, "New", err);
exec.placeNew(p, from_id, from_id, free, kind);
}
@@ -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 "");
+ ctlfs.events.notePath(p, "ask", std.fmt.bufPrint(&rec, "{d} save path", .{pane.serial}) catch unreachable); // a u32
}
const marker = switch (request) {
.search => |marker| marker,
@@ -1071,7 +1071,7 @@ pub fn startPrompt(p: *Pardes, pane: *Pane, t: *Text, request: union(enum) {
// directory for the name to be typed onto.
const dir = if (request == .save) paneDir(pane) else "";
const slash: []const u8 = if (request == .save and (dir.len == 0 or dir[dir.len - 1] != '/')) "/" else "";
- const answer = std.mem.concat(p.gpa, u8, &.{ marker, dir, slash }) catch return;
+ const answer = std.mem.concat(p.gpa, u8, &.{ marker, dir, slash }) catch |err| return p.reportError(p.view().active, "prompt", err);
// The keyboard comes back to the text answered for; a prompt for
// the body takes it out of a tag or header.
switch (t.what) {
diff --git a/src/tagline.zig b/src/tagline.zig
index 28cd2a9b..a364732a 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 return;
+ const text = edit.flatSurface(p, t) catch unreachable; // a header's text is its own (flatSurface makes none)
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;
@@ -211,7 +211,7 @@ pub fn tagText(p: *Pardes, arena: std.mem.Allocator, pane: *Pane) ![]u8 {
/// it starts on Save, so that `:` and the execute key write the file.
pub fn enterTag(p: *Pardes, pane: *Pane) void {
const t = &pane.tag;
- const whole = tagText(p, p.scratch.allocator(), pane) catch return;
+ const whole = tagText(p, p.scratch.allocator(), pane) catch |err| return p.reportError(p.view().active, "tag", err);
if (!t.cur_pinned) {
// Save is looked for in the tag's own text, after the prefix.
const lead = whole.len - curTail(pane).len;
@@ -365,7 +365,7 @@ pub fn typedIntoName(p: *Pardes, pane: *Pane, key: pardes.Key) bool {
pub fn draftName(p: *Pardes, pane: *Pane, col: usize) void {
const f = pane.file orelse return;
if (!panes.Output.fileTraits(f.output).saves) return;
- const name = p.gpa.dupe(u8, f.path) catch return;
+ const name = p.gpa.dupe(u8, f.path) catch |err| return p.reportError(p.view().active, "name", err);
pane.closePrompt();
pane.prompt = .name;
pane.prompt_view = p.live;
@@ -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 "");
+ takeKeyboard(t, edit.flatSurface(p, t) catch unreachable); // a header's text is its own
}
/// 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 return false;
+ const text = edit.flatSurface(p, &p.global_tag) catch unreachable; // a header's text is its own
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;