summaryrefslogtreecommitdiff
path: root/src/ninep/pane.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-28 00:42:04 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:14 -0300
commit425d9beb9c977df364ed83743cb2efdef9429478 (patch)
treeeaba2e20ff041b50539d1b47fdeb498e59237cf0 /src/ninep/pane.zig
parent1912878e753ce12fdc1ac72ae2e83ddfc18df002 (diff)
downloadpardes-425d9beb9c977df364ed83743cb2efdef9429478.tar.gz
pardes-425d9beb9c977df364ed83743cb2efdef9429478.zip
File the tag code into tagline.zig and draw tags beside bodies
With tags reduced to Texts, what is left of them is the computed prefix, the default and saved tails, entering and leaving a tag and the headers: that goes to tagline.zig, as acme keeps the tag half of a window in wind.c. Tag and header drawing moves next to body drawing in body_layer.zig, and the tag hit helpers go to tag_layer.zig with the Hit they read, where sameCell now also tells the lines of a taller tag apart. The docs describe the tag as a Text. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/ninep/pane.zig')
-rw-r--r--src/ninep/pane.zig11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/ninep/pane.zig b/src/ninep/pane.zig
index 282ae473..8e827fba 100644
--- a/src/ninep/pane.zig
+++ b/src/ninep/pane.zig
@@ -3,6 +3,7 @@
//! mark and scroll, errors, event, look and exec. Terminals add pty/ (pty.zig).
const std = @import("std");
const pardes = @import("../pardes.zig");
+const tagline = @import("../tagline.zig");
const exec = @import("../exec.zig");
const look = @import("../look.zig");
const panes = @import("../panes.zig");
@@ -79,7 +80,7 @@ pub fn fileOf(pane: *Pane) ?*panes.File.State {
}
pub fn tagOf(p: *Pardes, pane: *Pane) []const u8 {
- return p.tagText(p.scratch.allocator(), pane) catch "";
+ return tagline.tagText(p, p.scratch.allocator(), pane) catch "";
}
pub fn dirOf(pane: *Pane) []const u8 {
@@ -422,7 +423,7 @@ fn writeTag(req: Req, pane: *Pane) Reply {
if (req.data.len == 0) return .{ .tag = req.tag, .written = 0 };
// The tag's own text grows by what is written, newlines and all: a tag
// is a text like any other (acme's tag file appends the same way).
- const had = Pardes.curTail(pane).len;
+ const had = tagline.curTail(pane).len;
const room = limits.max_tag_tail -| had;
if (room == 0) return Reply.fail(req.tag, E.NOSPC);
const take = wholeUtf8(req.data[0..@min(req.data.len, room)]);
@@ -746,7 +747,7 @@ test "tag reads the whole tag and writes append to the editable tail" {
const before = rd(p, node, 0, 4096).bytes.len;
const w = wr(p, node, " Mine");
try testing.expectEqual(@as(u32, 5), w.reply.written);
- try testing.expect(std.mem.endsWith(u8, Pardes.curTail(pane), " Mine"));
+ try testing.expect(std.mem.endsWith(u8, tagline.curTail(pane), " Mine"));
const after = rd(p, node, 0, 4096);
try testing.expectEqual(before + 5, after.bytes.len);
try testing.expect(std.mem.endsWith(u8, after.bytes, " Mine"));
@@ -754,7 +755,7 @@ test "tag reads the whole tag and writes append to the editable tail" {
// A tag is a text like the body: a newline written to it stays one, and
// the tag reads back taller by it.
try testing.expectEqual(@as(u32, 10), wr(p, node, "\nNext Line").reply.written);
- try testing.expect(std.mem.endsWith(u8, Pardes.curTail(pane), " Mine\nNext Line"));
+ try testing.expect(std.mem.endsWith(u8, tagline.curTail(pane), " Mine\nNext Line"));
try testing.expect(std.mem.endsWith(u8, rd(p, node, 0, 4096).bytes, " Mine\nNext Line"));
if (pane.tag.own) |own| p.gpa.free(own);
@@ -887,7 +888,7 @@ test "truncating the tag clears its editable tail" {
const pane = p.panes[0].?;
const tag = Node.of(pane.serial, .tag);
_ = wr(p, tag, " Mine");
- try testing.expect(Pardes.curTail(pane).len > 0);
+ try testing.expect(tagline.curTail(pane).len > 0);
const cleared = call(p, .{ .tag = 1, .op = .setattr, .node = tag, .truncate = true });
try testing.expectEqual(Status.ok, cleared.reply.status);
try testing.expectEqualStrings("", pane.tag.own.?);