summaryrefslogtreecommitdiff
path: root/core/ninep/pane.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-18 23:49:29 -0300
committerGabriel Schneider <[email protected]>2026-11-19 01:35:13 -0300
commit1ca3e68f38385952fa5a2ccc3dac883ba0be71e8 (patch)
treebffbbf9e5e5b2b929d79bd81ea805c5288896623 /core/ninep/pane.zig
parente567aadc19f58b1e36098388483294321f3502dd (diff)
downloadpardes-1ca3e68f38385952fa5a2ccc3dac883ba0be71e8.tar.gz
pardes-1ca3e68f38385952fa5a2ccc3dac883ba0be71e8.zip
core: nothing of a core is a process global, the three that were (pardes-probes P3, the reorganisation's 12c): config.tab_now goes, a tab's width is the core's settings.tab handed to every width function as `tab` (File.graphemeDisplayWidth and the 73 functions above it, test helpers among them, that had no core to read it from gained the parameter; an Editor, a Surface and the hunks' Ctx carry it; render sets Surface.tab; graphemeDisplayWidth asks its one printable ASCII byte before the tab, the two disjoint: with the tab first, as before, the parameter cost 0.2-1.7% instructions an operation in pardes-perf, with ASCII first the measured cells use 2-16% fewer than the base), so a rollback can no longer leave a stale width and replica.zig's hand-made put-back in toConfirmed goes; Addon.distrusted/ndistrusted become Addon.Distrusted, the client's own list, which its frontend owns across its joins and hands each core as Options.distrusted (in no tape, dump or digest: Options' replica .local); Kind.draw_tokens becomes each slot's `draws` (local: a draw is a frame's, so each process's count differs and no digest may hold it; the copy saves it with the slot); the two turn reads in a step stay, being shown unable to reach a client's state (the report); the soak's Proc keeps only the client's list (its tab_now and the global swaps go, forced); test/perf.zig follows three signatures, so unit-test's perf check now says BaselineHarnessMismatch until the baselines are recorded again; tui core-test 824/966 (142 skipped), shell-test 1001/1004, pane-test 183/184, behaviour-test 274/274 and --replay 274/274, process-test 2 of 144 failed (lspcomplete, lspcompletemoved), replicas --clients 5 diverged 0 unequal 0 deltas wrong 0 quiet differ 0 at 30/80/207 ms, gui unit-test 1598/1602, lib-test, daemon.py plain, --far, --games, --window-clients pass
Co-Authored-By: Claude Opus <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/ninep/pane.zig')
-rw-r--r--core/ninep/pane.zig30
1 files changed, 15 insertions, 15 deletions
diff --git a/core/ninep/pane.zig b/core/ninep/pane.zig
index 11f0558e..e9e43095 100644
--- a/core/ninep/pane.zig
+++ b/core/ninep/pane.zig
@@ -228,7 +228,7 @@ pub fn dotOf(pane: *Pane) State.Range {
return .{ .q0 = clip(@min(head, anchor)), .q1 = clip(hi) };
}
-pub fn setDot(pane: *Pane, r: State.Range) void {
+pub fn setDot(tab: u16, pane: *Pane, r: State.Range) void {
const text = bodyOf(pane);
const q0 = @min(@as(usize, r.q0), text.len);
const q1 = @max(q0, @min(@as(usize, r.q1), text.len));
@@ -239,13 +239,13 @@ pub fn setDot(pane: *Pane, r: State.Range) void {
pane.body.cur_col = @intCast(h.col);
pane.body.cur_pinned = true;
pane.body.sticky_col = -1;
- pane.ensureCursorVisible();
+ pane.ensureCursorVisible(tab);
}
/// Scrolls `off` into view and nothing else: the cursor is dot's head, and
/// a write shown is not a write that moves dot (acme's textinsert leaves
/// dot where its rule puts it; only the view follows the text).
-pub fn showOffset(pane: *Pane, off: usize) void {
+pub fn showOffset(tab: u16, pane: *Pane, off: usize) void {
const text = bodyOf(pane);
const c = positionAt(pane, text, @min(off, text.len));
// Where dot is now, kept: pinned, so the view moving under it does not
@@ -255,7 +255,7 @@ pub fn showOffset(pane: *Pane, off: usize) void {
const col = pane.body.cur_col;
pane.body.cur_row = @intCast(c.row);
pane.body.cur_col = @intCast(c.col);
- pane.ensureCursorVisible();
+ pane.ensureCursorVisible(tab);
pane.body.cur_row = row;
pane.body.cur_col = col;
}
@@ -497,7 +497,7 @@ pub fn write(p: *Pardes, req: Req, id: usize, pane: *Pane, file: PaneFile) Reply
.body => writeBody(p, req, id, pane),
.tag => writeTag(p, req, pane),
.ctl => ctl.writePane(p, req, pane),
- .addr, .dot, .limit => writeRange(req, pane, file),
+ .addr, .dot, .limit => writeRange(p.settings.tab, req, pane, file),
.data, .xdata => writeData(p, req, pane),
.sel => writeSel(p, req, pane),
.dirty, .mark, .scroll => writeFlag(p, req, pane, file),
@@ -583,11 +583,11 @@ pub fn flushBatch(p: *Pardes) void {
if (fileOf(pane) == null) return;
const before = dotOf(pane);
const take = spliceJoined(p, pane, b.at, b.at, b.bytes.items, b.handle) orelse return;
- setDot(pane, .{
+ setDot(p.settings.tab, pane, .{
.q0 = shiftOne(before.q0, clip(b.at), 0, clip(take)),
.q1 = shiftOne(before.q1, clip(b.at), 0, clip(take)),
});
- if (!pane.fs.noscroll) showOffset(pane, b.at + take);
+ if (!pane.fs.noscroll) showOffset(p.settings.tab, pane, b.at + take);
}
/// How many bytes this open's write holds back (`fs.batch`) for its pane.
@@ -627,7 +627,7 @@ fn writeBody(p: *Pardes, req: Req, id: usize, pane: *Pane) Reply {
if (holdWrite(p, req, pane, at) catch return Reply.fail(req.tag, E.NOMEM)) |take| return .{ .tag = req.tag, .written = @intCast(take) };
const take = spliceJoined(p, pane, at, at, req.data, req.handle) orelse
return Reply.fail(req.tag, E.NOMEM);
- if (!pane.fs.noscroll) showOffset(pane, at + take);
+ if (!pane.fs.noscroll) showOffset(p.settings.tab, pane, at + take);
return .{ .tag = req.tag, .written = @intCast(take) };
}
@@ -728,12 +728,12 @@ fn writeData(p: *Pardes, req: Req, pane: *Pane) Reply {
const before = dotOf(pane);
const take = spliceJoined(p, pane, q0, q1, req.data, req.handle) orelse
return Reply.fail(req.tag, E.NOMEM);
- setDot(pane, .{
+ setDot(p.settings.tab, pane, .{
.q0 = shiftOne(before.q0, clip(q0), clip(q1 - q0), clip(take)),
.q1 = shiftOne(before.q1, clip(q0), clip(q1 - q0), clip(take)),
});
pf.addr = .{ .q0 = clip(q0 + take), .q1 = clip(q0 + take) };
- if (!pf.noscroll) showOffset(pane, q0 + take);
+ if (!pf.noscroll) showOffset(p.settings.tab, pane, q0 + take);
return .{ .tag = req.tag, .written = @intCast(take) };
}
@@ -752,7 +752,7 @@ fn writeSel(p: *Pardes, req: Req, pane: *Pane) Reply {
const start = if (going_on) pf.wrsel.q0 else clip(q0);
pf.wrsel = .{ .q0 = start, .q1 = clip(q0 + take) };
pf.wrsel_by = req.handle;
- setDot(pane, pf.wrsel);
+ setDot(p.settings.tab, pane, pf.wrsel);
return .{ .tag = req.tag, .written = @intCast(take) };
}
@@ -774,7 +774,7 @@ pub const e_addr_failed = "no address: the last one written to addr failed";
/// that does not evaluate says why: `bad address syntax`, `no match for
/// regexp`, `address out of range`, `bad regular expression`, `addresses
/// out of order`.
-fn writeRange(req: Req, pane: *Pane, file: PaneFile) Reply {
+fn writeRange(tab: u16, 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);
@@ -820,7 +820,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 => setDot(pane, range),
+ .dot => setDot(tab, pane, range),
else => unreachable,
}
return .{ .tag = req.tag, .written = @intCast(req.data.len) };
@@ -993,7 +993,7 @@ pub fn truncate(p: *Pardes, pane: *Pane, file: PaneFile) tree.Status {
pf.joined = if (fileOf(pane).?.revision != was) fileOf(pane).?.revision else null;
pf.joined_by = 0;
pf.addr = .{};
- setDot(pane, .{});
+ setDot(p.settings.tab, pane, .{});
},
.data, .xdata => if (fileOf(pane) != null) {
clampAddr(pf, bodyOf(pane).len);
@@ -1005,7 +1005,7 @@ pub fn truncate(p: *Pardes, pane: *Pane, file: PaneFile) tree.Status {
_ = spliceBody(p, pane, q0, q1, "") orelse return .err;
pf.joined = if (fileOf(pane).?.revision != was) fileOf(pane).?.revision else null;
pf.joined_by = 0;
- setDot(pane, .{ .q0 = shiftOne(before.q0, q0, q1 - q0, 0), .q1 = shiftOne(before.q1, q0, q1 - q0, 0) });
+ setDot(p.settings.tab, pane, .{ .q0 = shiftOne(before.q0, q0, q1 - q0, 0), .q1 = shiftOne(before.q1, q0, q1 - q0, 0) });
pf.addr = .{ .q0 = q0, .q1 = q0 };
},
// Done with the write after it, which may yet be refused.