summaryrefslogtreecommitdiff
path: root/src/ninep/pane.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/ninep/pane.zig')
-rw-r--r--src/ninep/pane.zig64
1 files changed, 32 insertions, 32 deletions
diff --git a/src/ninep/pane.zig b/src/ninep/pane.zig
index 58b14c92..519e5333 100644
--- a/src/ninep/pane.zig
+++ b/src/ninep/pane.zig
@@ -305,38 +305,6 @@ pub fn spliceBody(p: *Pardes, pane: *Pane, q0: usize, q1: usize, bytes: []const
return take;
}
-test "rows through the line index are the ones counting newlines gives, at every offset" {
- const p = try withFile(testing.allocator, "héllo\nwo\u{301}rld\n\n last line é\ntail");
- defer p.deinit();
- const pane = p.panes[0].?;
- const f = &pane.file.?;
- _ = try panes.File.lineIndex(p.gpa, f);
- const text = bodyOf(pane);
- try testing.expect(lineIndex(pane, text) != null);
- for (0..text.len + 2) |off| {
- try testing.expectEqual(modal.positionAt(text, off), positionAt(pane, text, off));
- try testing.expectEqual(modal.runePositionAt(text, off), runePositionAt(pane, text, off));
- }
- for (0..8) |row| for (0..16) |col| {
- const c: modal.Cursor = .{ .row = row, .col = col };
- try testing.expectEqual(modal.runeOffsetAt(text, c), runeOffsetAt(pane, text, c));
- };
-}
-
-test "a terminal's body stats as long as it reads" {
- const gpa = testing.allocator;
- const p = try pardes.Pardes.init(gpa, .{ .tty_only = true, .cols = 80, .rows = 24 });
- defer p.deinit();
- while (p.nextEffect()) |_| {}
- const pane = p.panes[0].?;
- try testing.expect(pane.isTerminal());
- p.update(.{ .output = .{ .pane = 0, .bytes = "$ ls\r\nalpha beta\r\n$ " } });
- const body = Node.of(pane.serial, .body);
- const whole = rd(p, body, 0, 1 << 16);
- try testing.expect(whole.bytes.len > 0);
- try testing.expectEqual(@as(u64, whole.bytes.len), call(p, .{ .tag = 1, .op = .getattr, .node = body }).reply.attr.size);
-}
-
// ---- what stat reports ----
/// A range file's text: acme's addr format, two right-aligned offsets, so
@@ -1027,6 +995,38 @@ const withFile = th.withFile;
const serialOf = th.serialOf;
const Status = tree.Status;
+test "rows through the line index are the ones counting newlines gives, at every offset" {
+ const p = try withFile(testing.allocator, "héllo\nwo\u{301}rld\n\n last line é\ntail");
+ defer p.deinit();
+ const pane = p.panes[0].?;
+ const f = &pane.file.?;
+ _ = try panes.File.lineIndex(p.gpa, f);
+ const text = bodyOf(pane);
+ try testing.expect(lineIndex(pane, text) != null);
+ for (0..text.len + 2) |off| {
+ try testing.expectEqual(modal.positionAt(text, off), positionAt(pane, text, off));
+ try testing.expectEqual(modal.runePositionAt(text, off), runePositionAt(pane, text, off));
+ }
+ for (0..8) |row| for (0..16) |col| {
+ const c: modal.Cursor = .{ .row = row, .col = col };
+ try testing.expectEqual(modal.runeOffsetAt(text, c), runeOffsetAt(pane, text, c));
+ };
+}
+
+test "a terminal's body stats as long as it reads" {
+ const gpa = testing.allocator;
+ const p = try pardes.Pardes.init(gpa, .{ .tty_only = true, .cols = 80, .rows = 24 });
+ defer p.deinit();
+ while (p.nextEffect()) |_| {}
+ const pane = p.panes[0].?;
+ try testing.expect(pane.isTerminal());
+ p.update(.{ .output = .{ .pane = 0, .bytes = "$ ls\r\nalpha beta\r\n$ " } });
+ const body = Node.of(pane.serial, .body);
+ const whole = rd(p, body, 0, 1 << 16);
+ try testing.expect(whole.bytes.len > 0);
+ try testing.expectEqual(@as(u64, whole.bytes.len), call(p, .{ .tag = 1, .op = .getattr, .node = body }).reply.attr.size);
+}
+
test "a body write to a terminal pane types at its shell" {
const gpa = testing.allocator;
const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 40, .rows = 10 });