diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-21 18:47:01 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-21 21:34:04 -0300 |
| commit | 0d7879195a05b450877d2bf6bd625c01fbfbef8a (patch) | |
| tree | 78ee67251d7919335c2a7ac5e06afe2bbf158f24 /core/panes.zig | |
| parent | b7e843256982f5a22954d103bb40264daf2bb758 (diff) | |
| download | pardes-0d7879195a05b450877d2bf6bd625c01fbfbef8a.tar.gz pardes-0d7879195a05b450877d2bf6bd625c01fbfbef8a.zip | |
layers: ghost rows (slice 5): with `Changes` shown, what the file no longer has is drawn where it stood, rows of their own with no number and dimmer ink (`jj.Ghost`, kept with jj's answers, `Changes.ghosts` in `at` order, their text in `Changes.ghost_text` beside the hunks' removed lines): a line a pinned change took away whole, red across, in the line numbers' grey, placed by carrying the place it was taken from through the later pins' hunks into the shown text (`jj.carried`), and each pin's description after its last line (`id title author age`, the id's first four letters, the author's first name, the age short with no "ago", in its lane's colour, the author and age grey; the age is of the wall clock jj's answer carries, read where jj runs, an input as jj's answer is), the descriptions of blocks that close just above a place first and newest first, then the lines taken away there, then the descriptions of pins that have only those; a ghost row carries its own pin's lane and those of the line above that run on below it or close at or after it (`jj.ghostLanes`); the view's geometry takes the rows (`File.fillBody`'s ghosted instance, only while this view shows the changes and there are some: a ghost row's `wrap_col` is `-1 - ` its index, its `wrap_line` the line it stands before; `Pane.ghosts`/`ghost_text`, derived, set by `jj.showGhosts` each step while shown and as an answer lands), so the rows below move down in this view alone (another view with the lanes hidden is unmoved: tested); `wrapAt` says `ghost` and answers the line below at its start, so the cursor steps over them (`j` from the line above lands on the line below), selection, search hits, places and tables do not paint them, the line numbers skip them, a page ends before one; a Look (B3) on one opens its line in the revision it came from (`path@id-:line` for a line taken away, `path@id:line` for a description: `jj.lookGhost`); `]g` and `[g` (helix's, free in pardes's map: `goto_change`) go to the next and the previous change's first line (`jj.nextChange`); edits carry them as the lines' values (`jj.splice`: a ghost row stands before the line it stood before; one before a line taken out stands before the line after what took its place); in a terminal and in a window (tested both); round 3's lanes test reads each line's row through the view's map; tests: what the rows show (text, numbers, lanes by pin, grounds, inks) in both frontends and the other view unmoved; the cursor, the selection, `]g`/`[g` and a Look; the rows riding through two deletions with a client replaying them equal
Co-Authored-By: Claude Opus <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/panes.zig')
| -rw-r--r-- | core/panes.zig | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/core/panes.zig b/core/panes.zig index 8b152132..df85a508 100644 --- a/core/panes.zig +++ b/core/panes.zig @@ -31,7 +31,7 @@ pub const Pane = struct { /// it (views.zig). (The 9P server's part of `fs` says so in its type.) pub const replica = .{ .local = .{ "pv", "pv_known" }, - .derived = .{ "wrap_line", "wrap_col", "wrap_pad", "wrap_n", "body_wrapped", "context_rows", "body_rows", "body_visible_rows", "context_row_limit", "geometry_key", "geometry_len", "notices", "pan" }, + .derived = .{ "wrap_line", "wrap_col", "wrap_pad", "wrap_n", "body_wrapped", "context_rows", "body_rows", "body_visible_rows", "context_row_limit", "geometry_key", "geometry_len", "notices", "pan", "ghosts", "ghost_text" }, .len = .{ .{ "msg", "msg_len" }, .{ "msg_older", "msg_older_len" }, .{ "question", "question_len" }, .{ "shell_tail", "shell_tail_len" }, .{ "sel_snap", "nsel_snap" } }, // A picture's memory is its own allocator's (a dump loaded makes // it there). @@ -303,6 +303,14 @@ pub const Pane = struct { wrap_col: [limits.wrap_rows]i32 = undefined, wrap_pad: [limits.wrap_rows]u16 = @splat(0), wrap_n: u16 = 0, + /// The ghost rows of its pinned changes (jj.zig, `Ghost`: lines a + /// change took away, a change's description), the session's answers' + /// (`Pardes.changes`) as its geometry reads them while a view shows + /// them (`layers.lanes`): set by jj.showGhosts. A ghost row's `wrap_col` is + /// negative, `-1 - ` its index here, and its `wrap_line` the line it + /// stands before. + ghosts: []const @import("jj.zig").Ghost = &.{}, + ghost_text: []const u8 = "", /// A row map also exists for sticky headers when soft wrapping is off. body_wrapped: bool = false, context_rows: u16 = 0, @@ -591,10 +599,14 @@ pub const Pane = struct { return pane.surfRow(@as(i32, @intCast(Term.grid(pane.terminal).offset)) + pane.pan); } - pub fn wrapAt(pane: *Pane, tab: u16, vr: i32) struct { line: i32, at: i32, pad: i32 = 0 } { + /// The line and byte a body row shows from; a ghost row (jj.zig) is no + /// line's: `ghost`, the line below it at its start. + pub fn wrapAt(pane: *Pane, tab: u16, vr: i32) struct { line: i32, at: i32, pad: i32 = 0, ghost: bool = false } { File.geometry(tab, pane); - if (pane.wrap_n > 0 and vr >= 0 and vr < @as(i32, pane.wrap_n)) - return .{ .line = pane.wrap_line[@intCast(vr)], .at = pane.wrap_col[@intCast(vr)], .pad = pane.wrap_pad[@intCast(vr)] }; + if (pane.wrap_n > 0 and vr >= 0 and vr < @as(i32, pane.wrap_n)) { + const at = pane.wrap_col[@intCast(vr)]; + return .{ .line = pane.wrap_line[@intCast(vr)], .at = @max(at, 0), .pad = pane.wrap_pad[@intCast(vr)], .ghost = at < 0 }; + } // unwrapped: rows ARE lines, and the byte column a row starts at is the // horizontal scroll (always 0 on a terminal, which never has one) return .{ .line = pane.scroll() + vr, .at = pane.hscroll }; |
