summaryrefslogtreecommitdiff
path: root/anim/src/source.zig
diff options
context:
space:
mode:
Diffstat (limited to 'anim/src/source.zig')
-rw-r--r--anim/src/source.zig13
1 files changed, 10 insertions, 3 deletions
diff --git a/anim/src/source.zig b/anim/src/source.zig
index 0bba714..6b693a4 100644
--- a/anim/src/source.zig
+++ b/anim/src/source.zig
@@ -42,7 +42,12 @@ pub const Source = struct {
// moves on) gliding to where the next one does. It never cuts.
const going = now.advancing();
const windows = [2]f32{ @floatFromInt(rec.viewFirst(fit, was)), @floatFromInt(rec.viewFirst(fit, here)) };
- const first = std.math.lerp(windows[0], windows[1], cursors.glide(going));
+ // Further than two windows (a large file, another function far
+ // off): what leaves has left before what replaces it arrives; a
+ // scroll through thousands of lines would be a blur, and say nothing.
+ const far = @abs(windows[1] - windows[0]) > 2 * @as(f32, @floatFromInt(fit));
+ const first = if (far) windows[if (going >= 0.5) 1 else 0] else std.math.lerp(windows[0], windows[1], cursors.glide(going));
+ const lit = if (far and going < 1) u.faded(@abs(2 * going - 1)) else u;
const from: u32 = @intFromFloat(@floor(first));
const last: u32 = @min(from + @as(u32, @intCast(context.rowsOf(box))), rec.line_count);
const shown_first: u32 = @intFromFloat(windows[if (going >= 0.5) 1 else 0]);
@@ -73,11 +78,13 @@ pub const Source = struct {
}
}
const mark_y = top + (mark_at - first) * m.row;
+ // The numbers of the two windows, as wide as the widest needs.
+ const widen = rows.numberRoom(@min(@as(u32, @intFromFloat(@max(windows[0], windows[1]))) + @as(u32, @intCast(context.rowsOf(box))), rec.line_count));
context.clipBody(u, box);
defer u.unclip();
// The plaque over the number. Fire: on the line about to run its
// edges go out and come back, once, and nothing else moves.
- if (shows > 0) u.faded(shows).current(.{ .x = theme.stroke.rule, .y = mark_y, .w = box.w - 2 * theme.stroke.rule, .h = m.row }, theme.metric.plaque.line, now.fires(.source));
+ if (shows > 0) u.faded(shows).current(.{ .x = theme.stroke.rule, .y = mark_y, .w = box.w - 2 * theme.stroke.rule, .h = m.row }, theme.metric.plaque.line + widen, now.fires(.source));
if (shows >= 1 and mark_y >= body.y and mark_y + m.row <= box.h) ties.anchor(u, .source, .{ .x = 0, .y = mark_y, .w = box.w, .h = m.row });
// The trail: the last three other lines it was on. It shifts without animation.
@@ -99,7 +106,7 @@ pub const Source = struct {
const span = text.lines[line - 1];
const k = std.mem.indexOfScalar(u32, trail[0..found], line);
const on = shows >= 0.5 and line == mark_line;
- rows.line(u, y, box.w, line, text.bytes[span[0]..span[1]], text.styles[span[0]..span[1]], if (on) .marked else if (k) |n| .{ .trail = n } else .plain);
+ rows.line(lit, y, box.w, line, widen, text.bytes[span[0]..span[1]], text.styles[span[0]..span[1]], if (on) .marked else if (k) |n| .{ .trail = n } else .plain);
}
// The source is read at a run; at a sprint it is veiled too.
context.veiled(u, box, now.sprint_veil);