summaryrefslogtreecommitdiff
path: root/core/File.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/File.zig')
-rw-r--r--core/File.zig51
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 };