summaryrefslogtreecommitdiff
path: root/core/exec.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/exec.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/exec.zig')
-rw-r--r--core/exec.zig28
1 files changed, 13 insertions, 15 deletions
diff --git a/core/exec.zig b/core/exec.zig
index 601d43dc..6804a22e 100644
--- a/core/exec.zig
+++ b/core/exec.zig
@@ -110,12 +110,12 @@ fn spanHas(r: i32, c: i32, ar: i32, ac: i32, br: i32, bc: i32) bool {
/// anywhere else.
pub fn operandAt(p: *Pardes, pane: *Pane, clicked: Pane.Sel, borrow: bool, for_look: bool) PointerOperand {
const visible = clicked.r0 - @as(i32, pane.tag_rows);
- const wrapped = pane.wrapAt(visible);
+ const wrapped = pane.wrapAt(p.settings.tab, visible);
const raw = pane.isTerminal() and pane.body.mode == .tty and clicked.r0 >= pane.tag_rows;
const row = if (raw) @as(i32, @intCast(panes.Term.grid(pane.terminal).offset)) + visible else wrapped.line;
- const raw_line = if (raw) modal.lineSlice(body_layer.bodyText(p.scratch.allocator(), pane) catch "", @intCast(@max(0, visible))) else "";
+ const raw_line = if (raw) modal.lineSlice(body_layer.bodyText(p.settings.tab, p.scratch.allocator(), pane) catch "", @intCast(@max(0, visible))) else "";
const col = if (raw)
- @as(i32, @intCast(panes.File.rawAtDisplay(raw_line, @intCast(@max(0, clicked.c0)))))
+ @as(i32, @intCast(panes.File.rawAtDisplay(p.settings.tab, raw_line, @intCast(@max(0, clicked.c0)))))
else if (clicked.r0 >= pane.tag_rows)
edit.paneByteAtDisplay(
p.editor(),
@@ -144,7 +144,7 @@ pub fn operandAt(p: *Pardes, pane: *Pane, clicked: Pane.Sel, borrow: bool, for_l
lo -|= span.prompt_bytes;
hi -|= span.prompt_bytes;
} else if (!span.raw_terminal and raw) {
- const prefix = panes.Term.promptPrefix(pane.terminal, row, raw_line);
+ const prefix = panes.Term.promptPrefix(p.settings.tab, pane.terminal, row, raw_line);
lo += prefix;
hi += prefix;
}
@@ -186,11 +186,11 @@ pub fn operandAt(p: *Pardes, pane: *Pane, clicked: Pane.Sel, borrow: bool, for_l
var expanded = clicked;
if (pane.file != null) {
result.file_word = .{ .row = row, .lo = 0, .hi = hi };
- expanded = fileWordCells(pane, clicked, row, 0, hi) orelse return result;
+ expanded = fileWordCells(p.settings.tab, pane, clicked, row, 0, hi) orelse return result;
} else {
const shown = if (raw) raw_line else got.line;
expanded.c0 = 0;
- expanded.c1 = @as(i32, @intCast(panes.File.rawDisplayCol(shown, shown.len))) - 1;
+ expanded.c1 = @as(i32, @intCast(panes.File.rawDisplayCol(p.settings.tab, shown, shown.len))) - 1;
}
result.preview = expanded;
result.expanded = expanded;
@@ -212,7 +212,7 @@ pub fn operandAt(p: *Pardes, pane: *Pane, clicked: Pane.Sel, borrow: bool, for_l
const hi = std.math.cast(i32, b.hi) orelse return result;
result.text = line[b.lo..b.hi];
result.file_word = .{ .row = row, .lo = lo, .hi = hi };
- const expanded = fileWordCells(pane, clicked, row, lo, hi) orelse clicked;
+ const expanded = fileWordCells(p.settings.tab, pane, clicked, row, lo, hi) orelse clicked;
result.preview = expanded;
result.expanded = expanded;
return result;
@@ -228,15 +228,15 @@ pub fn operandAt(p: *Pardes, pane: *Pane, clicked: Pane.Sel, borrow: bool, for_l
/// The cells bytes `lo..hi` of a file pane's line `row` take on screen,
/// soft-wrapped or not, as `clicked` reshaped; null when scrolled off.
-fn fileWordCells(pane: *Pane, clicked: Pane.Sel, row: i32, lo: i32, hi: i32) ?Pane.Sel {
- const first = pane.wrapRow(row, lo);
- const last = pane.wrapRow(row, hi - 1);
+fn fileWordCells(tab: u16, pane: *Pane, clicked: Pane.Sel, row: i32, lo: i32, hi: i32) ?Pane.Sel {
+ const first = pane.wrapRow(tab, row, lo);
+ const last = pane.wrapRow(tab, row, hi - 1);
if (first.row < 0 or last.row < 0) return null;
var cells = clicked;
cells.r0 = first.row + @as(i32, pane.tag_rows);
- cells.c0 = @as(i32, panes.File.gutterWidth(pane)) + first.pad + panes.File.displayOffset(pane, row, first.at, lo);
+ cells.c0 = @as(i32, panes.File.gutterWidth(pane)) + first.pad + panes.File.displayOffset(tab, pane, row, first.at, lo);
cells.r1 = last.row + @as(i32, pane.tag_rows);
- cells.c1 = @as(i32, panes.File.gutterWidth(pane)) + last.pad + panes.File.displayEndOffset(pane, row, last.at, hi - 1);
+ cells.c1 = @as(i32, panes.File.gutterWidth(pane)) + last.pad + panes.File.displayEndOffset(tab, pane, row, last.at, hi - 1);
return cells;
}
@@ -1038,8 +1038,6 @@ pub fn applySettingBuiltin(p: *Pardes, setting: config.Runtime.Setting, arg: ?[]
} else if (!p.settings.apply(setting, arg)) {
var said: pardes.Kind.Buf(96) = .{};
p.reportFailure(v.active, said.print("{s}{s}: takes {s}", .{ setting.word, if (tag == .tab) ": invalid tab width" else "", comptime config.Runtime.takes(tag).? }));
- } else if (tag == .tab) {
- config.tab_now = p.settings.tab;
},
// Said with what it takes: its words, its range.
else => if (!p.settings.apply(setting, arg)) {
@@ -1124,7 +1122,7 @@ test "the acme chords act once per selection, not once on the primary" {
.{ .anchor = 0, .head = 6 },
.{ .anchor = 7, .head = 13 },
};
- pane.body.setRanges(pane.file.?.content, &ranges, &.{}, 0, true);
+ pane.body.setRanges(config.tab_width, pane.file.?.content, &ranges, &.{}, 0, true);
try std.testing.expectEqual(@as(u16, 1), pane.body.nsel);
const before = p.view().ncol;