summaryrefslogtreecommitdiff
path: root/core/look.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/look.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/look.zig')
-rw-r--r--core/look.zig38
1 files changed, 19 insertions, 19 deletions
diff --git a/core/look.zig b/core/look.zig
index 79880476..6ff1da66 100644
--- a/core/look.zig
+++ b/core/look.zig
@@ -251,10 +251,10 @@ pub fn expandedSel(p: *Pardes, pane: *Pane, at: Pane.Sel) ?Pane.Sel {
while (it.next()) |line| : (v += 1) {
if (v != sl.r0) continue;
const display_col: usize = @intCast(@max(0, sl.c0));
- const col = panes.File.renderedLineByteCol(pane, v, line, display_col);
+ const col = panes.File.renderedLineByteCol(p.settings.tab, pane, v, line, display_col);
const b = expandedWord(line, col) orelse return null;
- sl.c0 = @intCast(panes.File.renderedLineDisplayCol(pane, v, line, b.lo));
- sl.c1 = @intCast(panes.File.renderedLineDisplayCol(pane, v, line, b.hi) - 1);
+ sl.c0 = @intCast(panes.File.renderedLineDisplayCol(p.settings.tab, pane, v, line, b.lo));
+ sl.c1 = @intCast(panes.File.renderedLineDisplayCol(p.settings.tab, pane, v, line, b.hi) - 1);
return sl;
}
return null;
@@ -269,37 +269,37 @@ fn tagWordSel(p: *Pardes, pane: *Pane, at: Pane.Sel) ?Pane.Sel {
const whole = tagline.tagText(p, arena, pane) catch return null;
const row: usize = @as(usize, @intCast(at.r0)) + pane.tag_top;
const shown_line = modal.lineSlice(shown.text, row);
- const real = shown.toReal(modal.lineStartOffset(shown.text, row) + panes.File.rawAtDisplay(shown_line, @intCast(@max(0, at.c0))));
+ const real = shown.toReal(modal.lineStartOffset(shown.text, row) + panes.File.rawAtDisplay(p.settings.tab, shown_line, @intCast(@max(0, at.c0))));
const start = if (std.mem.lastIndexOfScalar(u8, whole[0..@min(real, whole.len)], '\n')) |nl| nl + 1 else 0;
const end = std.mem.indexOfScalarPos(u8, whole, start, '\n') orelse whole.len;
const b = expandedWord(whole[start..end], real - start) orelse return null;
- const lo = shownCell(shown.text, shown.fromReal(start + b.lo), pane.tag_top);
- const hi = shownCell(shown.text, shown.fromReal(start + b.hi - 1), pane.tag_top);
+ const lo = shownCell(p.settings.tab, shown.text, shown.fromReal(start + b.lo), pane.tag_top);
+ const hi = shownCell(p.settings.tab, shown.text, shown.fromReal(start + b.hi - 1), pane.tag_top);
return .{ .state = at.state, .r0 = lo.row, .c0 = lo.col, .r1 = hi.row, .c1 = hi.col };
}
-fn shownCell(text: []const u8, off: usize, top: usize) struct { row: i32, col: i32 } {
+fn shownCell(tab: u16, text: []const u8, off: usize, top: usize) struct { row: i32, col: i32 } {
const before = text[0..@min(off, text.len)];
const row = std.mem.count(u8, before, "\n");
const line_start = if (std.mem.lastIndexOfScalar(u8, before, '\n')) |nl| nl + 1 else 0;
return .{
.row = @as(i32, @intCast(row)) - @as(i32, @intCast(top)),
- .col = @intCast(panes.File.rawDisplayCol(text[line_start..], off - line_start)),
+ .col = @intCast(panes.File.rawDisplayCol(tab, text[line_start..], off - line_start)),
};
}
/// the word under the modal cursor as a pane-local selection (paneText
/// coords: row 0 is the tag; file panes carry the line-number prefix)
pub fn cursorWordSel(p: *Pardes, pane: *Pane) Pane.Sel {
- const w = pane.wrapRow(pane.body.cur_row, pane.body.cur_col);
+ const w = pane.wrapRow(p.settings.tab, pane.body.cur_row, pane.body.cur_col);
const vrow = w.row + @as(i32, pane.tag_rows);
const vcol = if (pane.file != null)
- w.pad + panes.File.displayOffset(pane, pane.body.cur_row, w.at, pane.body.cur_col) + @as(i32, panes.File.gutterWidth(pane))
+ w.pad + panes.File.displayOffset(p.settings.tab, pane, pane.body.cur_row, w.at, pane.body.cur_col) + @as(i32, panes.File.gutterWidth(pane))
else blk: {
const lines = edit.paneCursorLines(p.editor(), &pane.body) catch break :blk pane.body.cur_col;
const local = pane.body.cur_row;
if (local < 0 or @as(usize, @intCast(local)) >= lines.len) break :blk pane.body.cur_col;
- break :blk panes.File.lineDisplayOffset(lines[@intCast(local)], @intCast(@max(0, w.at)), @intCast(@max(0, pane.body.cur_col)));
+ break :blk panes.File.lineDisplayOffset(p.settings.tab, lines[@intCast(local)], @intCast(@max(0, w.at)), @intCast(@max(0, pane.body.cur_col)));
};
return .{ .state = .done, .c0 = vcol, .c1 = vcol, .r0 = vrow, .r1 = vrow };
}
@@ -645,7 +645,7 @@ fn landLookSpot(p: *Pardes, id: usize, pane: *Pane, spot: Pane.LookSpot) void {
pane.look_at = spot;
p.look_walk_owner = pane.serial;
p.view().active = id;
- pane.ensureCursorVisible();
+ pane.ensureCursorVisible(p.settings.tab);
}
pub fn cancelLookHover(p: *Pardes) void {
@@ -747,7 +747,7 @@ pub fn focusPaneLine(p: *Pardes, id: usize, at: Spot, landing: enum { center, ke
pane.body.cur_col = if (at.col > 0) @intCast(at.col - 1) else 0;
pane.body.cur_pinned = true;
if (at.end_line != 0) return selectSpan(p, pane, at);
- pane.ensureCursorVisible();
+ pane.ensureCursorVisible(p.settings.tab);
}
fn selectSpan(p: *Pardes, pane: *Pane, at: Spot) void {
@@ -757,7 +757,7 @@ fn selectSpan(p: *Pardes, pane: *Pane, at: Spot) void {
const acol: i32 = @intCast(at.col -| 1);
const ecol: i32 = if (at.end_col > 0) @intCast(at.end_col - 1) else std.math.maxInt(i32);
const r = panes.Text.cellRange(text, @intCast(at.line -| 1), acol, @intCast(at.end_line -| 1), ecol);
- pane.body.setRange(text, 0, r, true);
+ pane.body.setRange(p.settings.tab, text, 0, r, true);
}
fn openPaneTarget(p: *const Pardes, path: []const u8, at: Spot) ?Target {
@@ -967,7 +967,7 @@ fn lookWord(p: *Pardes, id: usize, pane: *Pane, word: []const u8) void {
return missed(p, id, "no match for \"{s}\"", .{missText(word, &cut)});
});
clearNavigationSelection(p, pane);
- ninep_pane.setDot(pane, .{ .q0 = @intCast(at), .q1 = @intCast(at + word.len) });
+ ninep_pane.setDot(p.settings.tab, pane, .{ .q0 = @intCast(at), .q1 = @intCast(at + word.len) });
p.view().active = id;
}
@@ -1131,7 +1131,7 @@ fn lookAddress(p: *Pardes, id: usize, path: []const u8, expr: []const u8) void {
return missed(p, target, "{s}: {s}", .{ name, why });
}
clearNavigationSelection(p, pane);
- ninep_pane.setDot(pane, r);
+ ninep_pane.setDot(p.settings.tab, pane, r);
v.active = target;
}
@@ -1396,7 +1396,7 @@ fn settleLine(p: *Pardes, id: usize, path: []const u8, at: Spot, before: usize,
const start = modal.lineStartOffset(f.content, at.line - 1);
const next = std.mem.indexOfScalarPos(u8, f.content, start, '\n');
const end = if (next) |i| i + 1 else f.content.len;
- @import("ninep/pane.zig").setDot(shown, .{ .q0 = @intCast(start), .q1 = @intCast(end) });
+ @import("ninep/pane.zig").setDot(p.settings.tab, shown, .{ .q0 = @intCast(start), .q1 = @intCast(end) });
}
}
@@ -2022,7 +2022,7 @@ test "Look ignores missing and out of bounds pane addresses" {
defer p.deinit();
const pane = try p.setTestFile("alpha\nbravo\n");
for ([_][]const u8{ config.pane_addr ++ "15:2", config.pane_addr ++ "999999:2" }) |operand| {
- pane.body.setRange(pane.file.?.content, 0, .{ .anchor = 0, .head = 3 }, true);
+ pane.body.setRange(config.tab_width, pane.file.?.content, 0, .{ .anchor = 0, .head = 3 }, true);
lookAt(p, 0, operand);
try std.testing.expectEqual(@as(usize, 0), p.view().active);
try std.testing.expectEqual(@as(i32, 0), pane.body.cur_row);
@@ -2423,7 +2423,7 @@ test "a tag word looked at by a click and by Enter is one record to an event rea
const shown_at = std.mem.lastIndexOf(u8, shown, "Del").?;
const shown_row: u16 = @intCast(std.mem.count(u8, shown[0..shown_at], "\n"));
const line_start = if (std.mem.lastIndexOfScalar(u8, shown[0..shown_at], '\n')) |nl| nl + 1 else 0;
- const x = p.view().rects[0].x + TAG_TEXT_INSET + @as(u16, @intCast(panes.File.displayWidth(shown[line_start..shown_at]))) + 1;
+ const x = p.view().rects[0].x + TAG_TEXT_INSET + @as(u16, @intCast(panes.File.displayWidth(config.tab_width, shown[line_start..shown_at]))) + 1;
const y = p.view().rects[0].y + shown_row;
p.update(.{ .mouse = .{ .button = .right, .kind = .press, .col = x, .row = y } });
p.update(.{ .mouse = .{ .button = .right, .kind = .release, .col = x, .row = y } });