diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-21 09:46:32 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-21 14:17:20 -0300 |
| commit | dfb051bd798f65c2217eea7f95b03dce292e30bf (patch) | |
| tree | 4307ce068343f57de735be1ee7f6093ea106f4f8 /core/File.zig | |
| parent | c4f7bb9477c7aa4c8864f14edb9e85b6c8c08437 (diff) | |
| download | pardes-dfb051bd798f65c2217eea7f95b03dce292e30bf.tar.gz pardes-dfb051bd798f65c2217eea7f95b03dce292e30bf.zip | |
layers: `Changes [revset]` pins a revset's changes on a file's pane in this view (bare `@`, bare again off, another replaces; refusals in jj's words) and draws them: what jj says is asked in two recorded answers (Site.jj), `jj log -p --git --context=0` restricted to the file (the pins: id, author, time, the description's first line, and each one's diff, read with diff.zig's walk into hunks and the removed lines' text) and `jj file annotate` at the shown revision (which pin wrote each line), kept as flat arrays in the pane (Pane.changes: replicated, a late joiner has them in the dump, a client never runs jj) and worn by the view whose revset is File.Layers.revset; a pin's lane runs unbroken from a line it wrote to the next while every line between is a newer pin's, so lanes nest, the spine keeping its place and a nested change a level to the right on its rows only, three levels in a gutter the lanes widen (a window two cells, strips of a third of a cell with half that of air: Surface.lanes, drawn by the gui; a terminal three, a `▎` a level), coloured by the theme's accents but its green and red in hue order from the top, one within 15 degrees of the last kept skipped (doom one: magenta, blue, yellow), oldest first; a line a pin added whole (in a run it took away and wrote, past as many as it took away) is green across the line as a diff's added line; with Changes off nothing is drawn and the gutter is as it was; tests: the data through the pane (pins, lines, hunks, removed text, unpin, `@` touching nothing, a refusal), a client replaying it ends equal, the lanes and grounds of a three-deep stack in a terminal's cells and a window's strips; core-test 895/1055 (160 skipped), shell-test 1097/1100
Co-Authored-By: Claude Opus <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/File.zig')
| -rw-r--r-- | core/File.zig | 51 |
1 files changed, 43 insertions, 8 deletions
diff --git a/core/File.zig b/core/File.zig index 450e4ec9..f7d6bced 100644 --- a/core/File.zig +++ b/core/File.zig @@ -372,7 +372,13 @@ pub fn gutterWidth(pane: *const Pane) u16 { var lines = if (file.line_starts.len > 0) file.line_starts.len else lineCount(file.content); var digits: u16 = 1; while (lines >= 10) : (lines /= 10) digits += 1; - return @max(config.PREFIX_W, digits + 1); + return @max(config.PREFIX_W, digits + 1) + laneCells(pane); +} + +/// The cells the changes' lanes take after the line number in this view +/// (File.Layers), none while it pins no changes. +pub fn laneCells(pane: *const Pane) u16 { + return pane.layers.lanes; } /// Convert between rendered cells and UTF-8 byte columns. Tag rows always @@ -1756,7 +1762,7 @@ fn geometryKey(pane: *const Pane, f: *const State) u64 { if (f.output) |o| pardes.walk.digest(Output.Origin, &o.from) else 0, std.hash.Wyhash.hash(0, f.path), f.tree_context, f.context.revision orelse 0, f.context.declarations.len, f.line_starts.len, t.revision orelse 0, t.list.items.len, pane.view.wrap, pane.view.layered, pane.view.body_h, pane.view.tagline_h, - pane.view.rect_h, + pane.view.rect_h, laneCells(pane), }; // One hash of them laid out as words: every reader of the map asks for // this key, a hundred times a frame. @@ -1813,7 +1819,8 @@ fn fillBody(tab: u16, dst: ?[]u8, pane: *Pane, f: *State, width: usize, record_w @memset(prefix, ' '); if (at == 0 and prefix.len > 0) { var lineno = row + 1; - var digit: usize = prefix.len - 1; + // The number, a blank, then the lanes (laneCells). + var digit: usize = prefix.len - 1 - laneCells(pane); if (row == end_slot) { prefix[digit - 1] = '~'; } else while (true) { @@ -1868,13 +1875,41 @@ fn fillBody(tab: u16, dst: ?[]u8, pane: *Pane, f: *State, width: usize, record_w /// made without the language's ink: highlightDiffPlain). /// /// Both are painted in recolorSyntax's one walk over the cells, each where -/// it says (one walk per painter cost a frame a sixth more). Ruled, not -/// built (PARDES.md "Changes on the source view"): 3. changes: a lane after -/// the line number, a line added whole green across it, a changed line's -/// words tinted, ghost rows for what the shown revision has not; 4. churn: -/// a heat lane after the number and a strip by the scroll thumb. +/// it says (one walk per painter cost a frame a sixth more). +/// +/// 3. changes (`Changes [revset]`, jj.zig): while `revset` is set, a +/// lane a pinned change after the line number (the gutter `lanes` +/// cells wider), a line one added whole green across it (jj.paint). +/// Ruled, not built (PARDES.md "Changes on the source view"): a +/// changed line's words tinted, ghost rows for what the shown +/// revision has not. +/// 4. churn, ruled, not built: a heat lane after the number and a strip +/// by the scroll thumb. pub const Layers = struct { + pub const replica = .{ .len = .{.{ "revset", "revset_len" }} }; ink: bool = true, + /// The changes this view pins (jj's revset), none while empty; what jj + /// answered for them is the pane's (`Pane.changes`). + revset: [revset_max]u8 = undefined, + revset_len: u8 = 0, + /// The cells its lanes take while it pins any, 0 while it pins none + /// (laneCells): set as it pins them, from the view's frontend: in a + /// window two, which its strips of pixels fill one and a half of + /// (Surface.Lane); in a terminal three, a glyph each. + lanes: u8 = 0, + + pub const revset_max = 64; + + pub fn pinned(l: *const Layers) []const u8 { + return l.revset[0..l.revset_len]; + } + + /// One word while it pins nothing: a digest walks every view's layers + /// of every pane (field by field it cost a step 0.1 to 0.7% more). + pub fn digest(l: *const Layers, h: *pardes.walk.Hasher) void { + h.update(&.{ @intFromBool(l.ink), l.revset_len, l.lanes }); + if (l.revset_len > 0) h.update(l.pinned()); + } }; pub const SynStyle = struct { fg: [3]u8, bold: bool }; |
