diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-18 23:49:29 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-19 01:35:13 -0300 |
| commit | 1ca3e68f38385952fa5a2ccc3dac883ba0be71e8 (patch) | |
| tree | bffbbf9e5e5b2b929d79bd81ea805c5288896623 /core/Text.zig | |
| parent | e567aadc19f58b1e36098388483294321f3502dd (diff) | |
| download | pardes-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/Text.zig')
| -rw-r--r-- | core/Text.zig | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/core/Text.zig b/core/Text.zig index 5acd6146..51d660cf 100644 --- a/core/Text.zig +++ b/core/Text.zig @@ -162,8 +162,8 @@ pub fn dropSels(t: *Text) void { /// Bring the cursor into view (acme's textshow). Only a body scrolls to it; /// the tagline follows its caret where it is drawn, and a prompt's answer is /// drawn whole. -pub fn show(t: *Text) void { - if (t.what == .body) if (t.pane()) |w| w.ensureCursorVisible(); +pub fn show(t: *Text, tab: u16) void { + if (t.what == .body) if (t.pane()) |w| w.ensureCursorVisible(tab); } pub fn toModalCursor(t: *Text) modal.Cursor { @@ -176,15 +176,15 @@ pub fn fromModalCursor(t: *Text, c: modal.Cursor) void { t.cur_pinned = true; } -pub fn insertVerticalCursor(lines: []const []const u8, c: modal.Cursor, down: bool) modal.Cursor { +pub fn insertVerticalCursor(tab: u16, lines: []const []const u8, c: modal.Cursor, down: bool) modal.Cursor { if (lines.len == 0) return c; // A cursor past the lines (its text changed under it) moves from the last. const row = if (down) @min(c.row + 1, lines.len - 1) else @min(c.row, lines.len) -| 1; const target = lines[row]; if (target.len == 0) return .{ .row = row, .col = 0 }; const source = if (c.row < lines.len) lines[c.row] else ""; - const goal = File.rawDisplayCol(source, c.col); - const mapped = File.rawAtDisplay(target, goal); + const goal = File.rawDisplayCol(tab, source, c.col); + const mapped = File.rawAtDisplay(tab, target, goal); const last = modal.prevGrapheme(target, target.len); return .{ .row = row, .col = modal.graphemeStart(target, @min(mapped, last)) }; } @@ -219,7 +219,7 @@ pub fn rangeCells(text: []const u8, r: modal.Selection) Cells { return .{ .cur = r.head, .anc = r.head }; } -pub fn setRange(t: *Text, text: []const u8, row0: i32, r0: modal.Selection, explicit: bool) void { +pub fn setRange(t: *Text, tab: u16, text: []const u8, row0: i32, r0: modal.Selection, explicit: bool) void { var r = r0; if (r.anchor == r.head) r.head = modal.nextGrapheme(text, r.head); // min_width_1 const off = rangeCells(text, r); @@ -239,7 +239,7 @@ pub fn setRange(t: *Text, text: []const u8, row0: i32, r0: modal.Selection, expl t.cur_pinned = true; t.sticky_col = -1; t.normal.clear(); - t.show(); + t.show(tab); } pub fn ranges(t: *Text, text: []const u8, row0: i32, out: *[max_selections]modal.Selection) struct { n: usize, pri: usize } { @@ -266,7 +266,7 @@ pub fn ranges(t: *Text, text: []const u8, row0: i32, out: *[max_selections]modal return .{ .n = n, .pri = pri }; } -pub fn setRanges(t: *Text, text: []const u8, in: []const modal.Selection, sticky: []const i32, pri0: usize, explicit: bool) void { +pub fn setRanges(t: *Text, tab: u16, text: []const u8, in: []const modal.Selection, sticky: []const i32, pri0: usize, explicit: bool) void { if (in.len == 0) return; // helix asserts non-empty; here it just means "no change" var r: [max_selections]modal.Selection = undefined; var st: [max_selections]i32 = undefined; @@ -311,7 +311,7 @@ pub fn setRanges(t: *Text, text: []const u8, in: []const modal.Selection, sticky if (pri == i) pri = k; } n = k + 1; - setRange(t, text, 0, r[pri], explicit); + setRange(t, tab, text, 0, r[pri], explicit); if (n > 1 and !t.reserveSels()) return; // no room: the primary alone t.sticky_col = st[pri]; var w: usize = 0; @@ -334,7 +334,7 @@ pub fn setRanges(t: *Text, text: []const u8, in: []const modal.Selection, sticky /// helix `scroll` without cursor sync (Ctrl-f/b, PgUp/PgDn, zj/zk): shift /// the view, then snap a fallen-out cursor to the near scrolloff edge, col 0 -pub fn scrollViewMove(t: *Text, text: []const u8, range: modal.Selection, delta: i32) void { +pub fn scrollViewMove(t: *Text, tab: u16, text: []const u8, range: modal.Selection, delta: i32) void { // a view to move through is a body's; a tag or an answer is all shown if (t.what != .body) return; const w = t.pane() orelse return; @@ -348,13 +348,13 @@ pub fn scrollViewMove(t: *Text, text: []const u8, range: modal.Selection, delta: const head = File.textLineStart(t, text, @intCast(snap)); if (head <= cur) return; const anchor = if (t.select) range.anchor else head; - setRange(t, text, 0, .{ .anchor = anchor, .head = head }, false); + setRange(t, tab, text, 0, .{ .anchor = anchor, .head = head }, false); } else { const snap: i32 = @max(0, @min(top + @as(i32, w.rows) - margin - 1, last_row)); const head = File.textLineStart(t, text, @intCast(snap)); if (head >= cur) return; const anchor = if (t.select) range.anchor else head; - setRange(t, text, 0, .{ .anchor = anchor, .head = head }, false); + setRange(t, tab, text, 0, .{ .anchor = anchor, .head = head }, false); } } @@ -368,7 +368,7 @@ pub fn rangeLineSpan(text: []const u8, r: modal.Selection) struct { start: usize /// pull the cursor back inside `text` after a rewrite; `row0` is the /// absolute surface row of its first line (0 for a file) -pub fn clampCursor(t: *Text, text: []const u8, row0: i32) void { +pub fn clampCursor(t: *Text, tab: u16, text: []const u8, row0: i32) void { const n = modal.lineCount(text); const row: usize = @min(@as(usize, @intCast(@max(0, t.cur_row - row0))), if (n == 0) 0 else n - 1); const llen = modal.lineSlice(text, row).len; @@ -376,7 +376,7 @@ pub fn clampCursor(t: *Text, text: []const u8, row0: i32) void { t.cur_col = @intCast(@min(@as(usize, @intCast(@max(0, t.cur_col))), llen)); t.cur_pinned = true; t.vsel.active = false; - t.show(); + t.show(tab); } // ---- undo: the edits a text took, as a journal ---- |
