diff options
Diffstat (limited to 'src/ninep/pane.zig')
| -rw-r--r-- | src/ninep/pane.zig | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/ninep/pane.zig b/src/ninep/pane.zig index 9aada3ee..47fdd755 100644 --- a/src/ninep/pane.zig +++ b/src/ninep/pane.zig @@ -819,6 +819,8 @@ fn pairOf(text: []const u8) ?State.Range { return .{ .q0 = q0, .q1 = q1 }; } +pub const e_no_text_address = "this pane has no text to address"; + pub const e_addr_failed = "no address: the last one written to addr failed"; /// A range file takes an address expression, or that pair of offsets. One @@ -826,6 +828,9 @@ pub const e_addr_failed = "no address: the last one written to addr failed"; /// regexp`, `address out of range`, `bad regular expression`, `addresses /// out of order`. fn writeRange(req: Req, pane: *Pane, file: PaneFile) Reply { + // A terminal, an image or a PDF has no text an address names: refused + // alike for addr, dot and limit, before the expression is read. + if (fileOf(pane) == null) return tree.failText(req.tag, E.INVAL, e_no_text_address); const pf = &pane.fs; const text = bodyOf(pane); clampAddr(pf, text.len); @@ -868,10 +873,7 @@ fn writeRange(req: Req, pane: *Pane, file: PaneFile) Reply { }, .limit => pf.limit = range, // Setting dot scrolls to it, which is the whole of acme's `show`. - .dot => { - if (fileOf(pane) == null) return tree.failText(req.tag, E.INVAL, e_no_text); - setDot(pane, range); - }, + .dot => setDot(pane, range), else => unreachable, } return .{ .tag = req.tag, .written = @intCast(req.data.len) }; |
