summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/FrameStats.zig844
-rw-r--r--src/gui/gui.zig10
-rw-r--r--test/perf.zig28
-rw-r--r--tools/demos/clip-cursor.txt9
-rw-r--r--tools/demos/clip-far.txt5
-rw-r--r--tools/demos/clip-flick.txt4
-rw-r--r--tools/demos/clip-pages.txt3
-rw-r--r--tools/demos/clip-query.txt5
-rw-r--r--tools/demos/clip-terminal.txt6
-rw-r--r--tools/demos/jumps.txt101
-rw-r--r--tools/demos/kinds.txt216
-rw-r--r--tools/demos/longlines.txt150
-rw-r--r--tools/demos/one.txt11
-rw-r--r--tools/demos/panes.txt91
-rw-r--r--tools/demos/pdf-scroll.txt22
-rw-r--r--tools/demos/pdf-sdm.txt24
-rw-r--r--tools/demos/scroll.txt25
-rw-r--r--tools/demos/stress.txt24
18 files changed, 840 insertions, 738 deletions
diff --git a/src/FrameStats.zig b/src/FrameStats.zig
index 33ffd300..fb882d69 100644
--- a/src/FrameStats.zig
+++ b/src/FrameStats.zig
@@ -16,10 +16,11 @@
//! glyph rasterizing) and the view it showed, so a spike is attributed and
//! a scroll's throughput is counted in rows actually presented.
//!
-//! `PARDES_FRAMES_DEMO=scroll` (or `stress`) runs a timed script of scroll
-//! inputs (`named`) in a pixel shell (the GUI feeds them through its own
-//! wheel and key paths) and then ends the session: a timedemo, so two
-//! builds are compared on the same motion, on a real display.
+//! `PARDES_FRAMES_DEMO=<file>` runs a timed script of inputs (`parseScript`;
+//! the ones the notes measured with are in tools/demos/) in a pixel shell
+//! (the GUI feeds them through its own wheel and key paths) and then ends
+//! the session: a timedemo, so two builds are compared on the same motion,
+//! on a real display.
const std = @import("std");
const pardes = @import("pardes.zig");
const animation = @import("animation.zig");
@@ -100,9 +101,9 @@ shaped: u16 = 0,
rastered: u16 = 0,
bytes: u32 = 0,
landed: u16 = 0,
-/// When the timedemo started, monotonic ns (0: none ran), and which.
+/// When the timedemo started, monotonic ns (0: none ran), and its steps.
demo_ns: u64 = 0,
-demo_name: []const u8 = "",
+demo: []const Step = &.{},
/// The frame being timed: its marks, the monotonic clock's ns.
mark_start: u64 = 0,
mark_update: u64 = 0,
@@ -272,7 +273,7 @@ pub fn dump(stats: *const FrameStats, path: [:0]const u8) void {
// up with the frames' by this.
write.line(fd, &buf, "# t0_ns {d}\n", .{t0});
// The timedemo's phases, on the frames' clock.
- if (stats.demo_ns != 0) if (named(stats.demo_name)) |steps| for (steps) |step| switch (step.act) {
+ for (stats.demo) |step| switch (step.act) {
.phase => |name| write.line(fd, &buf, "# phase {s} {d:.1}\n", .{ name, @as(f64, @floatFromInt((stats.demo_ns + @as(u64, step.at_ms) * std.time.ns_per_ms) -| t0)) / std.time.ns_per_ms }),
else => {},
};
@@ -289,7 +290,7 @@ pub fn dump(stats: *const FrameStats, path: [:0]const u8) void {
};
}
-/// One input of the scroll timedemo, `at_ms` after the first frame.
+/// One input of a timedemo, `at_ms` after the first frame.
pub const Step = struct {
at_ms: u32,
act: union(enum) {
@@ -316,732 +317,97 @@ pub const Step = struct {
},
};
-/// Every kind of scroll a user makes, on a long file from its top: single
-/// notches, a fast spin of the wheel both ways (notches 8 ms apart, two a
-/// frame: each retargets the one before), half pages, pages, the far jumps
-/// to the end (ge) and back (gg), half pages faster than they settle, and the cursor
-/// moving a line, a word and, in insert mode, a column at a time.
-/// The timedemo PARDES_FRAMES_DEMO names, if any.
-pub fn named(name: []const u8) ?[]const Step {
- if (std.mem.eql(u8, name, "scroll")) return &demo;
- if (std.mem.eql(u8, name, "stress")) return &stress;
- if (std.mem.eql(u8, name, "kinds")) return &kinds;
- if (std.mem.eql(u8, name, "panes")) return &panes;
- if (std.mem.eql(u8, name, "pdf-scroll")) return &pdf_scroll;
- if (std.mem.eql(u8, name, "pdf-sdm")) return &pdf_sdm;
- if (std.mem.eql(u8, name, "one")) return &one;
- if (std.mem.eql(u8, name, "keys")) return &keystrokes;
- if (std.mem.eql(u8, name, "jumps")) return &jumps;
- if (std.mem.eql(u8, name, "longlines")) return &longlines;
- if (std.mem.eql(u8, name, "clip-flick")) return &clip_flick;
- if (std.mem.eql(u8, name, "clip-far")) return &clip_far;
- if (std.mem.eql(u8, name, "clip-cursor")) return &clip_cursor;
- if (std.mem.eql(u8, name, "clip-query")) return &clip_query;
- if (std.mem.eql(u8, name, "clip-terminal")) return &clip_terminal;
- if (std.mem.eql(u8, name, "clip-pages")) return &clip_pages;
- return null;
-}
-
-pub const demo = blk: {
- @setEvalBranchQuota(20_000);
- var steps: [128]Step = undefined;
- var n: usize = 0;
- var t: u32 = 1500;
- steps[n] = .{ .at_ms = t, .act = .{ .phase = "notches" } };
- n += 1;
- for (0..10) |_| {
- steps[n] = .{ .at_ms = t, .act = .{ .wheel = 1 } };
- n += 1;
- t += 150;
- }
- t += 400;
- steps[n] = .{ .at_ms = t, .act = .{ .phase = "spin" } };
- n += 1;
- for ([_]i8{ 1, -1 }) |dir| {
- for (0..24) |_| {
- steps[n] = .{ .at_ms = t, .act = .{ .wheel = dir } };
- n += 1;
- t += 8;
- }
- t += 800;
- }
- const ctrl = struct {
- fn key(cp: u21) pardes.Key {
- return .{ .cp = cp, .ctrl = true };
+/// A timedemo's script, the file PARDES_FRAMES_DEMO names (tools/demos/): an
+/// input a line, `<ms> <action> [<arg>]` at `ms` after the first frame, or
+/// `<ms> <n>x<every> <action> [<arg>]` for n of them `every` ms apart; a
+/// line that starts with `#` says what the script is. The actions: `wheel
+/// <notches>` (down positive), `touch <lines>`, `key <k>`, `keys <k>...`
+/// (its keys in turn, each `every` ms after the one before, n times over),
+/// `phase <name>`, `click <button> <at> rail` or `text`, `rail_wheel
+/// <notches>`, `paste <text>` and `exec <line>` (in both `\n` is a newline
+/// and `\\` a backslash), and `end`. A key is a character (its text typed),
+/// `space`, `^<c>` (with Ctrl) or a pardes.Key name (enter, page_down, ...).
+/// The steps' strings are `text`'s, or `arena`'s where an escape was undone.
+pub fn parseScript(arena: std.mem.Allocator, text: []const u8) error{ OutOfMemory, BadScript }![]Step {
+ var steps: std.ArrayList(Step) = .empty;
+ var lines = std.mem.splitScalar(u8, text, '\n');
+ while (lines.next()) |raw| {
+ const line = std.mem.trimEnd(u8, raw, "\r");
+ if (line.len == 0 or line[0] == '#') continue;
+ var words = std.mem.tokenizeScalar(u8, line, ' ');
+ const at = std.fmt.parseInt(u32, words.next() orelse return error.BadScript, 10) catch return error.BadScript;
+ var word = words.next() orelse return error.BadScript;
+ var count: u32 = 1;
+ var every: u32 = 0;
+ if (std.ascii.isDigit(word[0])) {
+ const x = std.mem.indexOfScalar(u8, word, 'x') orelse return error.BadScript;
+ count = std.fmt.parseInt(u32, word[0..x], 10) catch return error.BadScript;
+ every = std.fmt.parseInt(u32, word[x + 1 ..], 10) catch return error.BadScript;
+ word = words.next() orelse return error.BadScript;
}
- };
- steps[n] = .{ .at_ms = t, .act = .{ .phase = "pages" } };
- n += 1;
- for ([_]u21{ 'd', 'd', 'd', 'u', 'u', 'f', 'b' }) |cp| {
- steps[n] = .{ .at_ms = t, .act = .{ .key = ctrl.key(cp) } };
- n += 1;
- t += 600;
- }
- for ([_]u21{ 'g', 'e' }, [_][]const u8{ "g", "e" }, 0..) |cp, text, i| {
- steps[n] = .{ .at_ms = t + 20 * i, .act = .{ .key = .{ .cp = cp, .text = text } } };
- n += 1;
- }
- t += 800;
- for (0..2) |i| {
- steps[n] = .{ .at_ms = t + 20 * i, .act = .{ .key = .{ .cp = 'g', .text = "g" } } };
- n += 1;
- }
- t += 800;
- steps[n] = .{ .at_ms = t, .act = .{ .phase = "retarget" } };
- n += 1;
- for (0..4) |_| {
- steps[n] = .{ .at_ms = t, .act = .{ .key = ctrl.key('d') } };
- n += 1;
- t += 80;
- }
- t += 700;
- steps[n] = .{ .at_ms = t, .act = .{ .phase = "cursor" } };
- n += 1;
- for ([_]struct { u21, []const u8, u32 }{ .{ 'j', "j", 60 }, .{ 'w', "w", 90 } }) |run| {
- for (0..10) |_| {
- steps[n] = .{ .at_ms = t, .act = .{ .key = .{ .cp = run[0], .text = run[1] } } };
- n += 1;
- t += run[2];
- }
- t += 400;
- }
- steps[n] = .{ .at_ms = t, .act = .{ .key = .{ .cp = 'i', .text = "i" } } };
- n += 1;
- t += 300;
- for ([_]struct { u21, u32 }{ .{ pardes.Key.right, 60 }, .{ pardes.Key.down, 100 } }) |run| {
- for (0..8) |_| {
- steps[n] = .{ .at_ms = t, .act = .{ .key = .{ .cp = run[0] } } };
- n += 1;
- t += run[1];
- }
- t += 300;
- }
- steps[n] = .{ .at_ms = t, .act = .{ .key = .{ .cp = pardes.Key.escape } } };
- steps[n + 1] = .{ .at_ms = t + 1000, .act = .end };
- n += 2;
- const out = steps[0..n].*;
- break :blk out;
-};
-
-/// The scrolls every kind of text and pane is put through (`kinds`,
-/// `panes`), from `t`: notches, a spin, half pages, PageDown held, the far
-/// jumps, the cursor down a held j. 7.5 s.
-fn scrollSet(steps: []Step, n: *usize, t: *u32) void {
- const at = struct {
- fn add(s: []Step, k: *usize, ms: u32, act: @FieldType(Step, "act")) void {
- s[k.*] = .{ .at_ms = ms, .act = act };
- k.* += 1;
+ const arg = words.rest();
+ if (std.mem.eql(u8, word, "keys")) {
+ var k: u32 = 0;
+ for (0..count) |_| {
+ var names = std.mem.tokenizeScalar(u8, arg, ' ');
+ while (names.next()) |name| : (k += 1) try steps.append(arena, .{ .at_ms = at + k * every, .act = .{ .key = keyOf(name) orelse return error.BadScript } });
+ }
+ continue;
}
- };
- for (0..6) |_| {
- at.add(steps, n, t.*, .{ .wheel = 1 });
- t.* += 150;
- }
- for (0..100) |_| {
- at.add(steps, n, t.*, .{ .wheel = 1 });
- t.* += 8;
- }
- t.* += 500;
- for (0..3) |_| {
- at.add(steps, n, t.*, .{ .key = .{ .cp = 'd', .ctrl = true } });
- t.* += 400;
- }
- for (0..45) |_| {
- at.add(steps, n, t.*, .{ .key = .{ .cp = pardes.Key.page_down } });
- t.* += 33;
- }
- t.* += 400;
- for ([_][]const u8{ "e", "g" }) |second| {
- at.add(steps, n, t.*, .{ .key = .{ .cp = 'g', .text = "g" } });
- at.add(steps, n, t.* + 20, .{ .key = .{ .cp = second[0], .text = second } });
- t.* += 600;
- }
- for (0..30) |_| {
- at.add(steps, n, t.*, .{ .key = .{ .cp = 'j', .text = "j" } });
- t.* += 33;
+ const Act = @FieldType(Step, "act");
+ const act: Act = switch (std.meta.stringToEnum(std.meta.Tag(Act), word) orelse return error.BadScript) {
+ .wheel => .{ .wheel = std.fmt.parseInt(i8, arg, 10) catch return error.BadScript },
+ .rail_wheel => .{ .rail_wheel = std.fmt.parseInt(i8, arg, 10) catch return error.BadScript },
+ .touch => .{ .touch = std.fmt.parseFloat(f32, arg) catch return error.BadScript },
+ .key => .{ .key = keyOf(arg) orelse return error.BadScript },
+ .phase => .{ .phase = arg },
+ .click => click: {
+ var parts = std.mem.tokenizeScalar(u8, arg, ' ');
+ const button = std.meta.stringToEnum(pardes.Mouse.Button, parts.next() orelse "") orelse return error.BadScript;
+ const where = std.fmt.parseFloat(f32, parts.next() orelse "") catch return error.BadScript;
+ const on = parts.next() orelse "";
+ if (!std.mem.eql(u8, on, "rail") and !std.mem.eql(u8, on, "text")) return error.BadScript;
+ break :click .{ .click = .{ .button = button, .at = where, .rail = std.mem.eql(u8, on, "rail") } };
+ },
+ .paste => .{ .paste = try unescaped(arena, arg) },
+ .exec => .{ .exec = try unescaped(arena, arg) },
+ .end => .end,
+ };
+ for (0..count) |i| try steps.append(arena, .{ .at_ms = at + @as(u32, @intCast(i)) * every, .act = act });
}
- t.* += 500;
+ if (steps.items.len == 0) return error.BadScript;
+ return steps.toOwnedSlice(arena);
}
-/// A PDF's strip put through what moves it (anim 11): a wheel's notches,
-/// then spun; PageDown held; the far jumps ge and gg; a Look at a page and
-/// Back; then slow: a notch at a time, and a touchpad's drag a pixel or so
-/// a frame.
-pub const pdf_scroll = blk: {
- @setEvalBranchQuota(20_000);
- var steps: [512]Step = undefined;
- var n: usize = 0;
- var t: u32 = 1500;
- const at = struct {
- fn add(s: []Step, k: *usize, ms: u32, act: @FieldType(Step, "act")) void {
- s[k.*] = .{ .at_ms = ms, .act = act };
- k.* += 1;
- }
- };
- at.add(&steps, &n, t, .{ .exec = "Look ../../docs/design.pdf" });
- t += 2000;
- at.add(&steps, &n, t, .{ .phase = "spin" });
- for (0..6) |_| {
- at.add(&steps, &n, t, .{ .wheel = 1 });
- t += 150;
- }
- for (0..60) |_| {
- at.add(&steps, &n, t, .{ .wheel = 1 });
- t += 8;
- }
- t += 600;
- for (0..30) |_| {
- at.add(&steps, &n, t, .{ .wheel = -1 });
- t += 8;
- }
- t += 600;
- at.add(&steps, &n, t, .{ .phase = "held-pagedown" });
- for (0..20) |_| {
- at.add(&steps, &n, t, .{ .key = .{ .cp = pardes.Key.page_down } });
- t += 33;
- }
- t += 600;
- at.add(&steps, &n, t, .{ .phase = "far-jump" });
- for ([_][]const u8{ "e", "g" }) |second| {
- at.add(&steps, &n, t, .{ .key = .{ .cp = 'g', .text = "g" } });
- at.add(&steps, &n, t + 20, .{ .key = .{ .cp = second[0], .text = second } });
- t += 800;
- }
- at.add(&steps, &n, t, .{ .exec = "Look ../../docs/design.pdf:12" });
- t += 800;
- at.add(&steps, &n, t, .{ .key = .{ .cp = 'o', .ctrl = true } });
- t += 800;
- at.add(&steps, &n, t, .{ .phase = "slow-notches" });
- for (0..8) |_| {
- at.add(&steps, &n, t, .{ .wheel = 1 });
- t += 300;
- }
- at.add(&steps, &n, t, .{ .phase = "slow-touch" });
- for (0..120) |_| {
- at.add(&steps, &n, t, .{ .touch = 0.06 });
- t += 16;
- }
- t += 600;
- at.add(&steps, &n, t, .{ .phase = "done" });
- at.add(&steps, &n, t, .end);
- const out = steps[0..n].*;
- break :blk out;
-};
-
-/// The same, on a manual of 5363 pages (the Intel SDM, combined volumes,
-/// 27 MB: run where `sdm.pdf` is, a copy): its open, a wheel spun both
-/// ways, PageDown held five seconds, a far Look to page 3000 and Back, gg,
-/// a Look at page 4500, then slow notches and a touchpad's drag.
-pub const pdf_sdm = blk: {
- @setEvalBranchQuota(40_000);
- var steps: [512]Step = undefined;
- var n: usize = 0;
- var t: u32 = 1500;
- const at = struct {
- fn add(s: []Step, k: *usize, ms: u32, act: @FieldType(Step, "act")) void {
- s[k.*] = .{ .at_ms = ms, .act = act };
- k.* += 1;
- }
- };
- at.add(&steps, &n, t, .{ .phase = "open" });
- at.add(&steps, &n, t, .{ .exec = "Look sdm.pdf" });
- t += 3000;
- at.add(&steps, &n, t, .{ .phase = "spin" });
- for (0..6) |_| {
- at.add(&steps, &n, t, .{ .wheel = 1 });
- t += 150;
- }
- for (0..60) |_| {
- at.add(&steps, &n, t, .{ .wheel = 1 });
- t += 8;
- }
- t += 600;
- for (0..30) |_| {
- at.add(&steps, &n, t, .{ .wheel = -1 });
- t += 8;
- }
- t += 600;
- at.add(&steps, &n, t, .{ .phase = "held-pagedown" });
- for (0..150) |_| {
- at.add(&steps, &n, t, .{ .key = .{ .cp = pardes.Key.page_down } });
- t += 33;
- }
- t += 800;
- at.add(&steps, &n, t, .{ .phase = "far-jump" });
- at.add(&steps, &n, t, .{ .exec = "Look sdm.pdf:3000" });
- t += 1200;
- at.add(&steps, &n, t, .{ .key = .{ .cp = 'o', .ctrl = true } });
- t += 1200;
- at.add(&steps, &n, t, .{ .key = .{ .cp = 'g', .text = "g" } });
- at.add(&steps, &n, t + 20, .{ .key = .{ .cp = 'g', .text = "g" } });
- t += 1200;
- at.add(&steps, &n, t, .{ .phase = "look-deep" });
- at.add(&steps, &n, t, .{ .exec = "Look sdm.pdf:4500" });
- t += 1500;
- at.add(&steps, &n, t, .{ .phase = "slow-notches" });
- for (0..8) |_| {
- at.add(&steps, &n, t, .{ .wheel = 1 });
- t += 300;
- }
- at.add(&steps, &n, t, .{ .phase = "slow-touch" });
- for (0..120) |_| {
- at.add(&steps, &n, t, .{ .touch = 0.06 });
- t += 16;
- }
- t += 600;
- at.add(&steps, &n, t, .{ .phase = "done" });
- at.add(&steps, &n, t, .end);
- const out = steps[0..n].*;
- break :blk out;
-};
-
-/// Keystroke-to-present, a phase a gesture, on the file the session opened:
-/// test/perf.zig's --live sends these same steps to the tty through a pty
-/// and --live-gui runs them here, so the two frontends are timed alike.
-pub const keystrokes = blk: {
- @setEvalBranchQuota(50_000);
- var steps: [1024]Step = undefined;
- var n: usize = 0;
- var t: u32 = 1500;
- const at = struct {
- fn add(s: []Step, k: *usize, ms: u32, act: @FieldType(Step, "act")) void {
- s[k.*] = .{ .at_ms = ms, .act = act };
- k.* += 1;
- }
- };
- at.add(&steps, &n, t, .{ .phase = "key-down" });
- for (0..150) |_| {
- at.add(&steps, &n, t, .{ .key = .{ .cp = 'j', .text = "j" } });
- t += 30;
- }
- at.add(&steps, &n, t, .{ .phase = "key-right" });
- for (0..150) |i| {
- at.add(&steps, &n, t, .{ .key = if (i % 2 == 0) .{ .cp = 'l', .text = "l" } else .{ .cp = 'h', .text = "h" } });
- t += 30;
- }
- at.add(&steps, &n, t, .{ .phase = "edit-char" });
- at.add(&steps, &n, t, .{ .key = .{ .cp = 'i', .text = "i" } });
- t += 30;
- for (0..150) |_| {
- at.add(&steps, &n, t, .{ .key = .{ .cp = 'x', .text = "x" } });
- t += 30;
- }
- at.add(&steps, &n, t, .{ .key = .{ .cp = pardes.Key.escape } });
- t += 300;
- at.add(&steps, &n, t, .{ .phase = "page-down" });
- for (0..60) |_| {
- at.add(&steps, &n, t, .{ .key = .{ .cp = pardes.Key.page_down } });
- t += 50;
- }
- at.add(&steps, &n, t, .{ .phase = "wheel" });
- for (0..150) |_| {
- at.add(&steps, &n, t, .{ .wheel = 1 });
- t += 30;
- }
- t += 500;
- at.add(&steps, &n, t, .{ .phase = "done" });
- at.add(&steps, &n, t, .end);
- const out = steps[0..n].*;
- break :blk out;
-};
-
-/// `scrollSet` alone, on the file the session opened: one kind, for a
-/// profiler's run.
-pub const one = blk: {
- @setEvalBranchQuota(20_000);
- var steps: [512]Step = undefined;
- var n: usize = 0;
- var t: u32 = 1500;
- steps[n] = .{ .at_ms = t, .act = .{ .phase = "one" } };
- n += 1;
- scrollSet(&steps, &n, &t);
- steps[n] = .{ .at_ms = t, .act = .end };
- n += 1;
- const out = steps[0..n].*;
- break :blk out;
-};
-
-/// The samples' scenes (docs/next-anim.md), a few seconds each, recorded
-/// with PARDES_FRAMES_CAPTURE: a wheel spun hard; Ctrl-d held then ge and
-/// gg; j held then the thin caret typing and arrowing; a `/` typed and its
-/// places stepped with Ctrl-n; a command's output then the wheel over it;
-/// Ctrl-f a page at a time.
-fn clipSteps(comptime which: usize, steps: *[256]Step) usize {
- @setEvalBranchQuota(100_000);
- var n: usize = 0;
- var t: u32 = 1200;
- const add = struct {
- fn step(s: []Step, k: *usize, at: *u32, gap: u32, act: @FieldType(Step, "act")) void {
- s[k.*] = .{ .at_ms = at.*, .act = act };
- k.* += 1;
- at.* += gap;
- }
- };
- switch (which) {
- 0 => for (0..150) |_| add.step(steps, &n, &t, 12, .{ .wheel = 1 }),
- 1 => {
- for (0..36) |_| add.step(steps, &n, &t, 33, .{ .key = .{ .cp = 'd', .ctrl = true } });
- t += 600;
- add.step(steps, &n, &t, 20, .{ .key = .{ .cp = 'g', .text = "g" } });
- add.step(steps, &n, &t, 900, .{ .key = .{ .cp = 'e', .text = "e" } });
- add.step(steps, &n, &t, 20, .{ .key = .{ .cp = 'g', .text = "g" } });
- add.step(steps, &n, &t, 900, .{ .key = .{ .cp = 'g', .text = "g" } });
- },
- 2 => {
- for (0..45) |_| add.step(steps, &n, &t, 33, .{ .key = .{ .cp = 'j', .text = "j" } });
- t += 300;
- add.step(steps, &n, &t, 300, .{ .key = .{ .cp = 'i', .text = "i" } });
- for ("the quick brown fox jumps") |ch| add.step(steps, &n, &t, 60, .{ .key = .{ .cp = ch, .text = &.{ch} } });
- for (0..10) |_| add.step(steps, &n, &t, 70, .{ .key = .{ .cp = pardes.Key.left } });
- for (0..4) |_| add.step(steps, &n, &t, 90, .{ .key = .{ .cp = pardes.Key.up } });
- add.step(steps, &n, &t, 400, .{ .key = .{ .cp = pardes.Key.escape } });
- },
- 3 => {
- for ("/pane.") |ch| add.step(steps, &n, &t, 180, .{ .key = .{ .cp = ch, .text = &.{ch} } });
- t += 300;
- for (0..8) |_| add.step(steps, &n, &t, 300, .{ .key = .{ .cp = 'n', .ctrl = true } });
- },
- 4 => {
- add.step(steps, &n, &t, 1800, .{ .exec = "cat stress.zig" });
- for (0..60) |_| add.step(steps, &n, &t, 16, .{ .wheel = -1 });
- t += 400;
- for (0..12) |_| add.step(steps, &n, &t, 150, .{ .wheel = 1 });
- },
- else => for (0..8) |_| add.step(steps, &n, &t, 450, .{ .key = .{ .cp = 'f', .ctrl = true } }),
+/// A script's key: `<c>`, `space`, `^<c>` or a pardes.Key name.
+fn keyOf(word: []const u8) ?pardes.Key {
+ if (std.mem.eql(u8, word, "space")) return .{ .cp = ' ', .text = " " };
+ if (word.len == 2 and word[0] == '^') return .{ .cp = word[1], .ctrl = true };
+ if (word.len == 1) return .{ .cp = word[0], .text = word };
+ inline for (@typeInfo(pardes.Key).@"struct".decl_names) |name| {
+ if (@TypeOf(@field(pardes.Key, name)) == u21 and std.mem.eql(u8, word, name)) return .{ .cp = @field(pardes.Key, name) };
}
- t += 800;
- add.step(steps, &n, &t, 0, .end);
- return n;
+ return null;
}
-const clip_flick = blk: {
- var steps: [256]Step = undefined;
- const n = clipSteps(0, &steps);
- const out = steps[0..n].*;
- break :blk out;
-};
-const clip_far = blk: {
- var steps: [256]Step = undefined;
- const n = clipSteps(1, &steps);
- const out = steps[0..n].*;
- break :blk out;
-};
-const clip_cursor = blk: {
- var steps: [256]Step = undefined;
- const n = clipSteps(2, &steps);
- const out = steps[0..n].*;
- break :blk out;
-};
-const clip_query = blk: {
- var steps: [256]Step = undefined;
- const n = clipSteps(3, &steps);
- const out = steps[0..n].*;
- break :blk out;
-};
-const clip_terminal = blk: {
- var steps: [256]Step = undefined;
- const n = clipSteps(4, &steps);
- const out = steps[0..n].*;
- break :blk out;
-};
-const clip_pages = blk: {
- var steps: [256]Step = undefined;
- const n = clipSteps(5, &steps);
- const out = steps[0..n].*;
- break :blk out;
-};
-
-/// The cursor along long lines (a minified JS, a one-line JSON, six 360 KB
-/// lines), Wrap on and then off (off, the view scrolls sideways): w and e
-/// held, l held, $ and 0, f and t, gl and gh, typing at a line's end and in
-/// its middle, a selection swept with held L and W.
-pub const longlines = blk: {
- @setEvalBranchQuota(1_000_000);
- var steps: [8192]Step = undefined;
- var n: usize = 0;
- var t: u32 = 1500;
- const add = struct {
- fn step(s: []Step, k: *usize, at: *u32, gap: u32, act: @FieldType(Step, "act")) void {
- s[k.*] = .{ .at_ms = at.*, .act = act };
- k.* += 1;
- at.* += gap;
- }
- fn keys(s: []Step, k: *usize, at: *u32, gap: u32, text: []const u8, times: usize) void {
- for (0..times) |_| for (text, 0..) |_, i| step(s, k, at, gap, .{ .key = .{ .cp = text[i], .text = text[i .. i + 1] } });
- }
- };
- for ([_][]const u8{ "wrap", "nowrap" }) |mode| {
- if (std.mem.eql(u8, mode, "nowrap")) add.step(&steps, &n, &t, 300, .{ .exec = "Wrap" });
- for ([_][]const u8{ "minified.js", "oneline.json", "hugelines.txt" }) |file| {
- add.step(&steps, &n, &t, 1500, .{ .exec = "Look kinds/" ++ file });
- const tag = file ++ "-" ++ mode;
- add.keys(&steps, &n, &t, 400, "gg", 1);
- add.step(&steps, &n, &t, 0, .{ .phase = "w-held-" ++ tag });
- add.keys(&steps, &n, &t, 33, "w", 60);
- add.step(&steps, &n, &t, 0, .{ .phase = "e-held-" ++ tag });
- add.keys(&steps, &n, &t, 33, "e", 60);
- add.step(&steps, &n, &t, 0, .{ .phase = "l-held-" ++ tag });
- add.keys(&steps, &n, &t, 33, "l", 90);
- add.step(&steps, &n, &t, 0, .{ .phase = "dollar-zero-" ++ tag });
- add.keys(&steps, &n, &t, 600, "$0", 2);
- add.step(&steps, &n, &t, 0, .{ .phase = "f-t-" ++ tag });
- add.keys(&steps, &n, &t, 150, "f,", 8);
- add.keys(&steps, &n, &t, 150, "t ", 8);
- add.step(&steps, &n, &t, 0, .{ .phase = "gl-gh-" ++ tag });
- add.keys(&steps, &n, &t, 500, "glgh", 3);
- add.step(&steps, &n, &t, 0, .{ .phase = "insert-end-" ++ tag });
- add.keys(&steps, &n, &t, 300, "$a", 1);
- add.keys(&steps, &n, &t, 45, "typed at the end ", 2);
- add.step(&steps, &n, &t, 300, .{ .key = .{ .cp = pardes.Key.escape } });
- add.step(&steps, &n, &t, 0, .{ .phase = "insert-middle-" ++ tag });
- add.keys(&steps, &n, &t, 40, "0", 1);
- add.keys(&steps, &n, &t, 40, "40000l", 1);
- add.keys(&steps, &n, &t, 300, "i", 1);
- add.keys(&steps, &n, &t, 45, "typed in the middle ", 2);
- add.step(&steps, &n, &t, 300, .{ .key = .{ .cp = pardes.Key.escape } });
- add.step(&steps, &n, &t, 0, .{ .phase = "sweep-L-W-" ++ tag });
- add.keys(&steps, &n, &t, 33, "L", 40);
- add.keys(&steps, &n, &t, 33, "W", 30);
- // Del twice: the second throws the typing away.
- add.step(&steps, &n, &t, 300, .{ .exec = "Del" });
- add.step(&steps, &n, &t, 600, .{ .exec = "Del" });
- }
- }
- add.step(&steps, &n, &t, 0, .end);
- const out = steps[0..n].*;
- break :blk out;
-};
-
-/// What insert mode's paste pastes: 200 lines.
-const pasted = blk: {
- const line = "a pasted line, one of two hundred\n";
- var out: [line.len * 200]u8 = undefined;
- for (0..200) |i| @memcpy(out[i * line.len ..][0..line.len], line);
- break :blk out;
-};
-
-/// Every other way a view moves, each its own phase, on the session's file
-/// (a big one) and then on a small one: the counted jumps (12G, 9000G, gg),
-/// the upward pages, a search's n/N, a query's Ctrl-n moving its owner's
-/// view, `*`, Looks at `:40`, at a far line and at another file (a new
-/// pane: nothing to glide from), the jumplist both ways, the rail's
-/// buttons and the wheel over it, and insert mode: typing, arrows, Enter at
-/// the bottom of the view, a 200-line paste.
-pub const jumps = blk: {
- @setEvalBranchQuota(400_000);
- var steps: [2048]Step = undefined;
- var n: usize = 0;
- var t: u32 = 1500;
- const add = struct {
- fn step(s: []Step, k: *usize, at: *u32, gap: u32, act: @FieldType(Step, "act")) void {
- s[k.*] = .{ .at_ms = at.*, .act = act };
- k.* += 1;
- at.* += gap;
- }
- fn text(s: []Step, k: *usize, at: *u32, gap: u32, keys: []const u8) void {
- for (keys, 0..) |_, i| step(s, k, at, gap, .{ .key = .{ .cp = keys[i], .text = keys[i .. i + 1] } });
- }
- fn key(s: []Step, k: *usize, at: *u32, gap: u32, cp: u21, ctrl: bool, times: usize) void {
- for (0..times) |_| step(s, k, at, gap, .{ .key = .{ .cp = cp, .ctrl = ctrl } });
- }
- };
- for ([_][]const u8{ "big", "small" }) |size| {
- if (std.mem.eql(u8, size, "small")) add.step(&steps, &n, &t, 1200, .{ .exec = "Look kinds/guide.typ" });
- add.step(&steps, &n, &t, 0, .{ .phase = "counted-G-" ++ size });
- for ([_][]const u8{ "12G", "300G", "9000G", "gg", "ge", "gg" }) |keys| {
- add.text(&steps, &n, &t, 20, keys);
- t += 700;
- }
- add.step(&steps, &n, &t, 0, .{ .phase = "pages-up-" ++ size });
- add.text(&steps, &n, &t, 700, "ge");
- add.key(&steps, &n, &t, 500, 'u', true, 3);
- add.key(&steps, &n, &t, 500, 'b', true, 3);
- add.key(&steps, &n, &t, 500, pardes.Key.page_up, false, 3);
- add.step(&steps, &n, &t, 0, .{ .phase = "search-n-" ++ size });
- add.text(&steps, &n, &t, 700, "gg");
- add.text(&steps, &n, &t, 120, "/const ");
- add.key(&steps, &n, &t, 600, pardes.Key.enter, false, 1);
- add.text(&steps, &n, &t, 400, "nnnnnnNNNNNN");
- add.step(&steps, &n, &t, 0, .{ .phase = "rail-" ++ size });
- add.text(&steps, &n, &t, 700, "ge");
- for ([_]pardes.Mouse.Button{ .left, .left, .right, .right, .middle }, [_]f32{ 0.8, 0.3, 0.6, 0.9, 0.5 }) |button, at|
- add.step(&steps, &n, &t, 600, .{ .click = .{ .button = button, .at = at, .rail = true } });
- for (0..8) |_| add.step(&steps, &n, &t, 120, .{ .rail_wheel = 1 });
- t += 500;
- add.step(&steps, &n, &t, 0, .{ .phase = "query-ctrl-n-" ++ size });
- add.text(&steps, &n, &t, 120, "/pub fn");
- add.key(&steps, &n, &t, 250, 'n', true, 8);
- add.key(&steps, &n, &t, 250, 'p', true, 4);
- add.key(&steps, &n, &t, 700, pardes.Key.escape, false, 1);
- add.step(&steps, &n, &t, 0, .{ .phase = "star-" ++ size });
- add.text(&steps, &n, &t, 300, "ggww*");
- add.text(&steps, &n, &t, 500, "nnnn");
- add.step(&steps, &n, &t, 0, .{ .phase = "look-" ++ size });
- add.step(&steps, &n, &t, 900, .{ .exec = "Look :40" });
- add.step(&steps, &n, &t, 900, .{ .exec = "Look :7000" });
- add.step(&steps, &n, &t, 900, .{ .exec = "Look :200" });
- add.step(&steps, &n, &t, 0, .{ .phase = "jumplist-" ++ size });
- add.key(&steps, &n, &t, 600, 'o', true, 3);
- add.key(&steps, &n, &t, 600, 'i', true, 3);
- add.text(&steps, &n, &t, 40, " jo");
- t += 600;
- add.text(&steps, &n, &t, 40, " ji");
- t += 600;
- add.step(&steps, &n, &t, 0, .{ .phase = "insert-" ++ size });
- add.text(&steps, &n, &t, 300, "ggi");
- for (0..4) |_| add.text(&steps, &n, &t, 45, "the quick brown fox ");
- add.key(&steps, &n, &t, 60, pardes.Key.left, false, 12);
- add.key(&steps, &n, &t, 60, pardes.Key.right, false, 12);
- add.key(&steps, &n, &t, 60, pardes.Key.down, false, 6);
- // Enter after Enter until the view has to follow, a line at a time.
- add.key(&steps, &n, &t, 70, pardes.Key.enter, false, 60);
- add.step(&steps, &n, &t, 600, .{ .paste = &pasted });
- add.key(&steps, &n, &t, 700, pardes.Key.escape, false, 1);
+/// `text` with `\n` a newline and `\\` a backslash.
+fn unescaped(arena: std.mem.Allocator, text: []const u8) error{OutOfMemory}![]const u8 {
+ if (std.mem.indexOfScalar(u8, text, '\\') == null) return text;
+ var out: std.ArrayList(u8) = .empty;
+ var i: usize = 0;
+ while (i < text.len) : (i += 1) {
+ if (text[i] == '\\' and i + 1 < text.len) {
+ i += 1;
+ try out.append(arena, if (text[i] == 'n') '\n' else text[i]);
+ } else try out.append(arena, text[i]);
}
- add.step(&steps, &n, &t, 0, .{ .phase = "look-new-pane" });
- add.step(&steps, &n, &t, 1500, .{ .exec = "Look ../../src/layout.zig:9000" });
- add.step(&steps, &n, &t, 0, .end);
- const out = steps[0..n].*;
- break :blk out;
-};
-
-/// Each file of the corpus (`.scratch/tools/corpus.sh`) is opened by name,
-/// relative to the first file's directory, and put through `scrollSet`;
-/// the long-line ones a second time with Wrap off.
-pub const kinds = blk: {
- @setEvalBranchQuota(200_000);
- var steps: [4096]Step = undefined;
- var n: usize = 0;
- var t: u32 = 1500;
- const files = [_][]const u8{ "generated-parser.c", "commands.rs", "tables.py", "jquery.js", "minified.js", "grammar.json", "oneline.json", "CHANGELOG.md", "cascade.html", "simdutf.cpp", "parser.ts", "fcnal-test.sh", "data.go", "guide.typ", "unicode.txt", "big.log", "words.txt", "hugelines.txt" };
- for (files ++ [_][]const u8{ "minified.js!", "oneline.json!", "hugelines.txt!" }) |file| {
- const unwrapped = file[file.len - 1] == '!';
- const name = if (unwrapped) file[0 .. file.len - 1] else file;
- // Wrap goes off once, before the second round.
- if (unwrapped and std.mem.eql(u8, name, "minified.js")) {
- steps[n] = .{ .at_ms = t, .act = .{ .exec = "Wrap" } };
- n += 1;
- t += 200;
- }
- steps[n] = .{ .at_ms = t, .act = .{ .exec = "Look kinds/" ++ name } };
- n += 1;
- t += 1200;
- steps[n] = .{ .at_ms = t, .act = .{ .phase = file } };
- n += 1;
- scrollSet(&steps, &n, &t);
- steps[n] = .{ .at_ms = t, .act = .{ .exec = "Del" } };
- n += 1;
- t += 400;
- }
- steps[n] = .{ .at_ms = t, .act = .end };
- n += 1;
- const out = steps[0..n].*;
- break :blk out;
-};
-
-/// The other kinds of pane, opened from the first file's directory, each
-/// put through `scrollSet`: a command's fast output (the stress file, then
-/// `yes`), a +Pager, a directory, a PDF, a picture, Help's output pane, a
-/// +Diff, and the query pane typed into (its rows refilled each key, its
-/// owner's places drawn).
-pub const panes = blk: {
- @setEvalBranchQuota(200_000);
- var steps: [4096]Step = undefined;
- var n: usize = 0;
- var t: u32 = 1500;
- const Kind = struct { name: []const u8, open: []const u8, settle: u32 };
- for ([_]Kind{
- .{ .name = "command-cat", .open = "cat stress.zig", .settle = 300 },
- .{ .name = "command-yes", .open = "yes | head -200000", .settle = 300 },
- .{ .name = "pager", .open = "cat stress.zig | pardes -", .settle = 2500 },
- .{ .name = "directory", .open = "Look kinds/", .settle = 1200 },
- .{ .name = "pdf", .open = "Look ../../docs/design.pdf", .settle = 2000 },
- .{ .name = "image", .open = "Look ../../docs/screenshots/atelier.png", .settle = 1200 },
- .{ .name = "help", .open = "Help", .settle = 1200 },
- .{ .name = "changelog", .open = "Changelog", .settle = 1200 },
- }) |kind| {
- steps[n] = .{ .at_ms = t, .act = .{ .phase = kind.name } };
- n += 1;
- steps[n] = .{ .at_ms = t, .act = .{ .exec = kind.open } };
- n += 1;
- // A command's output streams in while it is scrolled.
- t += kind.settle;
- scrollSet(&steps, &n, &t);
- steps[n] = .{ .at_ms = t, .act = .{ .exec = "Del" } };
- n += 1;
- t += 600;
- }
- steps[n] = .{ .at_ms = t, .act = .{ .phase = "query-typing" } };
- n += 1;
- steps[n] = .{ .at_ms = t, .act = .{ .key = .{ .cp = '/', .text = "/" } } };
- n += 1;
- t += 300;
- for ("pane.vie") |ch| {
- steps[n] = .{ .at_ms = t, .act = .{ .key = .{ .cp = ch, .text = &.{ch} } } };
- n += 1;
- t += 150;
- }
- for (0..12) |_| {
- steps[n] = .{ .at_ms = t, .act = .{ .key = .{ .cp = 'n', .ctrl = true } } };
- n += 1;
- t += 120;
- }
- steps[n] = .{ .at_ms = t, .act = .{ .key = .{ .cp = pardes.Key.escape } } };
- n += 1;
- t += 800;
- steps[n] = .{ .at_ms = t, .act = .end };
- n += 1;
- const out = steps[0..n].*;
- break :blk out;
-};
+ return out.items;
+}
-/// Throughput on a big file (layout.zig x23, 30k lines): each input held
-/// for three seconds at a keyboard's repeat (33 ms) or a wheel spun hard (a
-/// notch every 8 ms), so the picture has to keep up with more than it can
-/// show: a spin, held Ctrl-d, held j, held PageDown, then the far jumps.
-pub const stress = blk: {
- @setEvalBranchQuota(100_000);
- var steps: [1024]Step = undefined;
- var n: usize = 0;
- var t: u32 = 1500;
- const Held = struct { name: []const u8, key: ?pardes.Key, every: u32 };
- for ([_]Held{
- .{ .name = "spin", .key = null, .every = 8 },
- .{ .name = "held-ctrl-d", .key = .{ .cp = 'd', .ctrl = true }, .every = 33 },
- .{ .name = "held-j", .key = .{ .cp = 'j', .text = "j" }, .every = 33 },
- .{ .name = "held-pagedown", .key = .{ .cp = pardes.Key.page_down }, .every = 33 },
- }) |held| {
- // Each from the top.
- for ([_]u32{ 0, 20 }) |dt| {
- steps[n] = .{ .at_ms = t + dt, .act = .{ .key = .{ .cp = 'g', .text = "g" } } };
- n += 1;
- }
- t += 800;
- steps[n] = .{ .at_ms = t, .act = .{ .phase = held.name } };
- n += 1;
- const end = t + 3000;
- while (t < end) : (t += held.every) {
- steps[n] = .{ .at_ms = t, .act = if (held.key) |key| .{ .key = key } else .{ .wheel = 1 } };
- n += 1;
- }
- t += 1000;
- }
- steps[n] = .{ .at_ms = t, .act = .{ .phase = "far" } };
- n += 1;
- for (0..3) |_| {
- for ([_][]const u8{ "e", "g" }) |second| {
- for ([_][]const u8{ "g", second }, 0..) |text, i| {
- steps[n] = .{ .at_ms = t + 20 * @as(u32, i), .act = .{ .key = .{ .cp = text[0], .text = text } } };
- n += 1;
- }
- t += 700;
- }
- }
- steps[n] = .{ .at_ms = t + 500, .act = .end };
- n += 1;
- const out = steps[0..n].*;
- break :blk out;
-};
+/// The script at `path` (PARDES_FRAMES_DEMO), read and parsed into `arena`.
+pub fn readScript(arena: std.mem.Allocator, io: std.Io, path: []const u8) ![]Step {
+ return parseScript(arena, try std.Io.Dir.cwd().readFileAlloc(io, path, arena, .limited(1 << 22)));
+}
test "frame stats: gaps into a motion count as jank, idle gaps do not, and the ring keeps the last frames" {
var stats: FrameStats = .{ .period_ns = 16 * std.time.ns_per_ms };
@@ -1085,11 +451,6 @@ test "frame stats: gaps into a motion count as jank, idle gaps do not, and the r
try std.testing.expectEqual(@as(usize, 10), tail[0].len + tail[1].len);
const newest = if (tail[1].len != 0) tail[1][tail[1].len - 1] else tail[0][tail[0].len - 1];
try std.testing.expectEqual(@as(f32, capacity + 4), newest.scroll);
- // Each timedemo ends, and its steps are in time order.
- for ([_][]const Step{ &demo, &stress, &kinds, &panes, &one, &jumps, &longlines }) |steps| {
- try std.testing.expect(steps[steps.len - 1].act == .end);
- for (steps[1..], steps[0 .. steps.len - 1]) |b, a| try std.testing.expect(b.at_ms >= a.at_ms);
- }
// An input is answered by the next drawn frame, and only by it.
stats.input(t - 2 * ms);
stats.mark_start = t;
@@ -1100,3 +461,28 @@ test "frame stats: gaps into a motion count as jank, idle gaps do not, and the r
stats.record(t + 4 * ms, false, false);
try std.testing.expectEqual(@as(u32, 0), stats.last(1)[0][0].latency_us);
}
+
+test "every script in tools/demos reads, its steps in time order, and ends the run" {
+ const io = std.testing.io;
+ var arena: std.heap.ArenaAllocator = .init(std.testing.allocator);
+ defer arena.deinit();
+ var dir = try std.Io.Dir.cwd().openDir(io, "tools/demos", .{ .iterate = true });
+ defer dir.close(io);
+ var it = dir.iterate();
+ var scripts: usize = 0;
+ while (try it.next(io)) |entry| {
+ const steps = try parseScript(arena.allocator(), try dir.readFileAlloc(io, entry.name, arena.allocator(), .limited(1 << 22)));
+ try std.testing.expect(steps[steps.len - 1].act == .end);
+ for (steps[1..], steps[0 .. steps.len - 1]) |b, a| try std.testing.expect(b.at_ms >= a.at_ms);
+ scripts += 1;
+ }
+ try std.testing.expect(scripts > 0);
+ // A line it cannot read is refused, not skipped.
+ try std.testing.expectError(error.BadScript, parseScript(arena.allocator(), "100 key\n200 end\n"));
+ try std.testing.expectError(error.BadScript, parseScript(arena.allocator(), "# nothing\n"));
+ const typed = try parseScript(arena.allocator(), "10 2x5 keys a ^n\n30 paste x\\ny\n");
+ try std.testing.expectEqual(@as(usize, 5), typed.len);
+ try std.testing.expectEqual(@as(u32, 25), typed[3].at_ms);
+ try std.testing.expect(typed[3].act.key.ctrl and typed[3].act.key.cp == 'n');
+ try std.testing.expectEqualStrings("x\ny", typed[4].act.paste);
+}
diff --git a/src/gui/gui.zig b/src/gui/gui.zig
index 21d448bd..a7095f6e 100644
--- a/src/gui/gui.zig
+++ b/src/gui/gui.zig
@@ -1482,10 +1482,9 @@ const Gui = struct {
/// owns the wheel (terminal.ownsWheel).
program_wheel: f32 = 0,
glide: Glide = .{},
- /// PARDES_FRAMES_DEMO: the timedemo (FrameStats.named), its next step
+ /// PARDES_FRAMES_DEMO: the timedemo (its script's steps), its next step
/// and when it started; null when none runs.
demo: []const pardes.FrameStats.Step = &.{},
- demo_name: []const u8 = "",
demo_next: ?usize = null,
demo_start_ns: u64 = 0,
/// The tick the last paced frame was sampled at (waitInput), and
@@ -2254,9 +2253,8 @@ fn runNative(init: std.process.Init, opts_in: pardes.Options, headless: bool, di
.capture_series = test_mode and env.get("PARDES_TEST_SERIES") != null,
.capture_dir = capture_dir orelse "",
.soft_present = soft_present,
- .demo = if (env.get("PARDES_FRAMES_DEMO")) |name| pardes.FrameStats.named(name) orelse &.{} else &.{},
- .demo_name = env.get("PARDES_FRAMES_DEMO") orelse "",
- .demo_next = if (env.get("PARDES_FRAMES_DEMO")) |name| (if (pardes.FrameStats.named(name) != null) @as(?usize, 0) else null) else null,
+ .demo = if (env.get("PARDES_FRAMES_DEMO")) |path| try pardes.FrameStats.readScript(init.arena.allocator(), init.io, path) else &.{},
+ .demo_next = if (env.get("PARDES_FRAMES_DEMO") != null) 0 else null,
.surface_opacity = surface_opacity,
.soft_renderer = soft_renderer,
.win_flags = reopen_flags,
@@ -5084,7 +5082,7 @@ fn runDemo(g: *Gui, in: *Input, core: *pardes.Pardes) void {
if (g.demo_start_ns == 0) {
g.demo_start_ns = now;
core.frames.demo_ns = now;
- core.frames.demo_name = g.demo_name;
+ core.frames.demo = g.demo;
}
defer g.demo_next = next;
while (next < steps.len and g.demo_start_ns + @as(u64, steps[next].at_ms) * std.time.ns_per_ms <= now) : (next += 1) {
diff --git a/test/perf.zig b/test/perf.zig
index 31a813cb..274e793f 100644
--- a/test/perf.zig
+++ b/test/perf.zig
@@ -1188,7 +1188,28 @@ fn liveSweep(io: std.Io) void {
}
}
-/// The bytes a terminal sends for a step of FrameStats.keys.
+/// Keystroke-to-present, a phase a gesture (FrameStats.parseScript's
+/// script): --live sends its steps to the tty through a pty, and
+/// --live-gui has the window run it (PARDES_FRAMES_DEMO), so the two
+/// frontends are timed alike.
+const keys_script =
+ \\1500 phase key-down
+ \\1500 150x30 key j
+ \\6000 phase key-right
+ \\6000 75x30 keys l h
+ \\10500 phase edit-char
+ \\10500 key i
+ \\10530 150x30 key x
+ \\15030 key escape
+ \\15330 phase page-down
+ \\15330 60x50 key page_down
+ \\18330 phase wheel
+ \\18330 150x30 wheel 1
+ \\23330 phase done
+ \\23330 end
+;
+
+/// The bytes a terminal sends for a step of `keys_script`.
fn stepBytes(buf: *[32]u8, step: pardes.FrameStats.Step) []const u8 {
return switch (step.act) {
.key => |k| switch (k.cp) {
@@ -1298,7 +1319,7 @@ fn liveKeysTty(l: *Live, exe: [:0]const u8) !void {
var starts: [live_phases.len + 1]u64 = @splat(std.math.maxInt(u64));
const t0 = nowNs();
var buf: [32]u8 = undefined;
- for (pardes.FrameStats.named("keys").?) |step| {
+ for (try pardes.FrameStats.parseScript(gpa, keys_script)) |step| {
const due = t0 + @as(u64, step.at_ms) * std.time.ns_per_ms;
while (nowNs() < due) _ = try h.pumpOnce(@intCast(@max(1, (due -| nowNs()) / std.time.ns_per_ms)));
switch (step.act) {
@@ -1348,7 +1369,8 @@ fn liveOpen(l: *Live, exe: [:0]const u8) !void {
fn liveKeysGui(l: *Live, exe: [:0]const u8) !void {
const dump_path = try l.path("gui-frames.tsv");
_ = setenv("PARDES_FRAMES", dump_path, 1);
- _ = setenv("PARDES_FRAMES_DEMO", "keys", 1);
+ try writeFile(try l.path("keys.txt"), keys_script);
+ _ = setenv("PARDES_FRAMES_DEMO", try l.path("keys.txt"), 1);
_ = setenv("PARDES_TEST", "1", 1);
_ = setenv("PARDES_TEST_CAPTURE_DIR", try std.fmt.allocPrintSentinel(gpa, "{s}", .{l.dir}, 0), 1);
_ = setenv("PARDES_TEST_COLS", try std.fmt.allocPrintSentinel(gpa, "{d}", .{screen_cols}, 0), 1);
diff --git a/tools/demos/clip-cursor.txt b/tools/demos/clip-cursor.txt
new file mode 100644
index 00000000..6053b14f
--- /dev/null
+++ b/tools/demos/clip-cursor.txt
@@ -0,0 +1,9 @@
+# clip-cursor: a sample's scene: j held, then the thin caret typing and
+# arrowing.
+1200 45x33 key j
+2985 1x300 keys i t
+3345 1x60 keys h e space q u i c k space b r o w n space f o x space j u m p s left
+4855 9x70 key left
+5485 key up
+5575 1x90 keys up up up escape
+7045 end
diff --git a/tools/demos/clip-far.txt b/tools/demos/clip-far.txt
new file mode 100644
index 00000000..c3cb5532
--- /dev/null
+++ b/tools/demos/clip-far.txt
@@ -0,0 +1,5 @@
+# clip-far: a sample's scene: Ctrl-d held, then ge and gg.
+1200 36x33 key ^d
+2988 1x20 keys g e
+3908 2x20 key g
+5628 end
diff --git a/tools/demos/clip-flick.txt b/tools/demos/clip-flick.txt
new file mode 100644
index 00000000..1a1a6ed4
--- /dev/null
+++ b/tools/demos/clip-flick.txt
@@ -0,0 +1,4 @@
+# clip-flick: a sample's scene (docs/next-anim.md, recorded with
+# PARDES_FRAMES_CAPTURE): a wheel spun hard.
+1200 150x12 wheel 1
+3800 end
diff --git a/tools/demos/clip-pages.txt b/tools/demos/clip-pages.txt
new file mode 100644
index 00000000..b46cc4f5
--- /dev/null
+++ b/tools/demos/clip-pages.txt
@@ -0,0 +1,3 @@
+# clip-pages: a sample's scene: Ctrl-f a page at a time.
+1200 8x450 key ^f
+5600 end
diff --git a/tools/demos/clip-query.txt b/tools/demos/clip-query.txt
new file mode 100644
index 00000000..47781f9b
--- /dev/null
+++ b/tools/demos/clip-query.txt
@@ -0,0 +1,5 @@
+# clip-query: a sample's scene: a / typed and its places stepped with
+# Ctrl-n.
+1200 1x180 keys / p a n e .
+2580 8x300 key ^n
+5780 end
diff --git a/tools/demos/clip-terminal.txt b/tools/demos/clip-terminal.txt
new file mode 100644
index 00000000..d6124f85
--- /dev/null
+++ b/tools/demos/clip-terminal.txt
@@ -0,0 +1,6 @@
+# clip-terminal: a sample's scene: a command's output, then the wheel over
+# it.
+1200 exec cat stress.zig
+3000 60x16 wheel -1
+4360 12x150 wheel 1
+6960 end
diff --git a/tools/demos/jumps.txt b/tools/demos/jumps.txt
new file mode 100644
index 00000000..97189105
--- /dev/null
+++ b/tools/demos/jumps.txt
@@ -0,0 +1,101 @@
+# jumps: every other way a view moves, each its own phase, on the session's
+# file (a big one) and then on a small one: the counted jumps (12G, 9000G,
+# gg), the upward pages, a search's n/N, a query's Ctrl-n moving its owner's
+# view, *, Looks at :40, at a far line and at another file (a new pane:
+# nothing to glide from), the jumplist both ways, the rail's buttons and the
+# wheel over it, and insert mode: typing, arrows, Enter at the bottom of the
+# view, a 200-line paste.
+1500 phase counted-G-big
+1500 1x20 keys 1 2 G
+2260 1x20 keys 3 0 0 G
+3040 1x20 keys 9 0 0 0 G
+3840 2x20 key g
+4580 1x20 keys g e
+5320 2x20 key g
+6060 phase pages-up-big
+6060 1x700 keys g e ^u
+7960 1x500 keys ^u ^u ^b ^b ^b page_up page_up page_up
+11960 phase search-n-big
+11960 1x700 keys g g /
+13480 1x120 keys c o n s t space enter
+14800 1x400 keys n n n n n n N N N N N N
+19600 phase rail-big
+19600 1x700 keys g e
+21000 click left 0.8 rail
+21600 click left 0.3 rail
+22200 click right 0.6 rail
+22800 click right 0.9 rail
+23400 click middle 0.5 rail
+24000 8x120 rail_wheel 1
+25460 phase query-ctrl-n-big
+25460 1x120 keys / p u b space f n ^n
+26550 1x250 keys ^n ^n ^n ^n ^n ^n ^n ^p ^p ^p ^p escape
+30000 phase star-big
+30000 1x300 keys g g w w * n
+32000 3x500 key n
+33500 phase look-big
+33500 exec Look :40
+34400 exec Look :7000
+35300 exec Look :200
+36200 phase jumplist-big
+36200 1x600 keys ^o ^o ^o ^i ^i ^i space
+39840 1x40 keys j o
+40520 1x40 keys space j i
+41240 phase insert-big
+41240 1x300 keys g g i t
+42185 1x45 keys h e space q u i c k space b r o w n space f o x space t h e space q u i c k space b r o w n space f o x space t h e space q u i c k space b r o w n space f o x space t h e space q u i c k space b r o w n space f o x space left
+45800 11x60 key left
+46460 12x60 key right
+47180 1x60 keys down down down down down down enter
+47610 59x70 key enter
+51740 paste a pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\n
+52340 key escape
+53040 exec Look kinds/guide.typ
+54240 phase counted-G-small
+54240 1x20 keys 1 2 G
+55000 1x20 keys 3 0 0 G
+55780 1x20 keys 9 0 0 0 G
+56580 2x20 key g
+57320 1x20 keys g e
+58060 2x20 key g
+58800 phase pages-up-small
+58800 1x700 keys g e ^u
+60700 1x500 keys ^u ^u ^b ^b ^b page_up page_up page_up
+64700 phase search-n-small
+64700 1x700 keys g g /
+66220 1x120 keys c o n s t space enter
+67540 1x400 keys n n n n n n N N N N N N
+72340 phase rail-small
+72340 1x700 keys g e
+73740 click left 0.8 rail
+74340 click left 0.3 rail
+74940 click right 0.6 rail
+75540 click right 0.9 rail
+76140 click middle 0.5 rail
+76740 8x120 rail_wheel 1
+78200 phase query-ctrl-n-small
+78200 1x120 keys / p u b space f n ^n
+79290 1x250 keys ^n ^n ^n ^n ^n ^n ^n ^p ^p ^p ^p escape
+82740 phase star-small
+82740 1x300 keys g g w w * n
+84740 3x500 key n
+86240 phase look-small
+86240 exec Look :40
+87140 exec Look :7000
+88040 exec Look :200
+88940 phase jumplist-small
+88940 1x600 keys ^o ^o ^o ^i ^i ^i space
+92580 1x40 keys j o
+93260 1x40 keys space j i
+93980 phase insert-small
+93980 1x300 keys g g i t
+94925 1x45 keys h e space q u i c k space b r o w n space f o x space t h e space q u i c k space b r o w n space f o x space t h e space q u i c k space b r o w n space f o x space t h e space q u i c k space b r o w n space f o x space left
+98540 11x60 key left
+99200 12x60 key right
+99920 1x60 keys down down down down down down enter
+100350 59x70 key enter
+104480 paste a pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\na pasted line, one of two hundred\n
+105080 key escape
+105780 phase look-new-pane
+105780 exec Look ../../src/layout.zig:9000
+107280 end
diff --git a/tools/demos/kinds.txt b/tools/demos/kinds.txt
new file mode 100644
index 00000000..f97e5707
--- /dev/null
+++ b/tools/demos/kinds.txt
@@ -0,0 +1,216 @@
+# kinds: each file of the corpus (.scratch/tools/corpus.sh) opened by name,
+# relative to the first file's directory, and put through the scroll set
+# (notches, a spin, half pages, PageDown held, the far jumps, the cursor
+# down a held j); the long-line ones a second time with Wrap off.
+1500 exec Look kinds/generated-parser.c
+2700 phase generated-parser.c
+2700 7x150 wheel 1
+3608 99x8 wheel 1
+4900 1x400 keys ^d ^d ^d page_down
+6133 44x33 key page_down
+7985 1x20 keys g e
+8585 2x20 key g
+9185 30x33 key j
+10675 exec Del
+11075 exec Look kinds/commands.rs
+12275 phase commands.rs
+12275 7x150 wheel 1
+13183 99x8 wheel 1
+14475 1x400 keys ^d ^d ^d page_down
+15708 44x33 key page_down
+17560 1x20 keys g e
+18160 2x20 key g
+18760 30x33 key j
+20250 exec Del
+20650 exec Look kinds/tables.py
+21850 phase tables.py
+21850 7x150 wheel 1
+22758 99x8 wheel 1
+24050 1x400 keys ^d ^d ^d page_down
+25283 44x33 key page_down
+27135 1x20 keys g e
+27735 2x20 key g
+28335 30x33 key j
+29825 exec Del
+30225 exec Look kinds/jquery.js
+31425 phase jquery.js
+31425 7x150 wheel 1
+32333 99x8 wheel 1
+33625 1x400 keys ^d ^d ^d page_down
+34858 44x33 key page_down
+36710 1x20 keys g e
+37310 2x20 key g
+37910 30x33 key j
+39400 exec Del
+39800 exec Look kinds/minified.js
+41000 phase minified.js
+41000 7x150 wheel 1
+41908 99x8 wheel 1
+43200 1x400 keys ^d ^d ^d page_down
+44433 44x33 key page_down
+46285 1x20 keys g e
+46885 2x20 key g
+47485 30x33 key j
+48975 exec Del
+49375 exec Look kinds/grammar.json
+50575 phase grammar.json
+50575 7x150 wheel 1
+51483 99x8 wheel 1
+52775 1x400 keys ^d ^d ^d page_down
+54008 44x33 key page_down
+55860 1x20 keys g e
+56460 2x20 key g
+57060 30x33 key j
+58550 exec Del
+58950 exec Look kinds/oneline.json
+60150 phase oneline.json
+60150 7x150 wheel 1
+61058 99x8 wheel 1
+62350 1x400 keys ^d ^d ^d page_down
+63583 44x33 key page_down
+65435 1x20 keys g e
+66035 2x20 key g
+66635 30x33 key j
+68125 exec Del
+68525 exec Look kinds/CHANGELOG.md
+69725 phase CHANGELOG.md
+69725 7x150 wheel 1
+70633 99x8 wheel 1
+71925 1x400 keys ^d ^d ^d page_down
+73158 44x33 key page_down
+75010 1x20 keys g e
+75610 2x20 key g
+76210 30x33 key j
+77700 exec Del
+78100 exec Look kinds/cascade.html
+79300 phase cascade.html
+79300 7x150 wheel 1
+80208 99x8 wheel 1
+81500 1x400 keys ^d ^d ^d page_down
+82733 44x33 key page_down
+84585 1x20 keys g e
+85185 2x20 key g
+85785 30x33 key j
+87275 exec Del
+87675 exec Look kinds/simdutf.cpp
+88875 phase simdutf.cpp
+88875 7x150 wheel 1
+89783 99x8 wheel 1
+91075 1x400 keys ^d ^d ^d page_down
+92308 44x33 key page_down
+94160 1x20 keys g e
+94760 2x20 key g
+95360 30x33 key j
+96850 exec Del
+97250 exec Look kinds/parser.ts
+98450 phase parser.ts
+98450 7x150 wheel 1
+99358 99x8 wheel 1
+100650 1x400 keys ^d ^d ^d page_down
+101883 44x33 key page_down
+103735 1x20 keys g e
+104335 2x20 key g
+104935 30x33 key j
+106425 exec Del
+106825 exec Look kinds/fcnal-test.sh
+108025 phase fcnal-test.sh
+108025 7x150 wheel 1
+108933 99x8 wheel 1
+110225 1x400 keys ^d ^d ^d page_down
+111458 44x33 key page_down
+113310 1x20 keys g e
+113910 2x20 key g
+114510 30x33 key j
+116000 exec Del
+116400 exec Look kinds/data.go
+117600 phase data.go
+117600 7x150 wheel 1
+118508 99x8 wheel 1
+119800 1x400 keys ^d ^d ^d page_down
+121033 44x33 key page_down
+122885 1x20 keys g e
+123485 2x20 key g
+124085 30x33 key j
+125575 exec Del
+125975 exec Look kinds/guide.typ
+127175 phase guide.typ
+127175 7x150 wheel 1
+128083 99x8 wheel 1
+129375 1x400 keys ^d ^d ^d page_down
+130608 44x33 key page_down
+132460 1x20 keys g e
+133060 2x20 key g
+133660 30x33 key j
+135150 exec Del
+135550 exec Look kinds/unicode.txt
+136750 phase unicode.txt
+136750 7x150 wheel 1
+137658 99x8 wheel 1
+138950 1x400 keys ^d ^d ^d page_down
+140183 44x33 key page_down
+142035 1x20 keys g e
+142635 2x20 key g
+143235 30x33 key j
+144725 exec Del
+145125 exec Look kinds/big.log
+146325 phase big.log
+146325 7x150 wheel 1
+147233 99x8 wheel 1
+148525 1x400 keys ^d ^d ^d page_down
+149758 44x33 key page_down
+151610 1x20 keys g e
+152210 2x20 key g
+152810 30x33 key j
+154300 exec Del
+154700 exec Look kinds/words.txt
+155900 phase words.txt
+155900 7x150 wheel 1
+156808 99x8 wheel 1
+158100 1x400 keys ^d ^d ^d page_down
+159333 44x33 key page_down
+161185 1x20 keys g e
+161785 2x20 key g
+162385 30x33 key j
+163875 exec Del
+164275 exec Look kinds/hugelines.txt
+165475 phase hugelines.txt
+165475 7x150 wheel 1
+166383 99x8 wheel 1
+167675 1x400 keys ^d ^d ^d page_down
+168908 44x33 key page_down
+170760 1x20 keys g e
+171360 2x20 key g
+171960 30x33 key j
+173450 exec Del
+173850 exec Wrap
+174050 exec Look kinds/minified.js
+175250 phase minified.js!
+175250 7x150 wheel 1
+176158 99x8 wheel 1
+177450 1x400 keys ^d ^d ^d page_down
+178683 44x33 key page_down
+180535 1x20 keys g e
+181135 2x20 key g
+181735 30x33 key j
+183225 exec Del
+183625 exec Look kinds/oneline.json
+184825 phase oneline.json!
+184825 7x150 wheel 1
+185733 99x8 wheel 1
+187025 1x400 keys ^d ^d ^d page_down
+188258 44x33 key page_down
+190110 1x20 keys g e
+190710 2x20 key g
+191310 30x33 key j
+192800 exec Del
+193200 exec Look kinds/hugelines.txt
+194400 phase hugelines.txt!
+194400 7x150 wheel 1
+195308 99x8 wheel 1
+196600 1x400 keys ^d ^d ^d page_down
+197833 44x33 key page_down
+199685 1x20 keys g e
+200285 2x20 key g
+200885 30x33 key j
+202375 exec Del
+202775 end
diff --git a/tools/demos/longlines.txt b/tools/demos/longlines.txt
new file mode 100644
index 00000000..b56164d6
--- /dev/null
+++ b/tools/demos/longlines.txt
@@ -0,0 +1,150 @@
+# longlines: the cursor along long lines (a minified JS, a one-line JSON,
+# six 360 KB lines), Wrap on and then off (off, the view scrolls sideways):
+# w and e held, l held, $ and 0, f and t, gl and gh, typing at a line's end
+# and in its middle, a selection swept with held L and W.
+1500 exec Look kinds/minified.js
+3000 2x400 key g
+3800 phase w-held-minified.js-wrap
+3800 60x33 key w
+5780 phase e-held-minified.js-wrap
+5780 60x33 key e
+7760 phase l-held-minified.js-wrap
+7760 90x33 key l
+10730 phase dollar-zero-minified.js-wrap
+10730 2x600 keys $ 0
+13130 phase f-t-minified.js-wrap
+13130 1x150 keys f , f , f , f , f , f , f , f , t space t space t space t space t space t space t space t space
+17930 phase gl-gh-minified.js-wrap
+17930 3x500 keys g l g h
+23930 phase insert-end-minified.js-wrap
+23930 1x300 keys $ a t
+24575 1x45 keys y p e d space a t space t h e space e n d space t y p e d space a t space t h e space e n d space escape
+26360 phase insert-middle-minified.js-wrap
+26360 1x40 keys 0 4 0 0 0 0 l i
+26940 1x45 keys t y p e d space i n space t h e space m i d d l e space t y p e d space i n space t h e space m i d d l e space escape
+29040 phase sweep-L-W-minified.js-wrap
+29040 40x33 key L
+30360 30x33 key W
+31350 2x300 exec Del
+32250 exec Look kinds/oneline.json
+33750 2x400 key g
+34550 phase w-held-oneline.json-wrap
+34550 60x33 key w
+36530 phase e-held-oneline.json-wrap
+36530 60x33 key e
+38510 phase l-held-oneline.json-wrap
+38510 90x33 key l
+41480 phase dollar-zero-oneline.json-wrap
+41480 2x600 keys $ 0
+43880 phase f-t-oneline.json-wrap
+43880 1x150 keys f , f , f , f , f , f , f , f , t space t space t space t space t space t space t space t space
+48680 phase gl-gh-oneline.json-wrap
+48680 3x500 keys g l g h
+54680 phase insert-end-oneline.json-wrap
+54680 1x300 keys $ a t
+55325 1x45 keys y p e d space a t space t h e space e n d space t y p e d space a t space t h e space e n d space escape
+57110 phase insert-middle-oneline.json-wrap
+57110 1x40 keys 0 4 0 0 0 0 l i
+57690 1x45 keys t y p e d space i n space t h e space m i d d l e space t y p e d space i n space t h e space m i d d l e space escape
+59790 phase sweep-L-W-oneline.json-wrap
+59790 40x33 key L
+61110 30x33 key W
+62100 2x300 exec Del
+63000 exec Look kinds/hugelines.txt
+64500 2x400 key g
+65300 phase w-held-hugelines.txt-wrap
+65300 60x33 key w
+67280 phase e-held-hugelines.txt-wrap
+67280 60x33 key e
+69260 phase l-held-hugelines.txt-wrap
+69260 90x33 key l
+72230 phase dollar-zero-hugelines.txt-wrap
+72230 2x600 keys $ 0
+74630 phase f-t-hugelines.txt-wrap
+74630 1x150 keys f , f , f , f , f , f , f , f , t space t space t space t space t space t space t space t space
+79430 phase gl-gh-hugelines.txt-wrap
+79430 3x500 keys g l g h
+85430 phase insert-end-hugelines.txt-wrap
+85430 1x300 keys $ a t
+86075 1x45 keys y p e d space a t space t h e space e n d space t y p e d space a t space t h e space e n d space escape
+87860 phase insert-middle-hugelines.txt-wrap
+87860 1x40 keys 0 4 0 0 0 0 l i
+88440 1x45 keys t y p e d space i n space t h e space m i d d l e space t y p e d space i n space t h e space m i d d l e space escape
+90540 phase sweep-L-W-hugelines.txt-wrap
+90540 40x33 key L
+91860 30x33 key W
+92850 2x300 exec Del
+93750 exec Wrap
+94050 exec Look kinds/minified.js
+95550 2x400 key g
+96350 phase w-held-minified.js-nowrap
+96350 60x33 key w
+98330 phase e-held-minified.js-nowrap
+98330 60x33 key e
+100310 phase l-held-minified.js-nowrap
+100310 90x33 key l
+103280 phase dollar-zero-minified.js-nowrap
+103280 2x600 keys $ 0
+105680 phase f-t-minified.js-nowrap
+105680 1x150 keys f , f , f , f , f , f , f , f , t space t space t space t space t space t space t space t space
+110480 phase gl-gh-minified.js-nowrap
+110480 3x500 keys g l g h
+116480 phase insert-end-minified.js-nowrap
+116480 1x300 keys $ a t
+117125 1x45 keys y p e d space a t space t h e space e n d space t y p e d space a t space t h e space e n d space escape
+118910 phase insert-middle-minified.js-nowrap
+118910 1x40 keys 0 4 0 0 0 0 l i
+119490 1x45 keys t y p e d space i n space t h e space m i d d l e space t y p e d space i n space t h e space m i d d l e space escape
+121590 phase sweep-L-W-minified.js-nowrap
+121590 40x33 key L
+122910 30x33 key W
+123900 2x300 exec Del
+124800 exec Look kinds/oneline.json
+126300 2x400 key g
+127100 phase w-held-oneline.json-nowrap
+127100 60x33 key w
+129080 phase e-held-oneline.json-nowrap
+129080 60x33 key e
+131060 phase l-held-oneline.json-nowrap
+131060 90x33 key l
+134030 phase dollar-zero-oneline.json-nowrap
+134030 2x600 keys $ 0
+136430 phase f-t-oneline.json-nowrap
+136430 1x150 keys f , f , f , f , f , f , f , f , t space t space t space t space t space t space t space t space
+141230 phase gl-gh-oneline.json-nowrap
+141230 3x500 keys g l g h
+147230 phase insert-end-oneline.json-nowrap
+147230 1x300 keys $ a t
+147875 1x45 keys y p e d space a t space t h e space e n d space t y p e d space a t space t h e space e n d space escape
+149660 phase insert-middle-oneline.json-nowrap
+149660 1x40 keys 0 4 0 0 0 0 l i
+150240 1x45 keys t y p e d space i n space t h e space m i d d l e space t y p e d space i n space t h e space m i d d l e space escape
+152340 phase sweep-L-W-oneline.json-nowrap
+152340 40x33 key L
+153660 30x33 key W
+154650 2x300 exec Del
+155550 exec Look kinds/hugelines.txt
+157050 2x400 key g
+157850 phase w-held-hugelines.txt-nowrap
+157850 60x33 key w
+159830 phase e-held-hugelines.txt-nowrap
+159830 60x33 key e
+161810 phase l-held-hugelines.txt-nowrap
+161810 90x33 key l
+164780 phase dollar-zero-hugelines.txt-nowrap
+164780 2x600 keys $ 0
+167180 phase f-t-hugelines.txt-nowrap
+167180 1x150 keys f , f , f , f , f , f , f , f , t space t space t space t space t space t space t space t space
+171980 phase gl-gh-hugelines.txt-nowrap
+171980 3x500 keys g l g h
+177980 phase insert-end-hugelines.txt-nowrap
+177980 1x300 keys $ a t
+178625 1x45 keys y p e d space a t space t h e space e n d space t y p e d space a t space t h e space e n d space escape
+180410 phase insert-middle-hugelines.txt-nowrap
+180410 1x40 keys 0 4 0 0 0 0 l i
+180990 1x45 keys t y p e d space i n space t h e space m i d d l e space t y p e d space i n space t h e space m i d d l e space escape
+183090 phase sweep-L-W-hugelines.txt-nowrap
+183090 40x33 key L
+184410 30x33 key W
+185400 2x300 exec Del
+186300 end
diff --git a/tools/demos/one.txt b/tools/demos/one.txt
new file mode 100644
index 00000000..acf310ca
--- /dev/null
+++ b/tools/demos/one.txt
@@ -0,0 +1,11 @@
+# one: the scroll set alone, on the file the session opened: one kind, for a
+# profiler's run.
+1500 phase one
+1500 7x150 wheel 1
+2408 99x8 wheel 1
+3700 1x400 keys ^d ^d ^d page_down
+4933 44x33 key page_down
+6785 1x20 keys g e
+7385 2x20 key g
+7985 30x33 key j
+9475 end
diff --git a/tools/demos/panes.txt b/tools/demos/panes.txt
new file mode 100644
index 00000000..a2a74b1c
--- /dev/null
+++ b/tools/demos/panes.txt
@@ -0,0 +1,91 @@
+# panes: the other kinds of pane, opened from the first file's directory,
+# each put through the scroll set: a command's fast output (the stress file,
+# then yes), a +Pager, a directory, a PDF, a picture, Help's output pane, a
+# +Diff, and the query pane typed into (its rows refilled each key, its
+# owner's places drawn).
+1500 phase command-cat
+1500 exec cat stress.zig
+1800 7x150 wheel 1
+2708 99x8 wheel 1
+4000 1x400 keys ^d ^d ^d page_down
+5233 44x33 key page_down
+7085 1x20 keys g e
+7685 2x20 key g
+8285 30x33 key j
+9775 exec Del
+10375 phase command-yes
+10375 exec yes | head -200000
+10675 7x150 wheel 1
+11583 99x8 wheel 1
+12875 1x400 keys ^d ^d ^d page_down
+14108 44x33 key page_down
+15960 1x20 keys g e
+16560 2x20 key g
+17160 30x33 key j
+18650 exec Del
+19250 phase pager
+19250 exec cat stress.zig | pardes -
+21750 7x150 wheel 1
+22658 99x8 wheel 1
+23950 1x400 keys ^d ^d ^d page_down
+25183 44x33 key page_down
+27035 1x20 keys g e
+27635 2x20 key g
+28235 30x33 key j
+29725 exec Del
+30325 phase directory
+30325 exec Look kinds/
+31525 7x150 wheel 1
+32433 99x8 wheel 1
+33725 1x400 keys ^d ^d ^d page_down
+34958 44x33 key page_down
+36810 1x20 keys g e
+37410 2x20 key g
+38010 30x33 key j
+39500 exec Del
+40100 phase pdf
+40100 exec Look ../../docs/design.pdf
+42100 7x150 wheel 1
+43008 99x8 wheel 1
+44300 1x400 keys ^d ^d ^d page_down
+45533 44x33 key page_down
+47385 1x20 keys g e
+47985 2x20 key g
+48585 30x33 key j
+50075 exec Del
+50675 phase image
+50675 exec Look ../../docs/screenshots/atelier.png
+51875 7x150 wheel 1
+52783 99x8 wheel 1
+54075 1x400 keys ^d ^d ^d page_down
+55308 44x33 key page_down
+57160 1x20 keys g e
+57760 2x20 key g
+58360 30x33 key j
+59850 exec Del
+60450 phase help
+60450 exec Help
+61650 7x150 wheel 1
+62558 99x8 wheel 1
+63850 1x400 keys ^d ^d ^d page_down
+65083 44x33 key page_down
+66935 1x20 keys g e
+67535 2x20 key g
+68135 30x33 key j
+69625 exec Del
+70225 phase changelog
+70225 exec Changelog
+71425 7x150 wheel 1
+72333 99x8 wheel 1
+73625 1x400 keys ^d ^d ^d page_down
+74858 44x33 key page_down
+76710 1x20 keys g e
+77310 2x20 key g
+77910 30x33 key j
+79400 exec Del
+80000 phase query-typing
+80000 1x300 keys / p
+80450 1x150 keys a n e . v i e ^n
+81620 11x120 key ^n
+82940 key escape
+83740 end
diff --git a/tools/demos/pdf-scroll.txt b/tools/demos/pdf-scroll.txt
new file mode 100644
index 00000000..0aa2316b
--- /dev/null
+++ b/tools/demos/pdf-scroll.txt
@@ -0,0 +1,22 @@
+# pdf-scroll: a PDF's strip put through what moves it (anim 11): a wheel's
+# notches, then spun; PageDown held; the far jumps ge and gg; a Look at a
+# page and Back; then slow: a notch at a time, and a touchpad's drag a pixel
+# or so a frame.
+1500 exec Look ../../docs/design.pdf
+3500 phase spin
+3500 7x150 wheel 1
+4408 59x8 wheel 1
+5480 30x8 wheel -1
+6320 phase held-pagedown
+6320 20x33 key page_down
+7580 phase far-jump
+7580 1x20 keys g e
+8380 2x20 key g
+9180 exec Look ../../docs/design.pdf:12
+9980 key ^o
+10780 phase slow-notches
+10780 8x300 wheel 1
+13180 phase slow-touch
+13180 120x16 touch 0.06
+15700 phase done
+15700 end
diff --git a/tools/demos/pdf-sdm.txt b/tools/demos/pdf-sdm.txt
new file mode 100644
index 00000000..00c4a50f
--- /dev/null
+++ b/tools/demos/pdf-sdm.txt
@@ -0,0 +1,24 @@
+# pdf-sdm: the same, on a manual of 5363 pages (the Intel SDM, combined
+# volumes, 27 MB: run where sdm.pdf is, a copy): its open, a wheel spun both
+# ways, PageDown held five seconds, a far Look to page 3000 and Back, gg, a
+# Look at page 4500, then slow notches and a touchpad's drag.
+1500 phase open
+1500 exec Look sdm.pdf
+4500 phase spin
+4500 7x150 wheel 1
+5408 59x8 wheel 1
+6480 30x8 wheel -1
+7320 phase held-pagedown
+7320 150x33 key page_down
+13070 phase far-jump
+13070 exec Look sdm.pdf:3000
+14270 1x1200 keys ^o g
+15490 key g
+16670 phase look-deep
+16670 exec Look sdm.pdf:4500
+18170 phase slow-notches
+18170 8x300 wheel 1
+20570 phase slow-touch
+20570 120x16 touch 0.06
+23090 phase done
+23090 end
diff --git a/tools/demos/scroll.txt b/tools/demos/scroll.txt
new file mode 100644
index 00000000..adb64e73
--- /dev/null
+++ b/tools/demos/scroll.txt
@@ -0,0 +1,25 @@
+# scroll: every kind of scroll a user makes, on a long file from its top:
+# single notches, a fast spin of the wheel both ways (notches 8 ms apart,
+# two a frame: each retargets the one before), half pages, pages, the far
+# jumps to the end (ge) and back (gg), half pages faster than they settle,
+# and the cursor moving a line, a word and, in insert mode, a column at a
+# time.
+1500 phase notches
+1500 10x150 wheel 1
+3400 phase spin
+3400 24x8 wheel 1
+4392 24x8 wheel -1
+5384 phase pages
+5384 1x600 keys ^d ^d ^d ^u ^u ^f ^b g
+9604 1x780 keys e g
+10404 key g
+11184 phase retarget
+11184 4x80 key ^d
+12204 phase cursor
+12204 10x60 key j
+13204 10x90 key w
+14504 1x300 keys i right
+14864 7x60 key right
+15584 8x100 key down
+16684 key escape
+17684 end
diff --git a/tools/demos/stress.txt b/tools/demos/stress.txt
new file mode 100644
index 00000000..54a7382d
--- /dev/null
+++ b/tools/demos/stress.txt
@@ -0,0 +1,24 @@
+# stress: throughput on a big file (layout.zig x23, 30k lines): each input
+# held for three seconds at a keyboard's repeat (33 ms) or a wheel spun hard
+# (a notch every 8 ms), so the picture has to keep up with more than it can
+# show: a spin, held Ctrl-d, held j, held PageDown, then the far jumps.
+1500 2x20 key g
+2300 phase spin
+2300 375x8 wheel 1
+6300 2x20 key g
+7100 phase held-ctrl-d
+7100 91x33 key ^d
+11103 2x20 key g
+11903 phase held-j
+11903 91x33 key j
+15906 2x20 key g
+16706 phase held-pagedown
+16706 91x33 key page_down
+20709 phase far
+20709 1x20 keys g e
+21409 2x20 key g
+22109 1x20 keys g e
+22809 2x20 key g
+23509 1x20 keys g e
+24209 2x20 key g
+25409 end