summaryrefslogtreecommitdiff
path: root/core/Dir.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/Dir.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/Dir.zig')
-rw-r--r--core/Dir.zig10
1 files changed, 5 insertions, 5 deletions
diff --git a/core/Dir.zig b/core/Dir.zig
index 0f99e497..1be67378 100644
--- a/core/Dir.zig
+++ b/core/Dir.zig
@@ -105,10 +105,10 @@ fn readHost(gpa: std.mem.Allocator, local: []const u8) ![]u8 {
/// first, every column as wide as the widest entry and a cell more,
/// rounded up to a tab, and each row ending in a newline. Blanks pad where
/// acme's tabs do: a pardes tab is a fixed width, not a stop.
-pub fn columnate(gpa: std.mem.Allocator, entries: []const []const u8, width: usize) error{OutOfMemory}![]u8 {
+pub fn columnate(tab_w: u16, gpa: std.mem.Allocator, entries: []const []const u8, width: usize) error{OutOfMemory}![]u8 {
var colw: usize = 0;
for (entries) |entry| {
- const w = File.displayWidth(entry) + 1;
+ const w = File.displayWidth(tab_w, entry) + 1;
colw = @max(colw, (w + tab - 1) / tab * tab);
}
const ncol = if (colw == 0) 1 else @max(1, width / colw);
@@ -120,7 +120,7 @@ pub fn columnate(gpa: std.mem.Allocator, entries: []const []const u8, width: usi
while (j < entries.len) : (j += nrow) {
try out.appendSlice(gpa, entries[j]);
if (j + nrow >= entries.len) break;
- try out.appendNTimes(gpa, ' ', colw - File.displayWidth(entries[j]));
+ try out.appendNTimes(gpa, ' ', colw - File.displayWidth(tab_w, entries[j]));
}
try out.append(gpa, '\n');
}
@@ -151,7 +151,7 @@ pub fn fit(p: *Pardes, pane: *Pane, cols: usize) void {
defer p.gpa.free(entries);
var it = std.mem.splitScalar(u8, l.names, '\n');
for (entries) |*entry| entry.* = it.next().?;
- const text = columnate(p.gpa, entries, width) catch return;
+ const text = columnate(p.settings.tab, p.gpa, entries, width) catch return;
if (std.mem.eql(u8, text, f.content)) p.gpa.free(text) else {
File.setContent(p, f, text);
panes.Output.resetBody(p, pane);
@@ -252,7 +252,7 @@ pub fn show(p: *Pardes, from: usize, id: usize) void {
const testing = std.testing;
fn laidOut(names: []const []const u8, width: usize) ![]u8 {
- return columnate(testing.allocator, names, width);
+ return columnate(config.tab_width, testing.allocator, names, width);
}
test "entries go down each column first, a column a tab wider than its widest entry, as acme's" {