summaryrefslogtreecommitdiff
path: root/dev
diff options
context:
space:
mode:
Diffstat (limited to 'dev')
-rw-r--r--dev/glide.zig51
-rw-r--r--dev/gui/gui.zig253
2 files changed, 272 insertions, 32 deletions
diff --git a/dev/glide.zig b/dev/glide.zig
index 711acb22..62e44bb7 100644
--- a/dev/glide.zig
+++ b/dev/glide.zig
@@ -39,9 +39,13 @@ pub const Glide = struct {
dir: i8 = 0,
before: []pardes.Cell = &.{},
/// The rows past the body's top (`above`) and bottom (`below`), nearest
- /// first, `bw` cells each: what the gap shows while the picture lags.
+ /// first, `bw` cells each, and a change's lanes on each (Surface.lanes,
+ /// a pixel shell's strips in the gutter, not cells): what the gap shows
+ /// while the picture lags.
above: []pardes.Cell = &.{},
below: []pardes.Cell = &.{},
+ above_lanes: []RowLanes = &.{},
+ below_lanes: []RowLanes = &.{},
nabove: u16 = 0,
nbelow: u16 = 0,
/// The core's lines a scroll moved, not yet measured; and what the
@@ -64,8 +68,10 @@ pub const Glide = struct {
/// not move, so a move is measured, and the rows that left are kept,
/// below them.
held: [pardes.MAX_PANES]u16 = @splat(0),
- /// The last frame's cells, which a move is measured against.
+ /// The last frame's cells, which a move is measured against, and its
+ /// lanes, which the rows that left take with them.
last: []pardes.Cell = &.{},
+ last_lanes: std.ArrayList(pardes.Lane) = .empty,
last_cols: u16 = 0,
last_rows: u16 = 0,
@@ -97,7 +103,10 @@ pub const Glide = struct {
gpa.free(glide.before);
gpa.free(glide.above);
gpa.free(glide.below);
+ gpa.free(glide.above_lanes);
+ gpa.free(glide.below_lanes);
gpa.free(glide.last);
+ glide.last_lanes.deinit(gpa);
}
pub fn bw(glide: *const Glide) u16 {
@@ -188,6 +197,8 @@ pub const Glide = struct {
glide.last_cols = surface.cols;
glide.last_rows = surface.rows;
glide.caret_row = if (surface.cursor) |c| c.y else null;
+ glide.last_lanes.clearRetainingCapacity();
+ glide.last_lanes.appendSlice(gpa, surface.lanes.items) catch {};
}
/// Finds how far the pane's body rows moved, `dir` rows at a time, by
@@ -261,28 +272,56 @@ pub const Glide = struct {
const src_row: usize = top + if (glide.dir > 0) shift - 1 - i else h - shift + i;
@memcpy(keep.*[i * w ..][0..w], glide.before[src_row * w ..][0..w]);
}
+ // Their lanes go with them, from the frame they left.
+ const keep_lanes = if (glide.dir > 0) glide.above_lanes else glide.below_lanes;
+ std.mem.copyBackwards(RowLanes, keep_lanes[shift..][0..kept], keep_lanes[0..kept]);
+ @memset(keep_lanes[0..shift], .{});
+ for (glide.last_lanes.items) |lane| {
+ if (lane.x < x0 or lane.x >= x0 + w or lane.y < glide.body_y + top or lane.y >= glide.body_y + glide.body_h) continue;
+ const row = lane.y - glide.body_y - top;
+ if (glide.dir > 0 and row < shift) keep_lanes[shift - 1 - row].add(lane);
+ if (glide.dir < 0 and row >= h - shift) keep_lanes[row - (h - shift)].add(lane);
+ }
count.* = kept + shift;
// What came into view is no longer past the other edge.
const other = if (glide.dir > 0) &glide.below else &glide.above;
+ const other_lanes = if (glide.dir > 0) glide.below_lanes else glide.above_lanes;
const other_n = if (glide.dir > 0) &glide.nbelow else &glide.nabove;
// ...and after a jump, the rows past it are another place's.
const dropped = if (far) other_n.* else @min(other_n.*, shift);
std.mem.copyForwards(pardes.Cell, other.*[0 .. @as(usize, other_n.* - dropped) * w], other.*[@as(usize, dropped) * w ..][0 .. @as(usize, other_n.* - dropped) * w]);
+ std.mem.copyForwards(RowLanes, other_lanes[0 .. other_n.* - dropped], other_lanes[dropped..][0 .. other_n.* - dropped]);
other_n.* -= dropped;
// An input: the core's rows moved by as many (down positive).
glide.follow.kick(@as(f32, @floatFromInt(shift)) * @as(f32, @floatFromInt(glide.dir)), glide.now_ns, glide.pace());
}
pub fn ensure(glide: *Glide, gpa: std.mem.Allocator) bool {
- const n = @as(usize, glide.bw()) * glide.body_h * reach;
- inline for (.{ &glide.above, &glide.below }) |buffer| if (buffer.len < n) {
- const grown = gpa.realloc(buffer.*, n) catch return false;
- buffer.* = grown;
+ const rows = @as(usize, glide.body_h) * reach;
+ inline for (.{ .{ &glide.above, rows * glide.bw() }, .{ &glide.below, rows * glide.bw() }, .{ &glide.above_lanes, rows }, .{ &glide.below_lanes, rows } }) |kept| if (kept[0].len < kept[1]) {
+ kept[0].* = gpa.realloc(kept[0].*, kept[1]) catch return false;
};
return true;
}
};
+/// A kept row's lanes, as the frame it left drew them: a row has a level
+/// each at most.
+pub const RowLanes = struct {
+ n: u8 = 0,
+ lane: [pardes.Lane.levels]pardes.Lane = undefined,
+
+ pub fn add(row: *RowLanes, lane: pardes.Lane) void {
+ if (row.n == row.lane.len) return;
+ row.lane[row.n] = lane;
+ row.n += 1;
+ }
+
+ pub fn items(row: *const RowLanes) []const pardes.Lane {
+ return row.lane[0..row.n];
+ }
+};
+
pub fn sameRow(a: []const pardes.Cell, b: []const pardes.Cell) bool {
for (a, b) |x, y| {
if (x.default != y.default) return false;
diff --git a/dev/gui/gui.zig b/dev/gui/gui.zig
index b00073fa..88ba023b 100644
--- a/dev/gui/gui.zig
+++ b/dev/gui/gui.zig
@@ -455,6 +455,7 @@ const Gui = struct {
scroll_lag: f32 = 0, // picture position - core position, in rows
scroll_edge: []pardes.Cell = &.{}, // the row that just left the pane
scroll_edge_len: u16 = 0,
+ scroll_edge_lanes: pardes.glide.RowLanes = .{}, // and a change's lanes on it
/// Loop steps since the last fractional turn: past `settle_after`, a
/// resting `scroll_lag` eases onto the core's row (stepScroll).
scroll_idle: u8 = 0,
@@ -3349,6 +3350,8 @@ const WheelRun = struct {
mc: MouseCell,
drawn: f32 = 0,
now_ns: u64 = std.time.ns_per_s,
+ /// Each frame given a change's lanes (testLanes), as `Changes` would.
+ lanes: bool = false,
fn init(gpa: std.mem.Allocator, core: *pardes.Pardes) !WheelRun {
var wr: WheelRun = .{ .g = testGui(10, 20, 6, 12), .core = core, .arena = .init(gpa), .mc = undefined };
@@ -3384,6 +3387,7 @@ const WheelRun = struct {
if (!wr.core.needs_frame and !frontendMoving(&wr.g)) return;
_ = wr.arena.reset(.retain_capacity);
const s = try wr.core.render(wr.arena.allocator());
+ if (wr.lanes) try testLanes(gpa, wr.core, s);
wr.g.frame = s;
wr.g.facts = s.facts.*;
wr.g.now_ns = wr.now_ns;
@@ -3559,6 +3563,8 @@ fn scrollRows(g: *Gui, in: *Input, gpa: std.mem.Allocator) bool {
if (g.scroll_edge.len >= bw) {
@memcpy(g.scroll_edge[0..bw], s.cells[@as(usize, srow) * s.cols + r.x + config.GUTTER ..][0..bw]);
g.scroll_edge_len = bw;
+ g.scroll_edge_lanes = .{};
+ for (s.lanes.items) |lane| if (lane.y == srow and lane.x >= r.x + config.GUTTER and lane.x < r.x + r.w) g.scroll_edge_lanes.add(lane);
}
}
}
@@ -3567,22 +3573,63 @@ fn scrollRows(g: *Gui, in: *Input, gpa: std.mem.Allocator) bool {
return moved;
}
+/// The body a scroll moves, as its rows are drawn: a glide's at its
+/// offset, else a touchpad's fraction (scroll_lag); its pane's rect (the
+/// rail and the body, Glide.rect's), its body's first row and its rows.
+/// Null when nothing lags, or when it was resized under us.
+const ScrollBody = struct {
+ pane: usize,
+ gliding: bool,
+ lag: f32,
+ rect: pardes.Rect,
+ y0: u16,
+ bh: u16,
+
+ /// The grid row of the `i`th row that left it, nearest first: over its
+ /// moving rows (under the `held` ones) while the picture lags a move
+ /// down, under the body for one up.
+ fn leftRow(sb: ScrollBody, held: u16, i: usize) i32 {
+ return if (sb.lag < 0) @as(i32, sb.y0 + held) - 1 - @as(i32, @intCast(i)) else @as(i32, sb.y0) + sb.bh + @as(i32, @intCast(i));
+ }
+
+ /// A glide's rows that left it drawn: as many as the lag opens.
+ fn glideLeft(sb: ScrollBody, glide: *const Glide) u16 {
+ const gap: u16 = @intFromFloat(@min(@ceil(@abs(sb.lag)), @as(f32, @floatFromInt(@as(u32, sb.bh) * Glide.reach))));
+ return @min(gap, if (sb.lag < 0) glide.nabove else glide.nbelow);
+ }
+};
+
+fn scrollBody(g: *const Gui, surface: *const pardes.Surface) ?ScrollBody {
+ const glide = &g.glide;
+ const gliding = glide.follow.offset != 0;
+ const sb: ScrollBody = .{
+ .pane = if (gliding) glide.pane else g.scroll_pane orelse return null,
+ .gliding = gliding,
+ .lag = if (gliding) glide.follow.offset else g.scroll_lag,
+ .rect = if (gliding) glide.rect else g.scroll_rect,
+ .y0 = if (gliding) glide.body_y else g.scroll_body_y,
+ .bh = if (gliding) glide.body_h else g.scroll_body_h,
+ };
+ const bw = sb.rect.w -| config.GUTTER;
+ if (sb.lag == 0 or bw == 0 or sb.bh == 0 or sb.rect.x + config.GUTTER + bw > surface.cols or sb.y0 + sb.bh > surface.rows) return null;
+ return sb;
+}
+
/// A scrolling body's picture: its rows moved by the lag, a glide's or a
/// touchpad's fraction of a row, and in the gap that opens the rows that
/// left.
fn emitScrollRows(g: *Gui, instances: [*]CellInstance, base: u32, surface: *const pardes.Surface, layout: CellLayout, win_w: f32, win_h: f32, page: [3]u8, held: u16) u32 {
g.scroll_held_px = 0;
const glide = &g.glide;
- const gliding = glide.follow.offset != 0;
- const pane = if (gliding) glide.pane else g.scroll_pane orelse return 0;
- const lag = if (gliding) glide.follow.offset else g.scroll_lag;
- if (lag == 0) return 0;
- const r = if (gliding) glide.rect else g.scroll_rect;
- const bh = if (gliding) glide.body_h else g.scroll_body_h;
- const y0 = if (gliding) glide.body_y else g.scroll_body_y;
- const bw = r.w -| config.GUTTER;
+ const sb = scrollBody(g, surface) orelse return 0;
+ const gliding = sb.gliding;
+ const pane = sb.pane;
+ const lag = sb.lag;
+ const r = sb.rect;
+ const bh = sb.bh;
+ const y0 = sb.y0;
+ const bw = r.w - config.GUTTER;
const x0 = r.x + config.GUTTER;
- if (bw == 0 or bh == 0 or x0 + bw > surface.cols or y0 + bh > surface.rows) return 0; // resized under us
// The scissor the shifted rows are drawn in is the scroll's.
g.scroll_rect = r;
g.scroll_body_y = y0;
@@ -3627,7 +3674,7 @@ fn emitScrollRows(g: *Gui, instances: [*]CellInstance, base: u32, surface: *cons
// A touchpad's fraction opens one row, the one that left: under the
// held rows, where the moving rows start.
if (g.scroll_edge_len >= bw) {
- const erow: u16 = if (lag > 0) y0 + bh else y0 + kept.rows - 1;
+ const erow: u16 = @intCast(sb.leftRow(kept.rows, 0));
var i: u16 = 0;
while (i < bw) : (i += 1) {
emitInstance(g, instances, base + n, x0 + i, erow, shifted, win_w, win_h, cellFontRole(&g.scroll_edge[i]), g.scroll_edge[0..bw], i, null, false, page);
@@ -3638,14 +3685,10 @@ fn emitScrollRows(g: *Gui, instances: [*]CellInstance, base: u32, surface: *cons
}
// A glide's: rows past the top while the picture lags a move down, past
// the bottom for one up; as many as it opens.
- const gap: u16 = @intFromFloat(@min(@ceil(@abs(lag)), @as(f32, @floatFromInt(@as(u32, bh) * Glide.reach))));
- const nkept = if (lag < 0) glide.nabove else glide.nbelow;
const rows = if (lag < 0) glide.above else glide.below;
- for (0..@min(gap, nkept)) |i| {
+ for (0..sb.glideLeft(glide)) |i| {
const cells = rows[i * bw ..][0..bw];
- // Row -1 - i above the moving rows (under the held ones), or bh + i
- // below the body, in grid rows.
- const at_row: i32 = if (lag < 0) @as(i32, y0 + kept.rows) - 1 - @as(i32, @intCast(i)) else @as(i32, y0) + bh + @as(i32, @intCast(i));
+ const at_row = sb.leftRow(kept.rows, i);
var at = shifted;
// emitInstance takes an unsigned row: move the layout instead.
at.y_off += @as(f32, @floatFromInt(at_row - @as(i32, y0))) * layout.h;
@@ -4916,16 +4959,7 @@ fn buildDecor(g: *Gui, gpa: std.mem.Allocator, surface: *const pardes.Surface, g
} else false;
if (grid_bottom < win_h and tag_last) try addDecor(g, gpa, 0, grid_bottom, win_w, win_h, chrome.tag_bg, 1, win_w, win_h);
try paneDecor(g, gpa, regions, surface.rail_ticks[0..surface.nrail_ticks], surface.heat.items, chrome, layout, surface.cols, surface.rows, win_w, win_h);
- // The changes' lanes (jj.paint): a strip a level in the gutter's
- // lane cells, each a third of a cell wide with half that of air
- // before it, so three take one and a half cells (the ruled
- // sample A); whole pixels, so every row's strip lines up.
- for (surface.lanes.items) |lane| {
- const w = @max(1, @round(layout.w / 3));
- const x0 = @round(@as(f32, @floatFromInt(lane.x)) * layout.w + w / 2 + @as(f32, @floatFromInt(lane.level)) * (w + w / 2));
- const y0 = @as(f32, @floatFromInt(lane.y)) * layout.h;
- try addDecor(g, gpa, x0, y0, x0 + w, y0 + layout.h, lane.rgb, 1, win_w, win_h);
- }
+ try laneDecor(g, gpa, surface, layout, win_w, win_h);
// A single spine runs down each column, through every tag and body.
for (regions) |column| {
if (column.kind != .column) continue;
@@ -4955,6 +4989,58 @@ fn buildDecor(g: *Gui, gpa: std.mem.Allocator, surface: *const pardes.Surface, g
}
}
+/// The changes' lanes (jj.paint): a strip a level in the gutter's lane
+/// cells, each a third of a cell wide with half that of air before it, so
+/// three take one and a half cells (the ruled sample A); whole pixels, so
+/// every row's strip lines up. A scrolling body's ride its rows as
+/// emitScrollRows draws them: the lag less, cut to the body under its held
+/// rows (its scissor), and the rows that left keep theirs in the gap.
+fn laneDecor(g: *Gui, gpa: std.mem.Allocator, surface: *const pardes.Surface, layout: CellLayout, win_w: f32, win_h: f32) !void {
+ const w = @max(1, @round(layout.w / 3));
+ const b = scrollBody(g, surface) orelse {
+ for (surface.lanes.items) |lane| try laneStrip(g, gpa, lane, lane.y, null, w, layout, win_w, win_h);
+ return;
+ };
+ const kept = holdContext(g, surface, b.pane, if (surface.facts.pane(b.pane)) |pane| pane.context_rows else 0, b.bh, layout);
+ const ride: LaneRide = .{
+ .x0 = b.rect.x + config.GUTTER,
+ .x1 = b.rect.x + b.rect.w,
+ .y0 = b.y0 + kept.rows,
+ .y1 = b.y0 + b.bh,
+ .dy = b.lag * layout.h - kept.lift,
+ .top = @as(f32, @floatFromInt(b.y0 + kept.rows)) * layout.h + kept.lift,
+ .bottom = @as(f32, @floatFromInt(b.y0 + b.bh)) * layout.h,
+ };
+ for (surface.lanes.items) |lane| {
+ const rides = lane.x >= ride.x0 and lane.x < ride.x1 and lane.y >= ride.y0 and lane.y < ride.y1;
+ try laneStrip(g, gpa, lane, lane.y, if (rides) &ride else null, w, layout, win_w, win_h);
+ }
+ if (b.gliding) {
+ const rows = if (b.lag < 0) g.glide.above_lanes else g.glide.below_lanes;
+ for (rows[0..b.glideLeft(&g.glide)], 0..) |*row, i| for (row.items()) |lane| try laneStrip(g, gpa, lane, b.leftRow(kept.rows, i), &ride, w, layout, win_w, win_h);
+ } else if (g.scroll_edge_len >= b.rect.w - config.GUTTER) {
+ for (g.scroll_edge_lanes.items()) |lane| try laneStrip(g, gpa, lane, b.leftRow(kept.rows, 0), &ride, w, layout, win_w, win_h);
+ }
+}
+
+/// A scrolling body's moving rows (laneDecor): their columns and rows, how
+/// far up they are drawn, and the pixels they are cut to.
+const LaneRide = struct { x0: u16, x1: u16, y0: u16, y1: u16, dy: f32, top: f32, bottom: f32 };
+
+/// `lane`'s strip, `w` pixels wide, on grid row `row`, riding a scroll's
+/// rows when given one.
+fn laneStrip(g: *Gui, gpa: std.mem.Allocator, lane: pardes.Lane, row: i32, ride: ?*const LaneRide, w: f32, layout: CellLayout, win_w: f32, win_h: f32) !void {
+ const x0 = @round(@as(f32, @floatFromInt(lane.x)) * layout.w + w / 2 + @as(f32, @floatFromInt(lane.level)) * (w + w / 2));
+ var y0 = @as(f32, @floatFromInt(row)) * layout.h;
+ var y1 = y0 + layout.h;
+ if (ride) |r| {
+ y0 = @max(y0 - r.dy, r.top);
+ y1 = @min(y1 - r.dy, r.bottom);
+ if (y1 <= y0) return;
+ }
+ try addDecor(g, gpa, x0, y0, x0 + w, y1, lane.rgb, 1, win_w, win_h);
+}
+
/// Each pane's rule between its tag and body, and its scroll rail: a page
/// coloured gutter with a thin track and its thumb, running down through the
/// pixels past the last whole row.
@@ -6650,6 +6736,121 @@ test "a wheel's caret rides with its line, the text's own glide, never a spring
try std.testing.expectEqual(@as(f32, @floatFromInt(s.cursor.?.y)), caretRow(&g, s, now).?);
}
+/// The active pane's body in a frame.
+fn testBody(core: *pardes.Pardes, s: *const pardes.Surface) pardes.Rect {
+ for (s.regionList()) |region| if (region.kind == .body and region.owner == core.view().active) return region.rect;
+ unreachable;
+}
+
+/// A change's lanes on the active body's rows as jj.paint lays them for a
+/// window (Surface.lanes), for a test: line L's on its row, 1 + L % 3
+/// levels, coloured its line, its level and 0x37, so a strip names its line.
+fn testLanes(gpa: std.mem.Allocator, core: *pardes.Pardes, s: *pardes.Surface) !void {
+ const body = testBody(core, s);
+ const top = core.panes[core.view().active].?.scroll();
+ for (0..body.h) |vr| {
+ const line: usize = @intCast(top + @as(i32, @intCast(vr)));
+ for (0..1 + line % 3) |level|
+ try s.lanes.append(gpa, .{ .x = body.x + 1, .y = body.y + @as(u16, @intCast(vr)), .level = @intCast(level), .rgb = .{ @intCast(line), @intCast(level), 0x37 } });
+ }
+}
+
+/// The frame's lane strips (testLanes') against where their lines are
+/// drawn: line L of a body whose first line is the core's `top`, its rows
+/// `lag` behind (a glide's offset or a touchpad's fraction), at body row
+/// L - top - lag (emitScrollRows), with its strips there, cut to the body;
+/// a line drawn outside it, none.
+fn expectLanesRide(g: *Gui, gpa: std.mem.Allocator, core: *pardes.Pardes, s: *const pardes.Surface, lag: f32) !void {
+ g.decor.clearRetainingCapacity();
+ var groups: Groups = .{};
+ const layout = fixedCellLayout(g);
+ const win_h: f32 = @floatFromInt(@as(u32, s.rows) * g.cell_h);
+ try buildDecor(g, gpa, s, &groups, layout, @floatFromInt(@as(u32, s.cols) * g.cell_w), win_h, false);
+ const body = testBody(core, s);
+ const top = core.panes[core.view().active].?.scroll();
+ const body_y0 = @as(f32, @floatFromInt(body.y)) * layout.h;
+ const body_y1 = @as(f32, @floatFromInt(body.y + body.h)) * layout.h;
+ var strips: [256]u8 = @splat(0);
+ for (g.decor.items) |item| {
+ if (@abs(item.bb * 255 - 0x37) > 0.01 or item.bg * 255 > 2.01) continue;
+ const line: u8 = @intFromFloat(@round(item.br * 255));
+ const at = (@as(f32, @floatFromInt(body.y)) + @as(f32, @floatFromInt(@as(i32, line) - top)) - lag) * layout.h;
+ try std.testing.expectApproxEqAbs(@max(at, body_y0), (1 - item.y0) / 2 * win_h, 0.01);
+ try std.testing.expectApproxEqAbs(@min(at + layout.h, body_y1), (1 - item.y1) / 2 * win_h, 0.01);
+ strips[line] += 1;
+ }
+ for (strips, 0..) |n, line| {
+ const at = (@as(f32, @floatFromInt(body.y)) + @as(f32, @floatFromInt(@as(i32, @intCast(line)) - top)) - lag) * layout.h;
+ const shown = @min(at + layout.h, body_y1) - @max(at, body_y0);
+ // A sliver under a hundredth of a pixel either way.
+ if (@abs(shown) < 0.01) continue;
+ try std.testing.expectEqual(@as(usize, if (shown > 0) 1 + line % 3 else 0), n);
+ }
+}
+
+test "a change's lanes ride their lines: mid-glide (a wheel's notch, Ctrl-d) and under a touchpad's fraction each strip is where its line is drawn, cut to the body, and the rows that left keep theirs" {
+ const gpa = std.testing.allocator;
+ {
+ const core = try pardes.Pardes.init(gpa, .{ .cols = 80, .rows = 24 });
+ defer core.deinit();
+ var text: std.ArrayList(u8) = .empty;
+ defer text.deinit(gpa);
+ for (0..200) |i| try text.print(gpa, "line {d}\n", .{i});
+ _ = try core.setTestFile(text.items);
+ for ("100G") |ch| core.update(.{ .key = .{ .cp = ch, .text = &.{ch} } });
+ var arena: std.heap.ArenaAllocator = .init(gpa);
+ defer arena.deinit();
+ var g = testGui(10, 20, 6, 12);
+ defer g.glide.deinit(gpa);
+ defer g.decor.deinit(gpa);
+ const r = core.view().rects[core.view().active];
+ g.scroll_pane = core.view().active;
+ g.scroll_col = r.x + 10;
+ g.scroll_row = r.y + r.h - 2;
+ var now: u64 = std.time.ns_per_s;
+ var mid: usize = 0;
+ // The view drawn once at rest, then a notch down (the wheel's) and
+ // Ctrl-d, each glided to rest, every frame checked.
+ for ([_]?pardes.Key{ null, null, .{ .cp = 'd', .ctrl = true } }, 0..) |key, step| {
+ if (key) |k| core.update(.{ .key = k }) else if (step > 0) g.scroll_notch = 1;
+ var frames: usize = 0;
+ while (true) : (frames += 1) {
+ stepGlide(&g, core);
+ now += std.time.ns_per_s / 60;
+ core.advance(now);
+ _ = arena.reset(.retain_capacity);
+ const s = try core.render(arena.allocator());
+ try testLanes(gpa, core, s);
+ g.now_ns = now;
+ glideFrame(&g, gpa, s);
+ if (g.glide.follow.offset != 0) mid += 1;
+ try expectLanesRide(&g, gpa, core, s, g.glide.follow.offset);
+ if (!g.glide.moving()) break;
+ if (frames > 200) return error.NeverSettled;
+ }
+ }
+ try std.testing.expect(mid > 10);
+ }
+ // A touchpad's half notch down, settled, then up: the text half a row
+ // off its cells, and the row that left in the half row it opens.
+ const core = try wheelRunFile(gpa);
+ defer core.deinit();
+ var wr = try WheelRun.init(gpa, core);
+ defer wr.deinit(gpa);
+ defer wr.g.decor.deinit(gpa);
+ wr.lanes = true;
+ core.needs_frame = true;
+ try wr.frame(gpa, &.{});
+ for ([_]f32{ -0.5, 0.5 }) |turn| {
+ try wr.frame(gpa, &.{turn});
+ try std.testing.expectEqual(turn, wr.g.scroll_lag);
+ try expectLanesRide(&wr.g, gpa, core, wr.g.frame.?, wr.g.scroll_lag);
+ for (0..20) |_| try wr.frame(gpa, &.{});
+ try std.testing.expectEqual(@as(f32, 0), wr.g.scroll_lag);
+ try expectLanesRide(&wr.g, gpa, core, wr.g.frame.?, 0);
+ }
+}
+
test "every scroll glides on one law: a half page, a page, the far jumps, a run of them retargeting" {
const gpa = std.testing.allocator;
const core = try pardes.Pardes.init(gpa, .{ .cols = 100, .rows = 40 });