From 09da0f673cfd9fdb83c4e48a2fa73a274aff4a6f Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 1 Oct 2026 11:17:45 -0300 Subject: The documentation site's landing page has four short silent clips in docs/site/media, recorded from a hidden test window by test/record_demos.py text-is-the-interface, terminals-are-panes, scripting-over-9p and diff-review: each a webm (VP9), an mp4 (H.264, faststart) and a poster PNG at 960 px, with captions.txt. The script drives a PARDES_TEST session on the virtual clock through stdin mouse events, keys and 9P, keeps the settled frame after each step, draws the pointer and loops each clip with a dissolve back to its first frame. Co-Authored-By: Claude Opus 5.5 --- test/record_demos.py | 614 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 614 insertions(+) create mode 100644 test/record_demos.py (limited to 'test/record_demos.py') diff --git a/test/record_demos.py b/test/record_demos.py new file mode 100644 index 00000000..655ec475 --- /dev/null +++ b/test/record_demos.py @@ -0,0 +1,614 @@ +#!/usr/bin/env python3 +"""Record the documentation site's landing-page clips from a hidden window. + +zig build -Dplatform=gui -Doptimize=ReleaseSafe --prefix +python3 -B test/record_demos.py /bin/pardes-gui [clip ...] + +Each clip drives a throwaway session (PARDES_TEST: an offscreen capture, +the virtual clock) through its stdin's window-pixel mouse events, its keys +and its 9P files, keeps the settled frame after every step, and lays the +frames out on a timeline with a drawn pointer. ffmpeg encodes the timeline +to docs/site/media/.webm and .mp4, with .png as its poster and +captions.txt beside them. Needs a Wayland display for the hidden window, +gcc and git for the demo project, and 9ns (cloud9) for the scripting clip. + +Frames and the intermediate video go under --work (default +../.scratch/rec/work, beside the checkout). The demo project lives at +/tmp/hello, a short path for the tags, and the session's home at +/tmp/pardes-rec-home; both are removed after. Nothing of the caller's +environment that names a session, a mount or a bus reaches the recording. +""" +import argparse +import contextlib +import fcntl +import json +import os +from pathlib import Path +import shutil +import signal +import struct +import subprocess +import sys +import termios +import threading +import time + +from PIL import Image, ImageDraw, ImageFont + +sys.path.insert(0, str(Path(__file__).resolve().parent)) +from ninep import Client # noqa: E402 + +REPO = Path(__file__).resolve().parent.parent +MEDIA = REPO / 'docs/site/media' +BADGE_FONT = REPO / 'assets/AdwaitaMono-Regular.ttf' +FPS = 30 +COLS, ROWS = 60, 20 +# A test window's text is 27 px (16 px cells); tags draw at 82% of it +# (config.gui_tagline_font_percent), 13 px a character. +TAG_W = 13 +# acme's pale yellow and blue read at the size a landing page shows a clip, +# and are the site's own colours. +THEME = ['acme'] +WIDTH = 960 # the clips' width: the window's own, never scaled +PROJECT = Path('/tmp/hello') +HOME = Path('/tmp/pardes-rec-home') + +# Nothing of the caller's session reaches the recording: no live pardes, +# no mount, no bus, no editor. +SCRUB = ('NINE_MOUNT', 'NAMESPACE', 'DBUS_SESSION_BUS_ADDRESS', 'GIT_EDITOR', 'EDITOR', 'VISUAL', 'PAGER', + 'GIT_PAGER', 'MANPAGER', 'LESS', 'PROMPT_COMMAND', 'ENV', 'BASH_ENV', 'TMUX', 'ZMX_SESSION') + + +def clean_env(): + env = {k: v for k, v in os.environ.items() if not k.startswith('PARDES_') and k not in SCRUB} + display = Path(os.environ.get('WAYLAND_DISPLAY', 'wayland-0')) + if not display.is_absolute(): + display = Path(os.environ.get('XDG_RUNTIME_DIR', '/run/user/%d' % os.getuid())) / display + env.update(WAYLAND_DISPLAY=str(display), SDL_VIDEODRIVER='wayland', TERM='xterm-256color', + LANG='C.UTF-8', LC_ALL='C.UTF-8', GIT_AUTHOR_DATE='2026-09-30T12:00:00', GIT_COMMITTER_DATE='2026-09-30T12:00:00') + return env + + +MAIN_C = '''#include + +static int square(int n) +{ + return n * n; +} + +int main(void) +{ + int sum = 0; + for (int i = 1; i <= 4; i++) sum += square(i); + pritnf("sum: %d\\n", sum); + return 0; +} +''' + +README = '''hello: prints the sum of the first four squares. + +Build it with make, run it with ./hello. +''' + +MAKEFILE = '''CFLAGS = -Wall -fno-diagnostics-show-caret -fno-diagnostics-show-option + +hello: src/main.c +\t@cc $(CFLAGS) -o hello src/main.c +''' + + +def make_project(): + shutil.rmtree(PROJECT, ignore_errors=True) + (PROJECT / 'src').mkdir(parents=True) + (PROJECT / 'src/main.c').write_text(MAIN_C) + (PROJECT / 'Makefile').write_text(MAKEFILE) + (PROJECT / 'README').write_text(README) + + +class Session: + """A hidden pardes-gui window, its capture directory, its 9P client.""" + + def __init__(self, binary, work, name, args, init='', cols=COLS, rows=ROWS): + self.binary, self.work, self.name = Path(binary).resolve(), work, name + self.cols, self.rows = cols, rows + self.caps = work / 'cap' + self.frames = work / 'frames' + for d in (self.caps, self.frames): + shutil.rmtree(d, ignore_errors=True) + d.mkdir(parents=True) + shutil.rmtree(HOME, ignore_errors=True) + HOME.mkdir(mode=0o700) + (HOME / 'config/pardes').mkdir(parents=True) + theme = '' if THEME[0] == 'default' else f'Theme {THEME[0]}\n' + (HOME / 'config/pardes/init').write_text('Shell /bin/sh\n' + theme + 'MessageLinger 0\n' + init) + env = clean_env() + env.update(HOME=str(HOME), XDG_RUNTIME_DIR=str(HOME), XDG_CONFIG_HOME=str(HOME / 'config'), + PARDES_NOTIME='1', PARDES_DUMP=str(HOME / 'demo.dump.zon'), + PARDES_TEST='1', PARDES_TEST_CLOCK='1', PARDES_TEST_COLS=str(cols), PARDES_TEST_ROWS=str(rows), + PARDES_TEST_CAPTURE_DIR=str(self.caps)) + for language in ['RS', 'C', 'GO', 'TS', 'PY', 'ZIG']: + env['PARDES_LSP_' + language] = '' + master, slave = os.openpty() + fcntl.ioctl(slave, termios.TIOCSWINSZ, struct.pack('HHHH', rows, cols, 0, 0)) + self.master = master + self.child = subprocess.Popen( + [str(self.binary), '--9p=' + name, *map(str, args)], cwd=PROJECT, env=env, + stdin=slave, stdout=slave, stderr=open(work / 'stderr.log', 'wb'), start_new_session=True, + preexec_fn=lambda: fcntl.ioctl(0, termios.TIOCSCTTY, 0)) + os.close(slave) + self.reader = threading.Thread(target=self._drain, daemon=True) + self.reader.start() + address = HOME / f'pardes-9p-{name}.sock' + deadline = time.monotonic() + 30 + while not address.exists(): + if self.child.poll() is not None or time.monotonic() > deadline: + raise RuntimeError('session did not start; see ' + str(work / 'stderr.log')) + time.sleep(.01) + self.client = Client(str(address)) + self.client.__enter__() + self.shots = [] # the timeline: see shot() + self.pointer = None # the drawn pointer's (x, y), None for none + self.button = None # the SDL button held, drawn as a ring and its name + self.badge = None # a key or two, drawn in the corner + self.settle() + + def _drain(self): + try: + while os.read(self.master, 65536): + pass + except OSError: + pass + + def close(self): + with contextlib.suppress(Exception): + self.client.__exit__(None, None, None) + if self.child.poll() is None: + self.child.terminate() + try: + self.child.wait(timeout=10) + except subprocess.TimeoutExpired: + self.child.kill() + self.child.wait() + # The session's own process group: its shells and their children. + with contextlib.suppress(ProcessLookupError, PermissionError): + os.killpg(self.child.pid, signal.SIGKILL) + with contextlib.suppress(OSError): + os.close(self.master) + self.reader.join(timeout=2) + + # 9P + + def read(self, path): + return self.client.read(path).decode(errors='replace') + + def write(self, path, data): + self.client.write(path, data.encode() if isinstance(data, str) else data) + + def panes(self): + return {int(r.split()[0]): r.split()[1] for r in self.read('/index').splitlines() if r.strip()} + + def tag(self, serial): + return self.read(f'/pane/{serial}/tag') + + def screen(self): + s = json.loads(self.client.read('/screen')) + cols = s['cols'] + return [''.join((cell[0] or ' ') for cell in s['cells'][r * cols:(r + 1) * cols]) for r in range(s['rows'])] + + def find(self, text, after=0, nth=0): + """The (col, row) of `text` on screen, searching rows from `after`.""" + for r, line in enumerate(self.screen()): + if r < after: + continue + at = line.find(text) + while at >= 0: + if nth == 0: + return at, r + nth -= 1 + at = line.find(text, at + 1) + raise LookupError(f'{text!r} not on screen:\n' + '\n'.join(self.screen())) + + def terminal_rows(self): + """The screen's rows below the (one) terminal's tag.""" + rows = self.screen() + return rows[next(i for i, line in enumerate(rows) if 'Tty+sh' in line) + 1:] + + def wait(self, predicate, what, seconds=20): + deadline = time.monotonic() + seconds + while time.monotonic() < deadline: + with contextlib.suppress(Exception): + if predicate(): + return + time.sleep(.03) + raise RuntimeError('timed out waiting for ' + what + '\n' + '\n'.join(self.screen())) + + def wait_text(self, text, seconds=20): + self.wait(lambda: any(text in line for line in self.screen()), repr(text), seconds) + + # the window + + def cell_px(self, col, row): + """The pixel at the middle of a cell (the window is an exact grid).""" + w, h = self.size() + cw, ch = w / self.cols, h / self.rows + return int((col + .5) * cw), int((row + .55) * ch) + + def tag_px(self, col, row, start=3, offset=.5): + """The pixel over a tag's character: a tag is drawn in the tagline + font, narrower than the grid, from its first column `start` (3 in a + pane's or column's tag, 0 in the workspace's).""" + w, h = self.size() + cw, ch = w / self.cols, h / self.rows + return int(start * cw + (col - start + offset) * TAG_W), int((row + .55) * ch) + + def size(self): + with open(self.caps / 'latest.ppm', 'rb') as f: + f.readline() + w, h = map(int, f.readline().split()) + return w, h + + def mouse(self, kind, button, x, y): + os.write(self.master, f'\x1b]777;mouse;{kind};{button};{x};{y}\x07'.encode()) + time.sleep(.05) + + def keys(self, data): + os.write(self.master, data.encode() if isinstance(data, str) else data) + time.sleep(.03) + + def status(self): + try: + step, frames, idle = (self.caps / 'status').read_text().split()[:3] + return int(step), int(frames), idle == '1' + except (FileNotFoundError, ValueError): + return None + + def settle(self): + """The frame once the window says it is idle (test/gui_golden.py).""" + deadline = time.monotonic() + 60 + start = None + while time.monotonic() < deadline: + now = self.status() + if now is not None: + if start is None: + start = now[0] + elif now[0] >= start + 2 and now[2] and now[1] > 0: + data = (self.caps / 'latest.ppm').read_bytes() + if data.startswith(b'P6'): + return data + time.sleep(.02) + raise RuntimeError('the window never went idle') + + # the timeline + + def shot(self, seconds, poster=False): + """Hold the settled frame for `seconds`, the pointer where it is. + `poster` marks the frame drawn as the clip's still.""" + data = self.settle() + path = self.frames / f'{len(self.shots):04d}.ppm' + path.write_bytes(data) + self.shots.append(dict(frame=path, secs=seconds, start=self.pointer, end=self.pointer, + button=self.button, badge=self.badge, poster=poster)) + + def glide(self, x, y, seconds=.6): + """Glide the drawn pointer to (x, y) over the frame on screen, then + move the window's pointer there (dragging any button held).""" + if self.shots and self.pointer is not None: + last = self.shots[-1] + self.shots.append(dict(last, secs=seconds, start=self.pointer, end=(x, y), poster=False)) + self.pointer = (x, y) + self.mouse('motion', self.button or 0, x, y) + + def sweep(self, button, start, end, hold=.5): + """Press `button` (SDL: 1 left, 2 middle, 3 right) at `start`, + drag it to `end` and release: the sweep acme's B2 and B3 take.""" + if self.pointer != start: + self.glide(*start) + self.mouse('down', button, *start) + self.button = button + self.shot(.15) + if end != start: + self.glide(*end, seconds=.3) + self.shot(hold) + self.mouse('up', button, *self.pointer) + self.button = None + + def press(self, keys, per_key=.4): + """Send each (key bytes, badge) of `keys`, a frame a key with the + badge in the corner.""" + for key, badge in keys: + self.badge = badge + self.keys(key) + self.shot(per_key) + self.badge = None + + def type(self, text, expect, per_key=.07): + """Type `text` a key at a time, a frame per key, once `expect(prefix)` + says the window shows what is typed so far.""" + for i, ch in enumerate(text): + self.keys(ch) + prefix = text[:i + 1] + self.wait(lambda: expect(prefix), 'echo of ' + repr(prefix)) + self.shot(per_key) + + +# composing + +def pointer_sprite(scale): + """An arrow pointer, white with a dark outline, its hotspot at (1, 1).""" + pts = [(0, 0), (0, 17), (4, 13), (7, 20), (10, 19), (7, 12), (12, 12)] + pts = [(x * scale + 1, y * scale + 1) for x, y in pts] + im = Image.new('RGBA', (int(13 * scale) + 4, int(21 * scale) + 4), (0, 0, 0, 0)) + ImageDraw.Draw(im).polygon(pts, fill=(255, 255, 255, 255), outline=(20, 20, 20, 255), width=2) + return im + + +# acme's colours for the buttons: B2 red, B3 green. +BUTTONS = {1: ('click', (70, 70, 70)), 2: ('middle-click', (170, 0, 0)), 3: ('right-click', (0, 110, 40))} + + +def draw_badge(img, text, xy, font, fill=(40, 40, 40), anchor='lt'): + d = ImageDraw.Draw(img, 'RGBA') + box = d.textbbox(xy, text, font=font, anchor=anchor) + pad = 7 + d.rounded_rectangle((box[0] - pad, box[1] - pad, box[2] + pad, box[3] + pad), radius=8, fill=fill + (235,)) + d.text(xy, text, font=font, fill=(255, 255, 255), anchor=anchor) + + +class Painter: + def __init__(self, size): + self.sprite = pointer_sprite(1.7) + self.font = ImageFont.truetype(str(BADGE_FONT), 24) + self.size = size + + def paint(self, img, pointer, button, badge): + img = img.copy() + w, h = self.size + if badge: + draw_badge(img, badge, (w - 16, h - 16), self.font, anchor='rb') + if pointer is not None: + x, y = pointer + if button: + label, colour = BUTTONS[button] + d = ImageDraw.Draw(img, 'RGBA') + r = 16 + d.ellipse((x - r, y - r, x + r, y + r), outline=colour + (255,), width=4) + # The name sits below the pointer, kept inside the frame. + lx = min(x + 22, w - 16 - self.font.getlength(label)) + draw_badge(img, label, (lx, y + 40), self.font, fill=colour) + img.paste(self.sprite, (int(x) - 1, int(y) - 1), self.sprite) + return img + + +def ease(t): + return t * t * (3 - 2 * t) + + +def lerp(a, b, t): + if a is None or b is None: + return b if t >= .5 else a + return (a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t) + + +def compose(shots, out): + """The shots at FPS with the pointer drawn, ending in a dissolve back to + the first frame so the clip loops; written lossless (FFV1) to `out`. + Answers the clip's length in seconds and its poster image.""" + first = Image.open(shots[0]['frame']).convert('RGB') + painter = Painter(first.size) + w, h = first.size + ff = subprocess.Popen(['ffmpeg', '-v', 'error', '-y', '-f', 'rawvideo', '-pix_fmt', 'rgb24', '-s', f'{w}x{h}', + '-r', str(FPS), '-i', '-', '-c:v', 'ffv1', str(out)], stdin=subprocess.PIPE) + poster = None + clock, emitted = 0.0, 0 + loaded = (None, None) + for shot in shots: + if loaded[0] != shot['frame']: + loaded = (shot['frame'], Image.open(shot['frame']).convert('RGB')) + img = loaded[1] + clock += shot['secs'] + n = round(clock * FPS) - emitted + for i in range(n): + t = ease((i + 1) / n) + frame = painter.paint(img, lerp(shot['start'], shot['end'], t), shot['button'], shot['badge']) + ff.stdin.write(frame.tobytes()) + if shot['poster'] and poster is None: + poster = painter.paint(img, shot['end'], shot['button'], None) + emitted += n + last = shots[-1] + n = round(.7 * FPS) + for i in range(n): + t = ease((i + 1) / n) + frame = Image.blend(loaded[1], first, t) + ff.stdin.write(painter.paint(frame, lerp(last['end'], shots[0]['start'], t), None, None).tobytes()) + emitted += n + ff.stdin.close() + if ff.wait() != 0: + raise RuntimeError('ffmpeg (lossless) failed') + return emitted / FPS, poster or painter.paint(first, None, None, None) + + +def encode(lossless, name, poster, crf_webm=30, crf_mp4=20): + """.webm (VP9) and .mp4 (H.264, yuv420p, faststart) and the poster + PNG, in MEDIA.""" + MEDIA.mkdir(parents=True, exist_ok=True) + webm, mp4 = MEDIA / (name + '.webm'), MEDIA / (name + '.mp4') + scale = [] if poster.width == WIDTH else ['-vf', f'scale={WIDTH}:-2:flags=lanczos'] + subprocess.run(['ffmpeg', '-v', 'error', '-y', '-i', str(lossless), *scale, '-c:v', 'libvpx-vp9', + '-b:v', '0', '-crf', str(crf_webm), '-row-mt', '1', '-deadline', 'good', '-cpu-used', '1', + '-g', '240', '-pix_fmt', 'yuv420p', '-an', str(webm)], check=True) + subprocess.run(['ffmpeg', '-v', 'error', '-y', '-i', str(lossless), *scale, '-c:v', 'libx264', + '-preset', 'veryslow', '-crf', str(crf_mp4), '-tune', 'animation', '-pix_fmt', 'yuv420p', + '-movflags', '+faststart', '-an', str(mp4)], check=True) + if poster.width != WIDTH: + poster = poster.resize((WIDTH, round(poster.height * WIDTH / poster.width)), Image.LANCZOS) + poster.save(MEDIA / (name + '.png'), optimize=True) + return [webm, mp4, MEDIA / (name + '.png')] + + +# the clips + +def text_is_the_interface(s): + """B2 on `make` in a tag runs it; B3 on the error opens the file there.""" + s.write('/pane/1/tag', ' make') + s.pointer = s.cell_px(36, 9) + s.shot(1.0) + col, row = s.find('make', 0) + s.sweep(2, s.tag_px(col, row, offset=.15), s.tag_px(col + 3, row, offset=.85)) + s.wait(lambda: any('exit' in s.tag(n) for n, kind in s.panes().items() if kind == 'cmd'), 'make to finish') + s.shot(1.1) + col, row = s.find('src/main.c:12:5', 0) + s.sweep(3, s.cell_px(col, row), s.cell_px(col + 14, row)) + s.wait(lambda: len(s.panes()) == 3, 'main.c to open') + s.glide(*s.cell_px(40, 9), seconds=.5) + s.shot(2.6, poster=True) + + +def shell_setup(s): + """A terminal under the file, at the project, with a short prompt.""" + s.write('/pane/1/exec', 'Tty\n') + s.wait(lambda: 2 in s.panes(), 'the terminal') + s.write('/pane/2/pty/data', f"cd {PROJECT}; PS1='$ '; clear\r") + s.wait(lambda: any(line.rstrip() == ' $' for line in s.screen()), 'the prompt') + # The pointer rests off the tags, so no word's hint is up. + s.mouse('motion', 0, *s.cell_px(COLS - 2, ROWS - 1)) + + +def mounted_shell_setup(s): + """A terminal under the file whose shell sees the session as files: + cloud9's 9ns mounts the pane's $PARDES_9P in a private namespace.""" + shell_setup(s) + mount = HOME / 'n' + mount.mkdir() + s.write('/pane/2/pty/data', f'exec 9ns --unix "$PARDES_9P" --mount {mount} -- /bin/sh\r') + time.sleep(1.5) # 9ns mounts and starts the shell that reads the next line + s.write('/pane/2/pty/data', "cd \"$NINE_MOUNT\" && PS1='$ ' && clear\r") + s.wait(lambda: [line.rstrip() for line in s.terminal_rows() if line.strip()] == [' $'], 'the mounted shell') + + +def scripting_over_9p(s): + """A shell reads the session's files and writes a pane's body.""" + s.shot(1.0) + for command, done in [('ls', lambda: any('index' in line for line in s.terminal_rows()[1:])), + ('cat index', lambda: any(' term ' in line for line in s.terminal_rows())), + ("echo 'hello from a script' > pane/1/body", lambda: 'hello from' in s.screen()[3])]: + s.type(command, lambda typed: at_prompt(s, typed)(), per_key=.06) + s.keys('\r') + s.wait(done, command) + s.wait(lambda: [line.rstrip() for line in s.terminal_rows() if line.strip()][-1] == ' $', 'the prompt') + s.shot(1.3) + s.shots[-1]['secs'] = 2.4 + s.shots[-1]['poster'] = True + + +def at_prompt(s, text): + return lambda: any(line.startswith(' $ ' + text) for line in s.screen()) + + +def terminals_are_panes(s): + """A shell under the file; Ctrl-b and its output is text to move over.""" + s.write('/pane/1/dot', '12\n') + s.shot(1.0) + s.type('make', lambda typed: at_prompt(s, typed)()) + s.keys('\r') + s.wait(lambda: 'Error 1' in '\n'.join(s.screen()), 'make') + s.wait(lambda: any(line.rstrip() == ' $' for line in s.screen()), 'the next prompt') + s.shot(1.4) + s.press([('\x02', 'Ctrl-b')], per_key=.8) + s.press([('k', 'k'), ('k', 'k k'), ('k', 'k k k')], per_key=.4) + s.press([('x', 'x')], per_key=2.4) + s.shots[-1]['poster'] = True + + +def diff_setup(s): + """The project committed, then its typo fixed; a lone terminal.""" + env = dict(clean_env(), HOME=str(HOME), GIT_AUTHOR_NAME='demo', GIT_AUTHOR_EMAIL='demo@example.com', + GIT_COMMITTER_NAME='demo', GIT_COMMITTER_EMAIL='demo@example.com') + for args in (['init', '-q'], ['add', '.'], ['commit', '-qm', 'hello'], ['config', 'diff.context', '1']): + subprocess.run(['git', '-C', str(PROJECT), *args], check=True, env=env, capture_output=True) + main = PROJECT / 'src/main.c' + main.write_text(main.read_text().replace('pritnf', 'printf')) + shell_setup(s) + s.write('/pane/1/exec', 'Del\n') + s.wait(lambda: list(s.panes()) == [2], 'the README to close') + + +def diff_review(s): + """git diff in a shell pages into +Pager as a diff; B3 on its + line + opens the file at that line.""" + s.pointer = s.cell_px(40, 6) + s.shot(.9) + s.type('git diff', lambda typed: at_prompt(s, typed)()) + s.keys('\r') + s.wait(lambda: 'pager' in s.panes().values() or len(s.panes()) == 2, 'the pager') + s.wait_text('+ printf') + s.shot(1.4) + col, row = s.find('+ printf', 0) + s.sweep(3, s.cell_px(col, row), s.cell_px(col, row)) + s.wait(lambda: len(s.panes()) == 3, 'main.c to open') + s.glide(*s.cell_px(42, 9), seconds=.5) + s.shot(2.6, poster=True) + + +CLIPS = { + 'text-is-the-interface': dict( + run=text_is_the_interface, args=[PROJECT / 'README'], + caption='Middle-click runs a word; right-click an error opens the file.'), + 'terminals-are-panes': dict( + setup=shell_setup, run=terminals_are_panes, args=[PROJECT / 'src/main.c'], + caption='A shell is a pane: Ctrl-b, then move over its output.'), + 'scripting-over-9p': dict( + setup=mounted_shell_setup, run=scripting_over_9p, args=[PROJECT / 'README'], + caption='The session is files: a shell script reads and writes its panes.'), + 'diff-review': dict( + setup=diff_setup, run=diff_review, args=[PROJECT / 'README'], + caption='git diff pages into a pane; right-click a change to open it.'), +} + + +def record(binary, work, name): + clip = CLIPS[name] + make_project() + s = Session(binary, work / name, 'rec-' + name, clip['args'], init=clip.get('init', '')) + try: + if 'setup' in clip: + clip['setup'](s) + clip['run'](s) + finally: + s.close() + seconds, poster = compose(s.shots, work / name / 'lossless.mkv') + files = encode(work / name / 'lossless.mkv', name, poster) + for f in files: + print(f'{f.name} {f.stat().st_size / 1e6:.2f} MB') + print(f'{name}: {seconds:.1f} s') + return seconds + + +def main(): + parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) + parser.add_argument('binary', type=Path, help='a pardes-gui built with -Dplatform=gui') + parser.add_argument('clips', nargs='*', help='which clips (default: all): ' + ', '.join(CLIPS)) + parser.add_argument('--work', type=Path, default=REPO.parent / '.scratch/rec/work', + help='frames and intermediates (large; default %(default)s)') + parser.add_argument('--theme', default=THEME[0], help='a theme name, or default (default %(default)s)') + args = parser.parse_args() + THEME[0] = args.theme + names = args.clips or list(CLIPS) + for name in names: + if name not in CLIPS: + parser.error(f'no clip {name!r}: ' + ', '.join(CLIPS)) + try: + for name in names: + record(args.binary, args.work.resolve(), name) + finally: + shutil.rmtree(PROJECT, ignore_errors=True) + shutil.rmtree(HOME, ignore_errors=True) + captions = MEDIA / 'captions.txt' + lines = dict(line.split(': ', 1) for line in captions.read_text().splitlines() if ': ' in line) \ + if captions.exists() else {} + for name in names: + lines[name] = CLIPS[name]['caption'] + captions.write_text(''.join(f'{name}: {lines[name]}\n' for name in CLIPS if name in lines)) + + +if __name__ == '__main__': + main() -- cgit v1.3 From f6a511c61d7ef2ff680f70077b236559a595be69 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 1 Oct 2026 12:42:48 -0300 Subject: Clicks in the site's clips stop, then click in place with a ring; the hero opens on all three panes; new clips show the PDF and image panes; the Themes gallery has a shot of every theme record_demos.py: a click glides to its target, stops, and presses and releases with the pointer still (a ring and the button's name on the press, a pulse after), pausing before anything moves. The hero's README, main.c and output pane are all up from its first frame. pdf-navigation and pdf-tint-fit page the Intel SDM vol. 2 (--pdf, read where it is): PdfSections to CPUID, a search stepped with n, PdfTint's three looks, PdfFit both ways and a page address. image-pane opens a Mandelbrot PNG the script draws, then Petscii. `record_demos.py themes` shoots one scene in each theme of src/themes, in the Themes order, into docs/site/media/themes with themes.toml (ready). Co-Authored-By: Claude Opus 5.5 --- docs/site/media/captions.txt | 11 +- docs/site/media/clips.toml | 15 + docs/site/media/diff-review.mp4 | Bin 139657 -> 133945 bytes docs/site/media/diff-review.png | Bin 84748 -> 92094 bytes docs/site/media/diff-review.webm | Bin 217009 -> 231829 bytes docs/site/media/image-pane.mp4 | Bin 0 -> 182755 bytes docs/site/media/image-pane.png | Bin 0 -> 189612 bytes docs/site/media/image-pane.webm | Bin 0 -> 223710 bytes docs/site/media/pdf-navigation.mp4 | Bin 0 -> 732978 bytes docs/site/media/pdf-navigation.png | Bin 0 -> 161942 bytes docs/site/media/pdf-navigation.webm | Bin 0 -> 809445 bytes docs/site/media/pdf-tint-fit.mp4 | Bin 0 -> 672000 bytes docs/site/media/pdf-tint-fit.png | Bin 0 -> 154718 bytes docs/site/media/pdf-tint-fit.webm | Bin 0 -> 687970 bytes docs/site/media/scripting-over-9p.webm | Bin 230045 -> 230045 bytes docs/site/media/terminals-are-panes.webm | Bin 132696 -> 132696 bytes docs/site/media/text-is-the-interface.mp4 | Bin 244272 -> 208679 bytes docs/site/media/text-is-the-interface.png | Bin 84804 -> 84827 bytes docs/site/media/text-is-the-interface.webm | Bin 330331 -> 279200 bytes docs/site/media/themes/acme.png | Bin 0 -> 56068 bytes docs/site/media/themes/alucard.png | Bin 0 -> 56543 bytes docs/site/media/themes/atelier.png | Bin 0 -> 54117 bytes docs/site/media/themes/ayu_dark.png | Bin 0 -> 53936 bytes docs/site/media/themes/ayu_light.png | Bin 0 -> 51539 bytes docs/site/media/themes/ayu_mirage.png | Bin 0 -> 53282 bytes docs/site/media/themes/catppuccin_frappe.png | Bin 0 -> 54195 bytes docs/site/media/themes/catppuccin_latte.png | Bin 0 -> 53833 bytes docs/site/media/themes/catppuccin_macchiato.png | Bin 0 -> 54572 bytes docs/site/media/themes/catppuccin_mocha.png | Bin 0 -> 55309 bytes docs/site/media/themes/clay.png | Bin 0 -> 54402 bytes docs/site/media/themes/dark.png | Bin 0 -> 51087 bytes docs/site/media/themes/dark_plus.png | Bin 0 -> 53097 bytes docs/site/media/themes/daybreak.png | Bin 0 -> 50612 bytes docs/site/media/themes/doom_one.png | Bin 0 -> 53266 bytes docs/site/media/themes/doom_one_light.png | Bin 0 -> 53006 bytes docs/site/media/themes/dracula.png | Bin 0 -> 54472 bytes docs/site/media/themes/dracula_soft.png | Bin 0 -> 54126 bytes docs/site/media/themes/duckbones.png | Bin 0 -> 55159 bytes docs/site/media/themes/dusk.png | Bin 0 -> 53826 bytes docs/site/media/themes/forestbones_dark.png | Bin 0 -> 55144 bytes docs/site/media/themes/forestbones_light.png | Bin 0 -> 53618 bytes docs/site/media/themes/forge.png | Bin 0 -> 53735 bytes docs/site/media/themes/forge_black.png | Bin 0 -> 49798 bytes docs/site/media/themes/forge_soft.png | Bin 0 -> 53106 bytes docs/site/media/themes/harvest.png | Bin 0 -> 55290 bytes docs/site/media/themes/helix.png | Bin 0 -> 52253 bytes docs/site/media/themes/ink.png | Bin 0 -> 50438 bytes docs/site/media/themes/kanagawabones.png | Bin 0 -> 55944 bytes docs/site/media/themes/lagoon.png | Bin 0 -> 51345 bytes docs/site/media/themes/lapis.png | Bin 0 -> 58311 bytes docs/site/media/themes/lapis_plain.png | Bin 0 -> 54111 bytes docs/site/media/themes/monokai.png | Bin 0 -> 55500 bytes docs/site/media/themes/monokai_pro.png | Bin 0 -> 52437 bytes docs/site/media/themes/monokai_pro_classic.png | Bin 0 -> 52583 bytes docs/site/media/themes/monokai_pro_light.png | Bin 0 -> 54494 bytes docs/site/media/themes/monokai_pro_light_sun.png | Bin 0 -> 55294 bytes docs/site/media/themes/monokai_pro_machine.png | Bin 0 -> 53048 bytes docs/site/media/themes/monokai_pro_octagon.png | Bin 0 -> 53951 bytes docs/site/media/themes/monokai_pro_ristretto.png | Bin 0 -> 52794 bytes docs/site/media/themes/monokai_pro_spectrum.png | Bin 0 -> 53833 bytes docs/site/media/themes/neobones_dark.png | Bin 0 -> 54808 bytes docs/site/media/themes/neobones_light.png | Bin 0 -> 54854 bytes docs/site/media/themes/nord.png | Bin 0 -> 53617 bytes docs/site/media/themes/nordbones.png | Bin 0 -> 55741 bytes docs/site/media/themes/orchard.png | Bin 0 -> 54859 bytes docs/site/media/themes/orchard_black.png | Bin 0 -> 50762 bytes docs/site/media/themes/paper.png | Bin 0 -> 55203 bytes docs/site/media/themes/rose_pine.png | Bin 0 -> 55110 bytes docs/site/media/themes/rose_pine_dawn.png | Bin 0 -> 56381 bytes docs/site/media/themes/rose_pine_moon.png | Bin 0 -> 53748 bytes docs/site/media/themes/rosebones_dark.png | Bin 0 -> 55441 bytes docs/site/media/themes/rosebones_light.png | Bin 0 -> 53670 bytes docs/site/media/themes/seoul256_dark_233.png | Bin 0 -> 54107 bytes docs/site/media/themes/seoul256_dark_234.png | Bin 0 -> 53423 bytes docs/site/media/themes/seoul256_dark_235.png | Bin 0 -> 53351 bytes docs/site/media/themes/seoul256_dark_236.png | Bin 0 -> 52348 bytes docs/site/media/themes/seoul256_dark_237.png | Bin 0 -> 51101 bytes docs/site/media/themes/seoul256_dark_238.png | Bin 0 -> 51346 bytes docs/site/media/themes/seoul256_dark_239.png | Bin 0 -> 50757 bytes docs/site/media/themes/seoul256_light_252.png | Bin 0 -> 49932 bytes docs/site/media/themes/seoul256_light_253.png | Bin 0 -> 50861 bytes docs/site/media/themes/seoul256_light_254.png | Bin 0 -> 51138 bytes docs/site/media/themes/seoul256_light_255.png | Bin 0 -> 51590 bytes docs/site/media/themes/seoul256_light_256.png | Bin 0 -> 48496 bytes docs/site/media/themes/seoulbones_dark.png | Bin 0 -> 53482 bytes docs/site/media/themes/seoulbones_light.png | Bin 0 -> 53299 bytes docs/site/media/themes/solarium.png | Bin 0 -> 53372 bytes docs/site/media/themes/solarized_dark.png | Bin 0 -> 52667 bytes docs/site/media/themes/solarized_light.png | Bin 0 -> 53850 bytes docs/site/media/themes/spectrum.png | Bin 0 -> 53539 bytes docs/site/media/themes/themes.toml | 347 ++++++++++++++++++- docs/site/media/themes/tokyobones_dark.png | Bin 0 -> 56620 bytes docs/site/media/themes/tokyobones_light.png | Bin 0 -> 55257 bytes docs/site/media/themes/tokyonight_day.png | Bin 0 -> 51489 bytes docs/site/media/themes/tokyonight_moon.png | Bin 0 -> 53770 bytes docs/site/media/themes/tokyonight_night.png | Bin 0 -> 54672 bytes docs/site/media/themes/tokyonight_storm.png | Bin 0 -> 53382 bytes docs/site/media/themes/vimbones.png | Bin 0 -> 55104 bytes docs/site/media/themes/zenbones_dark.png | Bin 0 -> 56055 bytes docs/site/media/themes/zenbones_light.png | Bin 0 -> 54982 bytes docs/site/media/themes/zenburned.png | Bin 0 -> 55739 bytes docs/site/media/themes/zenwritten_dark.png | Bin 0 -> 54856 bytes docs/site/media/themes/zenwritten_light.png | Bin 0 -> 55139 bytes test/record_demos.py | 407 +++++++++++++++++++---- 104 files changed, 716 insertions(+), 64 deletions(-) create mode 100644 docs/site/media/image-pane.mp4 create mode 100644 docs/site/media/image-pane.png create mode 100644 docs/site/media/image-pane.webm create mode 100644 docs/site/media/pdf-navigation.mp4 create mode 100644 docs/site/media/pdf-navigation.png create mode 100644 docs/site/media/pdf-navigation.webm create mode 100644 docs/site/media/pdf-tint-fit.mp4 create mode 100644 docs/site/media/pdf-tint-fit.png create mode 100644 docs/site/media/pdf-tint-fit.webm create mode 100644 docs/site/media/themes/acme.png create mode 100644 docs/site/media/themes/alucard.png create mode 100644 docs/site/media/themes/atelier.png create mode 100644 docs/site/media/themes/ayu_dark.png create mode 100644 docs/site/media/themes/ayu_light.png create mode 100644 docs/site/media/themes/ayu_mirage.png create mode 100644 docs/site/media/themes/catppuccin_frappe.png create mode 100644 docs/site/media/themes/catppuccin_latte.png create mode 100644 docs/site/media/themes/catppuccin_macchiato.png create mode 100644 docs/site/media/themes/catppuccin_mocha.png create mode 100644 docs/site/media/themes/clay.png create mode 100644 docs/site/media/themes/dark.png create mode 100644 docs/site/media/themes/dark_plus.png create mode 100644 docs/site/media/themes/daybreak.png create mode 100644 docs/site/media/themes/doom_one.png create mode 100644 docs/site/media/themes/doom_one_light.png create mode 100644 docs/site/media/themes/dracula.png create mode 100644 docs/site/media/themes/dracula_soft.png create mode 100644 docs/site/media/themes/duckbones.png create mode 100644 docs/site/media/themes/dusk.png create mode 100644 docs/site/media/themes/forestbones_dark.png create mode 100644 docs/site/media/themes/forestbones_light.png create mode 100644 docs/site/media/themes/forge.png create mode 100644 docs/site/media/themes/forge_black.png create mode 100644 docs/site/media/themes/forge_soft.png create mode 100644 docs/site/media/themes/harvest.png create mode 100644 docs/site/media/themes/helix.png create mode 100644 docs/site/media/themes/ink.png create mode 100644 docs/site/media/themes/kanagawabones.png create mode 100644 docs/site/media/themes/lagoon.png create mode 100644 docs/site/media/themes/lapis.png create mode 100644 docs/site/media/themes/lapis_plain.png create mode 100644 docs/site/media/themes/monokai.png create mode 100644 docs/site/media/themes/monokai_pro.png create mode 100644 docs/site/media/themes/monokai_pro_classic.png create mode 100644 docs/site/media/themes/monokai_pro_light.png create mode 100644 docs/site/media/themes/monokai_pro_light_sun.png create mode 100644 docs/site/media/themes/monokai_pro_machine.png create mode 100644 docs/site/media/themes/monokai_pro_octagon.png create mode 100644 docs/site/media/themes/monokai_pro_ristretto.png create mode 100644 docs/site/media/themes/monokai_pro_spectrum.png create mode 100644 docs/site/media/themes/neobones_dark.png create mode 100644 docs/site/media/themes/neobones_light.png create mode 100644 docs/site/media/themes/nord.png create mode 100644 docs/site/media/themes/nordbones.png create mode 100644 docs/site/media/themes/orchard.png create mode 100644 docs/site/media/themes/orchard_black.png create mode 100644 docs/site/media/themes/paper.png create mode 100644 docs/site/media/themes/rose_pine.png create mode 100644 docs/site/media/themes/rose_pine_dawn.png create mode 100644 docs/site/media/themes/rose_pine_moon.png create mode 100644 docs/site/media/themes/rosebones_dark.png create mode 100644 docs/site/media/themes/rosebones_light.png create mode 100644 docs/site/media/themes/seoul256_dark_233.png create mode 100644 docs/site/media/themes/seoul256_dark_234.png create mode 100644 docs/site/media/themes/seoul256_dark_235.png create mode 100644 docs/site/media/themes/seoul256_dark_236.png create mode 100644 docs/site/media/themes/seoul256_dark_237.png create mode 100644 docs/site/media/themes/seoul256_dark_238.png create mode 100644 docs/site/media/themes/seoul256_dark_239.png create mode 100644 docs/site/media/themes/seoul256_light_252.png create mode 100644 docs/site/media/themes/seoul256_light_253.png create mode 100644 docs/site/media/themes/seoul256_light_254.png create mode 100644 docs/site/media/themes/seoul256_light_255.png create mode 100644 docs/site/media/themes/seoul256_light_256.png create mode 100644 docs/site/media/themes/seoulbones_dark.png create mode 100644 docs/site/media/themes/seoulbones_light.png create mode 100644 docs/site/media/themes/solarium.png create mode 100644 docs/site/media/themes/solarized_dark.png create mode 100644 docs/site/media/themes/solarized_light.png create mode 100644 docs/site/media/themes/spectrum.png create mode 100644 docs/site/media/themes/tokyobones_dark.png create mode 100644 docs/site/media/themes/tokyobones_light.png create mode 100644 docs/site/media/themes/tokyonight_day.png create mode 100644 docs/site/media/themes/tokyonight_moon.png create mode 100644 docs/site/media/themes/tokyonight_night.png create mode 100644 docs/site/media/themes/tokyonight_storm.png create mode 100644 docs/site/media/themes/vimbones.png create mode 100644 docs/site/media/themes/zenbones_dark.png create mode 100644 docs/site/media/themes/zenbones_light.png create mode 100644 docs/site/media/themes/zenburned.png create mode 100644 docs/site/media/themes/zenwritten_dark.png create mode 100644 docs/site/media/themes/zenwritten_light.png (limited to 'test/record_demos.py') diff --git a/docs/site/media/captions.txt b/docs/site/media/captions.txt index 55f64d5b..73ad850c 100644 --- a/docs/site/media/captions.txt +++ b/docs/site/media/captions.txt @@ -1,4 +1,7 @@ -text-is-the-interface: Middle-click runs a word; right-click an error opens the file. -terminals-are-panes: A shell is a pane: Ctrl-b, then move over its output. -scripting-over-9p: The session is files: a shell script reads and writes its panes. -diff-review: git diff pages into a pane; right-click a change to open it. +text-is-the-interface: Middle-click runs a word; right-click an error opens its line. +terminals-are-panes: A terminal is a pane: Ctrl-b, then move over its output. +scripting-over-9p: A script drives the session through its virtual filesystem (9P). +diff-review: Right-click a diff line to open that line of the file. +pdf-navigation: A 2,515-page PDF: page, jump to CPUID, search, step hits. +pdf-tint-fit: PdfTint tints the page, PdfFit fits it, a page address jumps. +image-pane: Right-click a picture's name to open it; Petscii redraws it. diff --git a/docs/site/media/clips.toml b/docs/site/media/clips.toml index 9a83d681..3ce07fa3 100644 --- a/docs/site/media/clips.toml +++ b/docs/site/media/clips.toml @@ -23,3 +23,18 @@ ready = true name = "diff-review" caption = "Right-click a diff line to open that line of the file." ready = true + +[[clip]] +name = "pdf-navigation" +caption = "A 2,515-page PDF: page, jump to CPUID, search, step hits." +ready = true + +[[clip]] +name = "pdf-tint-fit" +caption = "PdfTint tints the page, PdfFit fits it, a page address jumps." +ready = true + +[[clip]] +name = "image-pane" +caption = "Right-click a picture's name to open it; Petscii redraws it." +ready = true diff --git a/docs/site/media/diff-review.mp4 b/docs/site/media/diff-review.mp4 index e3bb2f5b..73fa1a76 100644 Binary files a/docs/site/media/diff-review.mp4 and b/docs/site/media/diff-review.mp4 differ diff --git a/docs/site/media/diff-review.png b/docs/site/media/diff-review.png index fda184e3..76a7dc43 100644 Binary files a/docs/site/media/diff-review.png and b/docs/site/media/diff-review.png differ diff --git a/docs/site/media/diff-review.webm b/docs/site/media/diff-review.webm index ed201b13..da7756f9 100644 Binary files a/docs/site/media/diff-review.webm and b/docs/site/media/diff-review.webm differ diff --git a/docs/site/media/image-pane.mp4 b/docs/site/media/image-pane.mp4 new file mode 100644 index 00000000..de60b945 Binary files /dev/null and b/docs/site/media/image-pane.mp4 differ diff --git a/docs/site/media/image-pane.png b/docs/site/media/image-pane.png new file mode 100644 index 00000000..3f77e2ac Binary files /dev/null and b/docs/site/media/image-pane.png differ diff --git a/docs/site/media/image-pane.webm b/docs/site/media/image-pane.webm new file mode 100644 index 00000000..46de130b Binary files /dev/null and b/docs/site/media/image-pane.webm differ diff --git a/docs/site/media/pdf-navigation.mp4 b/docs/site/media/pdf-navigation.mp4 new file mode 100644 index 00000000..f0369f7b Binary files /dev/null and b/docs/site/media/pdf-navigation.mp4 differ diff --git a/docs/site/media/pdf-navigation.png b/docs/site/media/pdf-navigation.png new file mode 100644 index 00000000..79dd6453 Binary files /dev/null and b/docs/site/media/pdf-navigation.png differ diff --git a/docs/site/media/pdf-navigation.webm b/docs/site/media/pdf-navigation.webm new file mode 100644 index 00000000..17c8b1b3 Binary files /dev/null and b/docs/site/media/pdf-navigation.webm differ diff --git a/docs/site/media/pdf-tint-fit.mp4 b/docs/site/media/pdf-tint-fit.mp4 new file mode 100644 index 00000000..a1b4a5a6 Binary files /dev/null and b/docs/site/media/pdf-tint-fit.mp4 differ diff --git a/docs/site/media/pdf-tint-fit.png b/docs/site/media/pdf-tint-fit.png new file mode 100644 index 00000000..923ab143 Binary files /dev/null and b/docs/site/media/pdf-tint-fit.png differ diff --git a/docs/site/media/pdf-tint-fit.webm b/docs/site/media/pdf-tint-fit.webm new file mode 100644 index 00000000..e641101f Binary files /dev/null and b/docs/site/media/pdf-tint-fit.webm differ diff --git a/docs/site/media/scripting-over-9p.webm b/docs/site/media/scripting-over-9p.webm index b6f192b3..bf39a7e8 100644 Binary files a/docs/site/media/scripting-over-9p.webm and b/docs/site/media/scripting-over-9p.webm differ diff --git a/docs/site/media/terminals-are-panes.webm b/docs/site/media/terminals-are-panes.webm index 3f1ab09e..15ee73fe 100644 Binary files a/docs/site/media/terminals-are-panes.webm and b/docs/site/media/terminals-are-panes.webm differ diff --git a/docs/site/media/text-is-the-interface.mp4 b/docs/site/media/text-is-the-interface.mp4 index 19545731..253d1f39 100644 Binary files a/docs/site/media/text-is-the-interface.mp4 and b/docs/site/media/text-is-the-interface.mp4 differ diff --git a/docs/site/media/text-is-the-interface.png b/docs/site/media/text-is-the-interface.png index 81a73aee..b0d40b15 100644 Binary files a/docs/site/media/text-is-the-interface.png and b/docs/site/media/text-is-the-interface.png differ diff --git a/docs/site/media/text-is-the-interface.webm b/docs/site/media/text-is-the-interface.webm index 88c02d11..07cf62e6 100644 Binary files a/docs/site/media/text-is-the-interface.webm and b/docs/site/media/text-is-the-interface.webm differ diff --git a/docs/site/media/themes/acme.png b/docs/site/media/themes/acme.png new file mode 100644 index 00000000..da647db1 Binary files /dev/null and b/docs/site/media/themes/acme.png differ diff --git a/docs/site/media/themes/alucard.png b/docs/site/media/themes/alucard.png new file mode 100644 index 00000000..dab6ce80 Binary files /dev/null and b/docs/site/media/themes/alucard.png differ diff --git a/docs/site/media/themes/atelier.png b/docs/site/media/themes/atelier.png new file mode 100644 index 00000000..a8c36f2a Binary files /dev/null and b/docs/site/media/themes/atelier.png differ diff --git a/docs/site/media/themes/ayu_dark.png b/docs/site/media/themes/ayu_dark.png new file mode 100644 index 00000000..711ed8aa Binary files /dev/null and b/docs/site/media/themes/ayu_dark.png differ diff --git a/docs/site/media/themes/ayu_light.png b/docs/site/media/themes/ayu_light.png new file mode 100644 index 00000000..0ddcb9af Binary files /dev/null and b/docs/site/media/themes/ayu_light.png differ diff --git a/docs/site/media/themes/ayu_mirage.png b/docs/site/media/themes/ayu_mirage.png new file mode 100644 index 00000000..56676d1f Binary files /dev/null and b/docs/site/media/themes/ayu_mirage.png differ diff --git a/docs/site/media/themes/catppuccin_frappe.png b/docs/site/media/themes/catppuccin_frappe.png new file mode 100644 index 00000000..58c13dbe Binary files /dev/null and b/docs/site/media/themes/catppuccin_frappe.png differ diff --git a/docs/site/media/themes/catppuccin_latte.png b/docs/site/media/themes/catppuccin_latte.png new file mode 100644 index 00000000..27e58ce0 Binary files /dev/null and b/docs/site/media/themes/catppuccin_latte.png differ diff --git a/docs/site/media/themes/catppuccin_macchiato.png b/docs/site/media/themes/catppuccin_macchiato.png new file mode 100644 index 00000000..fb32c742 Binary files /dev/null and b/docs/site/media/themes/catppuccin_macchiato.png differ diff --git a/docs/site/media/themes/catppuccin_mocha.png b/docs/site/media/themes/catppuccin_mocha.png new file mode 100644 index 00000000..e16e4224 Binary files /dev/null and b/docs/site/media/themes/catppuccin_mocha.png differ diff --git a/docs/site/media/themes/clay.png b/docs/site/media/themes/clay.png new file mode 100644 index 00000000..117b731d Binary files /dev/null and b/docs/site/media/themes/clay.png differ diff --git a/docs/site/media/themes/dark.png b/docs/site/media/themes/dark.png new file mode 100644 index 00000000..6346759e Binary files /dev/null and b/docs/site/media/themes/dark.png differ diff --git a/docs/site/media/themes/dark_plus.png b/docs/site/media/themes/dark_plus.png new file mode 100644 index 00000000..6a750655 Binary files /dev/null and b/docs/site/media/themes/dark_plus.png differ diff --git a/docs/site/media/themes/daybreak.png b/docs/site/media/themes/daybreak.png new file mode 100644 index 00000000..ca3dcc5c Binary files /dev/null and b/docs/site/media/themes/daybreak.png differ diff --git a/docs/site/media/themes/doom_one.png b/docs/site/media/themes/doom_one.png new file mode 100644 index 00000000..95f13135 Binary files /dev/null and b/docs/site/media/themes/doom_one.png differ diff --git a/docs/site/media/themes/doom_one_light.png b/docs/site/media/themes/doom_one_light.png new file mode 100644 index 00000000..c8c4c69a Binary files /dev/null and b/docs/site/media/themes/doom_one_light.png differ diff --git a/docs/site/media/themes/dracula.png b/docs/site/media/themes/dracula.png new file mode 100644 index 00000000..64eea04a Binary files /dev/null and b/docs/site/media/themes/dracula.png differ diff --git a/docs/site/media/themes/dracula_soft.png b/docs/site/media/themes/dracula_soft.png new file mode 100644 index 00000000..9ef81583 Binary files /dev/null and b/docs/site/media/themes/dracula_soft.png differ diff --git a/docs/site/media/themes/duckbones.png b/docs/site/media/themes/duckbones.png new file mode 100644 index 00000000..9809ab36 Binary files /dev/null and b/docs/site/media/themes/duckbones.png differ diff --git a/docs/site/media/themes/dusk.png b/docs/site/media/themes/dusk.png new file mode 100644 index 00000000..0d95b59c Binary files /dev/null and b/docs/site/media/themes/dusk.png differ diff --git a/docs/site/media/themes/forestbones_dark.png b/docs/site/media/themes/forestbones_dark.png new file mode 100644 index 00000000..ea399605 Binary files /dev/null and b/docs/site/media/themes/forestbones_dark.png differ diff --git a/docs/site/media/themes/forestbones_light.png b/docs/site/media/themes/forestbones_light.png new file mode 100644 index 00000000..862858de Binary files /dev/null and b/docs/site/media/themes/forestbones_light.png differ diff --git a/docs/site/media/themes/forge.png b/docs/site/media/themes/forge.png new file mode 100644 index 00000000..bab91d48 Binary files /dev/null and b/docs/site/media/themes/forge.png differ diff --git a/docs/site/media/themes/forge_black.png b/docs/site/media/themes/forge_black.png new file mode 100644 index 00000000..e09320ed Binary files /dev/null and b/docs/site/media/themes/forge_black.png differ diff --git a/docs/site/media/themes/forge_soft.png b/docs/site/media/themes/forge_soft.png new file mode 100644 index 00000000..1b9fb2fb Binary files /dev/null and b/docs/site/media/themes/forge_soft.png differ diff --git a/docs/site/media/themes/harvest.png b/docs/site/media/themes/harvest.png new file mode 100644 index 00000000..b95e8c76 Binary files /dev/null and b/docs/site/media/themes/harvest.png differ diff --git a/docs/site/media/themes/helix.png b/docs/site/media/themes/helix.png new file mode 100644 index 00000000..6c353815 Binary files /dev/null and b/docs/site/media/themes/helix.png differ diff --git a/docs/site/media/themes/ink.png b/docs/site/media/themes/ink.png new file mode 100644 index 00000000..314610db Binary files /dev/null and b/docs/site/media/themes/ink.png differ diff --git a/docs/site/media/themes/kanagawabones.png b/docs/site/media/themes/kanagawabones.png new file mode 100644 index 00000000..c2c58ec9 Binary files /dev/null and b/docs/site/media/themes/kanagawabones.png differ diff --git a/docs/site/media/themes/lagoon.png b/docs/site/media/themes/lagoon.png new file mode 100644 index 00000000..bdd3dd49 Binary files /dev/null and b/docs/site/media/themes/lagoon.png differ diff --git a/docs/site/media/themes/lapis.png b/docs/site/media/themes/lapis.png new file mode 100644 index 00000000..2bc4024a Binary files /dev/null and b/docs/site/media/themes/lapis.png differ diff --git a/docs/site/media/themes/lapis_plain.png b/docs/site/media/themes/lapis_plain.png new file mode 100644 index 00000000..7315c2a0 Binary files /dev/null and b/docs/site/media/themes/lapis_plain.png differ diff --git a/docs/site/media/themes/monokai.png b/docs/site/media/themes/monokai.png new file mode 100644 index 00000000..4b4854b8 Binary files /dev/null and b/docs/site/media/themes/monokai.png differ diff --git a/docs/site/media/themes/monokai_pro.png b/docs/site/media/themes/monokai_pro.png new file mode 100644 index 00000000..e8036053 Binary files /dev/null and b/docs/site/media/themes/monokai_pro.png differ diff --git a/docs/site/media/themes/monokai_pro_classic.png b/docs/site/media/themes/monokai_pro_classic.png new file mode 100644 index 00000000..4e25319c Binary files /dev/null and b/docs/site/media/themes/monokai_pro_classic.png differ diff --git a/docs/site/media/themes/monokai_pro_light.png b/docs/site/media/themes/monokai_pro_light.png new file mode 100644 index 00000000..ee2f1e4c Binary files /dev/null and b/docs/site/media/themes/monokai_pro_light.png differ diff --git a/docs/site/media/themes/monokai_pro_light_sun.png b/docs/site/media/themes/monokai_pro_light_sun.png new file mode 100644 index 00000000..67e6e807 Binary files /dev/null and b/docs/site/media/themes/monokai_pro_light_sun.png differ diff --git a/docs/site/media/themes/monokai_pro_machine.png b/docs/site/media/themes/monokai_pro_machine.png new file mode 100644 index 00000000..3f683a68 Binary files /dev/null and b/docs/site/media/themes/monokai_pro_machine.png differ diff --git a/docs/site/media/themes/monokai_pro_octagon.png b/docs/site/media/themes/monokai_pro_octagon.png new file mode 100644 index 00000000..bc7a831e Binary files /dev/null and b/docs/site/media/themes/monokai_pro_octagon.png differ diff --git a/docs/site/media/themes/monokai_pro_ristretto.png b/docs/site/media/themes/monokai_pro_ristretto.png new file mode 100644 index 00000000..06429245 Binary files /dev/null and b/docs/site/media/themes/monokai_pro_ristretto.png differ diff --git a/docs/site/media/themes/monokai_pro_spectrum.png b/docs/site/media/themes/monokai_pro_spectrum.png new file mode 100644 index 00000000..c6e49f4c Binary files /dev/null and b/docs/site/media/themes/monokai_pro_spectrum.png differ diff --git a/docs/site/media/themes/neobones_dark.png b/docs/site/media/themes/neobones_dark.png new file mode 100644 index 00000000..026400de Binary files /dev/null and b/docs/site/media/themes/neobones_dark.png differ diff --git a/docs/site/media/themes/neobones_light.png b/docs/site/media/themes/neobones_light.png new file mode 100644 index 00000000..62d26b3a Binary files /dev/null and b/docs/site/media/themes/neobones_light.png differ diff --git a/docs/site/media/themes/nord.png b/docs/site/media/themes/nord.png new file mode 100644 index 00000000..d5c903b2 Binary files /dev/null and b/docs/site/media/themes/nord.png differ diff --git a/docs/site/media/themes/nordbones.png b/docs/site/media/themes/nordbones.png new file mode 100644 index 00000000..272ad19d Binary files /dev/null and b/docs/site/media/themes/nordbones.png differ diff --git a/docs/site/media/themes/orchard.png b/docs/site/media/themes/orchard.png new file mode 100644 index 00000000..623fde75 Binary files /dev/null and b/docs/site/media/themes/orchard.png differ diff --git a/docs/site/media/themes/orchard_black.png b/docs/site/media/themes/orchard_black.png new file mode 100644 index 00000000..02d78992 Binary files /dev/null and b/docs/site/media/themes/orchard_black.png differ diff --git a/docs/site/media/themes/paper.png b/docs/site/media/themes/paper.png new file mode 100644 index 00000000..59919d80 Binary files /dev/null and b/docs/site/media/themes/paper.png differ diff --git a/docs/site/media/themes/rose_pine.png b/docs/site/media/themes/rose_pine.png new file mode 100644 index 00000000..9dbf1d76 Binary files /dev/null and b/docs/site/media/themes/rose_pine.png differ diff --git a/docs/site/media/themes/rose_pine_dawn.png b/docs/site/media/themes/rose_pine_dawn.png new file mode 100644 index 00000000..8a062630 Binary files /dev/null and b/docs/site/media/themes/rose_pine_dawn.png differ diff --git a/docs/site/media/themes/rose_pine_moon.png b/docs/site/media/themes/rose_pine_moon.png new file mode 100644 index 00000000..ee93f871 Binary files /dev/null and b/docs/site/media/themes/rose_pine_moon.png differ diff --git a/docs/site/media/themes/rosebones_dark.png b/docs/site/media/themes/rosebones_dark.png new file mode 100644 index 00000000..19992fea Binary files /dev/null and b/docs/site/media/themes/rosebones_dark.png differ diff --git a/docs/site/media/themes/rosebones_light.png b/docs/site/media/themes/rosebones_light.png new file mode 100644 index 00000000..a879dc55 Binary files /dev/null and b/docs/site/media/themes/rosebones_light.png differ diff --git a/docs/site/media/themes/seoul256_dark_233.png b/docs/site/media/themes/seoul256_dark_233.png new file mode 100644 index 00000000..a757640b Binary files /dev/null and b/docs/site/media/themes/seoul256_dark_233.png differ diff --git a/docs/site/media/themes/seoul256_dark_234.png b/docs/site/media/themes/seoul256_dark_234.png new file mode 100644 index 00000000..a34b3f2a Binary files /dev/null and b/docs/site/media/themes/seoul256_dark_234.png differ diff --git a/docs/site/media/themes/seoul256_dark_235.png b/docs/site/media/themes/seoul256_dark_235.png new file mode 100644 index 00000000..d4c69938 Binary files /dev/null and b/docs/site/media/themes/seoul256_dark_235.png differ diff --git a/docs/site/media/themes/seoul256_dark_236.png b/docs/site/media/themes/seoul256_dark_236.png new file mode 100644 index 00000000..8f1c48ce Binary files /dev/null and b/docs/site/media/themes/seoul256_dark_236.png differ diff --git a/docs/site/media/themes/seoul256_dark_237.png b/docs/site/media/themes/seoul256_dark_237.png new file mode 100644 index 00000000..3816b258 Binary files /dev/null and b/docs/site/media/themes/seoul256_dark_237.png differ diff --git a/docs/site/media/themes/seoul256_dark_238.png b/docs/site/media/themes/seoul256_dark_238.png new file mode 100644 index 00000000..9553da5f Binary files /dev/null and b/docs/site/media/themes/seoul256_dark_238.png differ diff --git a/docs/site/media/themes/seoul256_dark_239.png b/docs/site/media/themes/seoul256_dark_239.png new file mode 100644 index 00000000..8109f756 Binary files /dev/null and b/docs/site/media/themes/seoul256_dark_239.png differ diff --git a/docs/site/media/themes/seoul256_light_252.png b/docs/site/media/themes/seoul256_light_252.png new file mode 100644 index 00000000..7f01a1ab Binary files /dev/null and b/docs/site/media/themes/seoul256_light_252.png differ diff --git a/docs/site/media/themes/seoul256_light_253.png b/docs/site/media/themes/seoul256_light_253.png new file mode 100644 index 00000000..5b9d2a43 Binary files /dev/null and b/docs/site/media/themes/seoul256_light_253.png differ diff --git a/docs/site/media/themes/seoul256_light_254.png b/docs/site/media/themes/seoul256_light_254.png new file mode 100644 index 00000000..125546f7 Binary files /dev/null and b/docs/site/media/themes/seoul256_light_254.png differ diff --git a/docs/site/media/themes/seoul256_light_255.png b/docs/site/media/themes/seoul256_light_255.png new file mode 100644 index 00000000..06b1e3fc Binary files /dev/null and b/docs/site/media/themes/seoul256_light_255.png differ diff --git a/docs/site/media/themes/seoul256_light_256.png b/docs/site/media/themes/seoul256_light_256.png new file mode 100644 index 00000000..ce4ee4da Binary files /dev/null and b/docs/site/media/themes/seoul256_light_256.png differ diff --git a/docs/site/media/themes/seoulbones_dark.png b/docs/site/media/themes/seoulbones_dark.png new file mode 100644 index 00000000..74ea8ebc Binary files /dev/null and b/docs/site/media/themes/seoulbones_dark.png differ diff --git a/docs/site/media/themes/seoulbones_light.png b/docs/site/media/themes/seoulbones_light.png new file mode 100644 index 00000000..7591721a Binary files /dev/null and b/docs/site/media/themes/seoulbones_light.png differ diff --git a/docs/site/media/themes/solarium.png b/docs/site/media/themes/solarium.png new file mode 100644 index 00000000..f24a111e Binary files /dev/null and b/docs/site/media/themes/solarium.png differ diff --git a/docs/site/media/themes/solarized_dark.png b/docs/site/media/themes/solarized_dark.png new file mode 100644 index 00000000..7df0ef41 Binary files /dev/null and b/docs/site/media/themes/solarized_dark.png differ diff --git a/docs/site/media/themes/solarized_light.png b/docs/site/media/themes/solarized_light.png new file mode 100644 index 00000000..40b88ef3 Binary files /dev/null and b/docs/site/media/themes/solarized_light.png differ diff --git a/docs/site/media/themes/spectrum.png b/docs/site/media/themes/spectrum.png new file mode 100644 index 00000000..111f0913 Binary files /dev/null and b/docs/site/media/themes/spectrum.png differ diff --git a/docs/site/media/themes/themes.toml b/docs/site/media/themes/themes.toml index 23df1e97..ed45b075 100644 --- a/docs/site/media/themes/themes.toml +++ b/docs/site/media/themes/themes.toml @@ -1,7 +1,6 @@ -# The Themes page gallery, in NextColor's order: media/themes/ for -# each. `ready = false` shows placeholder.svg under each name, so the site -# builds before the screenshots exist; set it true (or drop it) once they do. -ready = false +# The Themes page gallery, in the order the Themes builtin walks them: +# media/themes/ for each, made by test/record_demos.py themes. +ready = true [[theme]] name = "orchard" @@ -77,3 +76,343 @@ kind = "dark" name = "orchard_black" file = "orchard_black.png" kind = "dark" + +[[theme]] +name = "acme" +file = "acme.png" +kind = "light" + +[[theme]] +name = "lapis" +file = "lapis.png" +kind = "dark" + +[[theme]] +name = "lapis_plain" +file = "lapis_plain.png" +kind = "dark" + +[[theme]] +name = "dark_plus" +file = "dark_plus.png" +kind = "dark" + +[[theme]] +name = "solarized_dark" +file = "solarized_dark.png" +kind = "dark" + +[[theme]] +name = "solarized_light" +file = "solarized_light.png" +kind = "light" + +[[theme]] +name = "dracula" +file = "dracula.png" +kind = "dark" + +[[theme]] +name = "dracula_soft" +file = "dracula_soft.png" +kind = "dark" + +[[theme]] +name = "alucard" +file = "alucard.png" +kind = "light" + +[[theme]] +name = "monokai" +file = "monokai.png" +kind = "dark" + +[[theme]] +name = "monokai_pro" +file = "monokai_pro.png" +kind = "dark" + +[[theme]] +name = "monokai_pro_classic" +file = "monokai_pro_classic.png" +kind = "dark" + +[[theme]] +name = "monokai_pro_machine" +file = "monokai_pro_machine.png" +kind = "dark" + +[[theme]] +name = "monokai_pro_octagon" +file = "monokai_pro_octagon.png" +kind = "dark" + +[[theme]] +name = "monokai_pro_ristretto" +file = "monokai_pro_ristretto.png" +kind = "dark" + +[[theme]] +name = "monokai_pro_spectrum" +file = "monokai_pro_spectrum.png" +kind = "dark" + +[[theme]] +name = "monokai_pro_light" +file = "monokai_pro_light.png" +kind = "light" + +[[theme]] +name = "monokai_pro_light_sun" +file = "monokai_pro_light_sun.png" +kind = "light" + +[[theme]] +name = "tokyonight_night" +file = "tokyonight_night.png" +kind = "dark" + +[[theme]] +name = "tokyonight_storm" +file = "tokyonight_storm.png" +kind = "dark" + +[[theme]] +name = "tokyonight_moon" +file = "tokyonight_moon.png" +kind = "dark" + +[[theme]] +name = "tokyonight_day" +file = "tokyonight_day.png" +kind = "light" + +[[theme]] +name = "rose_pine" +file = "rose_pine.png" +kind = "dark" + +[[theme]] +name = "rose_pine_moon" +file = "rose_pine_moon.png" +kind = "dark" + +[[theme]] +name = "rose_pine_dawn" +file = "rose_pine_dawn.png" +kind = "light" + +[[theme]] +name = "catppuccin_latte" +file = "catppuccin_latte.png" +kind = "light" + +[[theme]] +name = "catppuccin_frappe" +file = "catppuccin_frappe.png" +kind = "dark" + +[[theme]] +name = "catppuccin_macchiato" +file = "catppuccin_macchiato.png" +kind = "dark" + +[[theme]] +name = "catppuccin_mocha" +file = "catppuccin_mocha.png" +kind = "dark" + +[[theme]] +name = "seoul256_dark_233" +file = "seoul256_dark_233.png" +kind = "dark" + +[[theme]] +name = "seoul256_dark_234" +file = "seoul256_dark_234.png" +kind = "dark" + +[[theme]] +name = "seoul256_dark_235" +file = "seoul256_dark_235.png" +kind = "dark" + +[[theme]] +name = "seoul256_dark_236" +file = "seoul256_dark_236.png" +kind = "dark" + +[[theme]] +name = "seoul256_dark_237" +file = "seoul256_dark_237.png" +kind = "dark" + +[[theme]] +name = "seoul256_dark_238" +file = "seoul256_dark_238.png" +kind = "dark" + +[[theme]] +name = "seoul256_dark_239" +file = "seoul256_dark_239.png" +kind = "dark" + +[[theme]] +name = "seoul256_light_252" +file = "seoul256_light_252.png" +kind = "light" + +[[theme]] +name = "seoul256_light_253" +file = "seoul256_light_253.png" +kind = "light" + +[[theme]] +name = "seoul256_light_254" +file = "seoul256_light_254.png" +kind = "light" + +[[theme]] +name = "seoul256_light_255" +file = "seoul256_light_255.png" +kind = "light" + +[[theme]] +name = "seoul256_light_256" +file = "seoul256_light_256.png" +kind = "light" + +[[theme]] +name = "zenbones_light" +file = "zenbones_light.png" +kind = "light" + +[[theme]] +name = "zenbones_dark" +file = "zenbones_dark.png" +kind = "dark" + +[[theme]] +name = "neobones_light" +file = "neobones_light.png" +kind = "light" + +[[theme]] +name = "neobones_dark" +file = "neobones_dark.png" +kind = "dark" + +[[theme]] +name = "vimbones" +file = "vimbones.png" +kind = "light" + +[[theme]] +name = "forestbones_light" +file = "forestbones_light.png" +kind = "light" + +[[theme]] +name = "forestbones_dark" +file = "forestbones_dark.png" +kind = "dark" + +[[theme]] +name = "nordbones" +file = "nordbones.png" +kind = "dark" + +[[theme]] +name = "rosebones_light" +file = "rosebones_light.png" +kind = "light" + +[[theme]] +name = "rosebones_dark" +file = "rosebones_dark.png" +kind = "dark" + +[[theme]] +name = "tokyobones_light" +file = "tokyobones_light.png" +kind = "light" + +[[theme]] +name = "tokyobones_dark" +file = "tokyobones_dark.png" +kind = "dark" + +[[theme]] +name = "seoulbones_light" +file = "seoulbones_light.png" +kind = "light" + +[[theme]] +name = "seoulbones_dark" +file = "seoulbones_dark.png" +kind = "dark" + +[[theme]] +name = "duckbones" +file = "duckbones.png" +kind = "dark" + +[[theme]] +name = "zenburned" +file = "zenburned.png" +kind = "dark" + +[[theme]] +name = "zenwritten_light" +file = "zenwritten_light.png" +kind = "light" + +[[theme]] +name = "zenwritten_dark" +file = "zenwritten_dark.png" +kind = "dark" + +[[theme]] +name = "kanagawabones" +file = "kanagawabones.png" +kind = "dark" + +[[theme]] +name = "nord" +file = "nord.png" +kind = "dark" + +[[theme]] +name = "ayu_dark" +file = "ayu_dark.png" +kind = "dark" + +[[theme]] +name = "ayu_mirage" +file = "ayu_mirage.png" +kind = "dark" + +[[theme]] +name = "ayu_light" +file = "ayu_light.png" +kind = "light" + +[[theme]] +name = "doom_one" +file = "doom_one.png" +kind = "dark" + +[[theme]] +name = "doom_one_light" +file = "doom_one_light.png" +kind = "light" + +[[theme]] +name = "helix" +file = "helix.png" +kind = "dark" + +[[theme]] +name = "dark" +file = "dark.png" +kind = "dark" diff --git a/docs/site/media/themes/tokyobones_dark.png b/docs/site/media/themes/tokyobones_dark.png new file mode 100644 index 00000000..f873726d Binary files /dev/null and b/docs/site/media/themes/tokyobones_dark.png differ diff --git a/docs/site/media/themes/tokyobones_light.png b/docs/site/media/themes/tokyobones_light.png new file mode 100644 index 00000000..211a30ff Binary files /dev/null and b/docs/site/media/themes/tokyobones_light.png differ diff --git a/docs/site/media/themes/tokyonight_day.png b/docs/site/media/themes/tokyonight_day.png new file mode 100644 index 00000000..cdbef103 Binary files /dev/null and b/docs/site/media/themes/tokyonight_day.png differ diff --git a/docs/site/media/themes/tokyonight_moon.png b/docs/site/media/themes/tokyonight_moon.png new file mode 100644 index 00000000..d35bf419 Binary files /dev/null and b/docs/site/media/themes/tokyonight_moon.png differ diff --git a/docs/site/media/themes/tokyonight_night.png b/docs/site/media/themes/tokyonight_night.png new file mode 100644 index 00000000..5497275b Binary files /dev/null and b/docs/site/media/themes/tokyonight_night.png differ diff --git a/docs/site/media/themes/tokyonight_storm.png b/docs/site/media/themes/tokyonight_storm.png new file mode 100644 index 00000000..5e62b9e2 Binary files /dev/null and b/docs/site/media/themes/tokyonight_storm.png differ diff --git a/docs/site/media/themes/vimbones.png b/docs/site/media/themes/vimbones.png new file mode 100644 index 00000000..134fd582 Binary files /dev/null and b/docs/site/media/themes/vimbones.png differ diff --git a/docs/site/media/themes/zenbones_dark.png b/docs/site/media/themes/zenbones_dark.png new file mode 100644 index 00000000..d7e8315c Binary files /dev/null and b/docs/site/media/themes/zenbones_dark.png differ diff --git a/docs/site/media/themes/zenbones_light.png b/docs/site/media/themes/zenbones_light.png new file mode 100644 index 00000000..22c2da48 Binary files /dev/null and b/docs/site/media/themes/zenbones_light.png differ diff --git a/docs/site/media/themes/zenburned.png b/docs/site/media/themes/zenburned.png new file mode 100644 index 00000000..3b97815b Binary files /dev/null and b/docs/site/media/themes/zenburned.png differ diff --git a/docs/site/media/themes/zenwritten_dark.png b/docs/site/media/themes/zenwritten_dark.png new file mode 100644 index 00000000..6421245f Binary files /dev/null and b/docs/site/media/themes/zenwritten_dark.png differ diff --git a/docs/site/media/themes/zenwritten_light.png b/docs/site/media/themes/zenwritten_light.png new file mode 100644 index 00000000..28f3a144 Binary files /dev/null and b/docs/site/media/themes/zenwritten_light.png differ diff --git a/test/record_demos.py b/test/record_demos.py index 655ec475..71bf1055 100644 --- a/test/record_demos.py +++ b/test/record_demos.py @@ -1,16 +1,23 @@ #!/usr/bin/env python3 -"""Record the documentation site's landing-page clips from a hidden window. +"""Record the documentation site's clips and theme shots from a hidden window. zig build -Dplatform=gui -Doptimize=ReleaseSafe --prefix -python3 -B test/record_demos.py /bin/pardes-gui [clip ...] +python3 -B test/record_demos.py /bin/pardes-gui [clip ... | themes] Each clip drives a throwaway session (PARDES_TEST: an offscreen capture, the virtual clock) through its stdin's window-pixel mouse events, its keys and its 9P files, keeps the settled frame after every step, and lays the -frames out on a timeline with a drawn pointer. ffmpeg encodes the timeline -to docs/site/media/.webm and .mp4, with .png as its poster and -captions.txt beside them. Needs a Wayland display for the hidden window, -gcc and git for the demo project, and 9ns (cloud9) for the scripting clip. +frames out on a timeline with a drawn pointer: a click glides there, +stops, and presses and releases still, a ring and the button's name drawn. +ffmpeg encodes the timeline to docs/site/media/.webm and .mp4, with +.png as its poster and captions.txt beside them (clips.toml, which +the site reads, is kept by hand). `themes` instead writes +docs/site/media/themes/.png for each theme of src/themes, in the +Themes builtin's order, and themes.toml. + +Needs a Wayland display for the hidden window, gcc and git for the demo +project, 9ns (cloud9) for the scripting clip, Pillow and numpy, and the +Intel SDM vol. 2 for the PDF clips (--pdf; read where it is, never copied). Frames and the intermediate video go under --work (default ../.scratch/rec/work, beside the checkout). The demo project lives at @@ -241,6 +248,19 @@ class Session: cw, ch = w / self.cols, h / self.rows return int(start * cw + (col - start + offset) * TAG_W), int((row + .55) * ch) + def tag_word(self, serial, word): + """The pixel over the middle of `word` in pane `serial`'s tag, which + may run past the grid's columns (/screen cuts a tag at its width, + the window wraps it at its own): its rows hold (width - 3 cells) / + TAG_W characters each.""" + tag = self.tag(serial) + w, h = self.size() + cw, ch = w / self.cols, h / self.rows + per_row = int((w - 3 * cw) // TAG_W) + top = self.find(tag[:min(len(tag), self.cols - 4)], 0)[1] + at = tag.index(word) + len(word) // 2 + return int(3 * cw + (at % per_row + .5) * TAG_W), int((top + at // per_row + .55) * ch) + def size(self): with open(self.caps / 'latest.ppm', 'rb') as f: f.readline() @@ -280,37 +300,43 @@ class Session: # the timeline - def shot(self, seconds, poster=False): + def shot(self, seconds, poster=False, ring=None, ring_button=None): """Hold the settled frame for `seconds`, the pointer where it is. - `poster` marks the frame drawn as the clip's still.""" + `poster` marks the frame drawn as the clip's still; `ring` draws a + click there ('press' while held, 'pulse' just after).""" data = self.settle() path = self.frames / f'{len(self.shots):04d}.ppm' path.write_bytes(data) self.shots.append(dict(frame=path, secs=seconds, start=self.pointer, end=self.pointer, - button=self.button, badge=self.badge, poster=poster)) + button=self.button, badge=self.badge, poster=poster, ring=ring, + ring_button=ring_button or self.button)) def glide(self, x, y, seconds=.6): """Glide the drawn pointer to (x, y) over the frame on screen, then move the window's pointer there (dragging any button held).""" if self.shots and self.pointer is not None: last = self.shots[-1] - self.shots.append(dict(last, secs=seconds, start=self.pointer, end=(x, y), poster=False)) + self.shots.append(dict(last, secs=seconds, start=self.pointer, end=(x, y), poster=False, ring=None)) self.pointer = (x, y) self.mouse('motion', self.button or 0, x, y) - def sweep(self, button, start, end, hold=.5): - """Press `button` (SDL: 1 left, 2 middle, 3 right) at `start`, - drag it to `end` and release: the sweep acme's B2 and B3 take.""" - if self.pointer != start: - self.glide(*start) - self.mouse('down', button, *start) + def click(self, button, x, y, done=None, what='the click', rest=.4, hold=.35, after=1.0): + """Glide to (x, y) and stop; a beat later press `button` (SDL: 1 + left, 2 middle, 3 right) and release it with the pointer still, a + ring and the button's name drawn on the press; once `done()` says + the click took, hold the result `after` seconds, the ring pulsing + out, before anything moves again.""" + if self.pointer != (x, y): + self.glide(x, y) + self.shot(rest) + self.mouse('down', button, x, y) self.button = button - self.shot(.15) - if end != start: - self.glide(*end, seconds=.3) - self.shot(hold) - self.mouse('up', button, *self.pointer) + self.shot(hold, ring='press') + self.mouse('up', button, x, y) self.button = None + if done is not None: + self.wait(done, what) + self.shot(after, ring='pulse', ring_button=button) def press(self, keys, per_key=.4): """Send each (key bytes, badge) of `keys`, a frame a key with the @@ -360,21 +386,31 @@ class Painter: self.font = ImageFont.truetype(str(BADGE_FONT), 24) self.size = size - def paint(self, img, pointer, button, badge): + def paint(self, img, pointer, badge, ring=None, button=None, since=0.0): + """`img` with the badge, the pointer, and a click: `ring` 'press' + (a ring and the button's name) or 'pulse' (`since` seconds after the + release: the ring widening and fading, the name kept a moment).""" img = img.copy() w, h = self.size if badge: draw_badge(img, badge, (w - 16, h - 16), self.font, anchor='rb') if pointer is not None: x, y = pointer - if button: + if ring and button: label, colour = BUTTONS[button] d = ImageDraw.Draw(img, 'RGBA') - r = 16 - d.ellipse((x - r, y - r, x + r, y + r), outline=colour + (255,), width=4) - # The name sits below the pointer, kept inside the frame. - lx = min(x + 22, w - 16 - self.font.getlength(label)) - draw_badge(img, label, (lx, y + 40), self.font, fill=colour) + if ring == 'press': + r, alpha, named = 16, 255, True + else: + t = min(since / .45, 1) + r, alpha, named = 16 + 22 * t, int(255 * (1 - t)), since < .6 + if alpha > 0: + d.ellipse((x - r, y - r, x + r, y + r), outline=colour + (alpha,), width=4) + if named: + # The name sits below the pointer, kept inside the frame. + lx = min(x + 22, w - 16 - self.font.getlength(label)) + ly = y + 40 if y + 70 < h else y - 60 + draw_badge(img, label, (lx, ly), self.font, fill=colour) img.paste(self.sprite, (int(x) - 1, int(y) - 1), self.sprite) return img @@ -409,22 +445,23 @@ def compose(shots, out): n = round(clock * FPS) - emitted for i in range(n): t = ease((i + 1) / n) - frame = painter.paint(img, lerp(shot['start'], shot['end'], t), shot['button'], shot['badge']) + frame = painter.paint(img, lerp(shot['start'], shot['end'], t), shot['badge'], shot['ring'], + shot['ring_button'], i / FPS) ff.stdin.write(frame.tobytes()) if shot['poster'] and poster is None: - poster = painter.paint(img, shot['end'], shot['button'], None) + poster = painter.paint(img, shot['end'], None) emitted += n last = shots[-1] n = round(.7 * FPS) for i in range(n): t = ease((i + 1) / n) frame = Image.blend(loaded[1], first, t) - ff.stdin.write(painter.paint(frame, lerp(last['end'], shots[0]['start'], t), None, None).tobytes()) + ff.stdin.write(painter.paint(frame, lerp(last['end'], shots[0]['start'], t), None).tobytes()) emitted += n ff.stdin.close() if ff.wait() != 0: raise RuntimeError('ffmpeg (lossless) failed') - return emitted / FPS, poster or painter.paint(first, None, None, None) + return emitted / FPS, poster or painter.paint(first, None, None) def encode(lossless, name, poster, crf_webm=30, crf_mp4=20): @@ -447,20 +484,29 @@ def encode(lossless, name, poster, crf_webm=30, crf_mp4=20): # the clips -def text_is_the_interface(s): - """B2 on `make` in a tag runs it; B3 on the error opens the file there.""" +def hero_setup(s): + """README, main.c under it and an output pane under that, all on + screen from the first frame: the output pane is a finished `clear`, + which `make` will reuse.""" + s.write('/pane/1/look', f'{PROJECT}/src/main.c\n') + s.wait(lambda: len(s.panes()) == 2, 'main.c') + s.write('/pane/1/exec', 'clear\n') + s.wait(lambda: any(kind == 'cmd' and 'exit' in s.tag(n) for n, kind in s.panes().items()), 'the output pane') s.write('/pane/1/tag', ' make') + s.mouse('motion', 0, *s.cell_px(36, 9)) + + +def text_is_the_interface(s): + """B2 on `make` in a tag runs it; B3 on the error opens main.c there.""" + output = next(n for n, kind in s.panes().items() if kind == 'cmd') s.pointer = s.cell_px(36, 9) - s.shot(1.0) + s.shot(1.2) col, row = s.find('make', 0) - s.sweep(2, s.tag_px(col, row, offset=.15), s.tag_px(col + 3, row, offset=.85)) - s.wait(lambda: any('exit' in s.tag(n) for n, kind in s.panes().items() if kind == 'cmd'), 'make to finish') - s.shot(1.1) + s.click(2, *s.tag_px(col + 1, row), done=lambda: '(make) exit' in s.tag(output), what='make') col, row = s.find('src/main.c:12:5', 0) - s.sweep(3, s.cell_px(col, row), s.cell_px(col + 14, row)) - s.wait(lambda: len(s.panes()) == 3, 'main.c to open') - s.glide(*s.cell_px(40, 9), seconds=.5) - s.shot(2.6, poster=True) + s.click(3, *s.cell_px(col + 4, row), done=lambda: any(line.startswith(' 12 ') for line in s.screen()[6:12]), + what='main.c at line 12', after=2.8) + s.shots[-1]['poster'] = True def shell_setup(s): @@ -543,32 +589,273 @@ def diff_review(s): s.wait_text('+ printf') s.shot(1.4) col, row = s.find('+ printf', 0) - s.sweep(3, s.cell_px(col, row), s.cell_px(col, row)) - s.wait(lambda: len(s.panes()) == 3, 'main.c to open') - s.glide(*s.cell_px(42, 9), seconds=.5) - s.shot(2.6, poster=True) + s.click(3, *s.cell_px(col, row), done=lambda: len(s.panes()) == 3, what='main.c to open', after=2.6) + s.shots[-1]['poster'] = True + + +def mandelbrot(path, width=1200, height=800): + """The classic view of the Mandelbrot set, smoothly coloured.""" + import numpy as np + x = np.linspace(-2.35, 0.85, width) + y = np.linspace(-1.0667, 1.0667, height) + c = x[None, :] + 1j * y[:, None] + z = np.zeros_like(c) + count = np.zeros(c.shape) + alive = np.ones(c.shape, bool) + limit = 200 + for n in range(limit): + z[alive] = z[alive] ** 2 + c[alive] + escaped = alive & (np.abs(z) > 4) + # The smooth (normalised) iteration count, so the bands blend. + count[escaped] = n + 1 - np.log2(np.log2(np.abs(z[escaped]))) + alive &= ~escaped + t = np.sqrt(np.clip(count / 40, 0, 1)) + # A deep blue through gold to white, the inside black. + stops = np.array([[0, 7, 100], [32, 107, 203], [237, 255, 255], [255, 170, 0], [80, 2, 0]], float) + pos = np.linspace(0, 1, len(stops)) + rgb = np.stack([np.interp(t, pos, stops[:, k]) for k in range(3)], axis=-1) + rgb[alive] = 0 + Image.fromarray(rgb.astype(np.uint8)).save(path) + + +def image_setup(s): + """A lone terminal at the project, which holds a picture.""" + mandelbrot(PROJECT / 'mandelbrot.png') + shell_setup(s) + s.write('/pane/1/exec', 'Del\n') + s.wait(lambda: list(s.panes()) == [2], 'the README to close') + + +def image_pane(s): + """ls in a shell; B3 on the PNG's name opens it in a pane.""" + s.pointer = s.cell_px(40, 8) + s.shot(1.0) + s.type('ls', lambda typed: at_prompt(s, typed)()) + s.keys('\r') + s.wait(lambda: any('mandelbrot.png' in line for line in s.terminal_rows()), 'ls') + s.shot(.9) + col, row = s.find('mandelbrot.png', 0) + s.click(3, *s.cell_px(col + 5, row), done=lambda: len(s.panes()) == 2, what='the picture', after=2.2) + s.shots[-1]['poster'] = True + image = next(n for n, kind in s.panes().items() if kind == 'image') + # Petscii, a word typed into the picture's tag, redraws it as a C64's + # character art would. + s.write(f'/pane/{image}/tag', ' Petscii') + s.click(2, *s.tag_word(image, 'Petscii'), done=lambda: 'petscii:on' in s.tag(image), what='petscii', + after=2.6) + + +# The Intel 64 and IA-32 SDM, vol. 2 (2,515 pages), opened where it is. +PDF = [Path('/home/goblin/01-resources/intel-devref-ii.pdf')] + + +def pdf_args(): + return [PDF[0]] + + +def pdf_setup(s): + s.mouse('motion', 0, *s.cell_px(COLS - 2, ROWS - 1)) + + +def pdf_tag(s, word, pane=None): + """The pixel over `word` in the PDF pane's tag.""" + pane = pane or next(n for n, kind in s.panes().items() if kind == 'pdf') + return s.tag_word(pane, word) + + +def page_of(s, pane): + tag = s.tag(pane) + return int(tag[tag.index('[') + 1:tag.index('/', tag.index('['))]) + + +def pdf_navigation(s): + """Page through the Intel SDM, jump to CPUID from its sections, search + a word and step through the hits.""" + pdf = next(n for n, kind in s.panes().items() if kind == 'pdf') + s.pointer = s.cell_px(44, 12) + s.shot(1.2) + s.press([('\x06', 'Ctrl-f'), ('\x06', 'Ctrl-f Ctrl-f')], per_key=.7) + s.click(2, *pdf_tag(s, 'PdfSections'), done=lambda: len(s.panes()) == 2, what='the sections', after=.8) + listing = next(n for n in s.panes() if n != pdf) + top = s.find('+PdfSections', 0)[1] + s.write('/focus', f'{listing}\n') + s.badge = '200G' + for key in '200G': + s.keys(key) + s.wait(lambda: any('CPUID' in line for line in s.screen()[top:]), 'the CPUID row') + s.shot(1.0) + s.badge = None + # A row's file.pdf:PAGE:SECTION is the place to look at. + col, row = s.find('pdf:317:200', after=top + 1) + s.click(3, *s.cell_px(col + 4, row), done=lambda: page_of(s, pdf) == 317, what='page 317', after=1.2) + s.click(2, *s.tag_word(listing, 'Del'), done=lambda: list(s.panes()) == [pdf], what='the listing to close', + after=.8) + s.write('/focus', f'{pdf}\n') + s.badge = '/' + s.keys('/') + s.shot(.25) + # Its first hits are on the pages after CPUID's first. + s.type('apic id', lambda typed: True, per_key=.08) + s.badge = '/apic id Enter' + s.keys('\r') + s.wait(lambda: any(kind == 'text' for kind in s.panes().values()), 'the hits') + s.shot(1.0) + s.badge = None + hits = next(n for n, kind in s.panes().items() if kind == 'text') + # The hit list folds to its tag, and the page has the column again. + s.click(2, *s.tag_word(hits, 'Collapse'), done=lambda: 'collapsed' in s.read(f'/pane/{hits}/ctl'), + what='the hits to fold', after=.8) + s.write('/focus', f'{pdf}\n') + for k in range(1, 4): + s.badge = ' '.join(['n'] * k) + s.keys('n') + s.shot(.8) + s.badge = None + s.shots[-1]['secs'] = 1.6 + s.shots[-1]['poster'] = True + + +def pdf_tint_setup(s): + """CPUID's page, and two words of the user's in the tag: PdfFit and a + page address (MOV's).""" + s.write('/pane/1/look', f'{PDF[0]}:317\n') + s.wait(lambda: page_of(s, 1) == 317, 'page 317') + s.write('/pane/1/tag', f' PdfFit {PDF[0].name}:762') + pdf_setup(s) + + +def pdf_tint_fit(s): + """PdfTint through its three looks, PdfFit both ways, then a look at + a page address.""" + s.pointer = s.cell_px(44, 12) + s.shot(1.2) + for _ in range(3): + before = s.read('/pane/1/ctl').split()[-1] + s.click(2, *pdf_tag(s, 'PdfTint'), done=lambda: s.read('/pane/1/ctl').split()[-1] != before, + what='the tint', after=1.0) + for fit in ('height', 'width'): + s.click(2, *pdf_tag(s, 'PdfFit'), done=lambda: f'fit:{fit}' in s.read('/pane/1/ctl'), what='the fit', + after=1.3) + s.click(3, *pdf_tag(s, f'{PDF[0].name}:762'), done=lambda: page_of(s, 1) == 762, what='page 762', after=2.0) + s.shots[-1]['poster'] = True + + +THEMES = MEDIA / 'themes' +THEME_WIDTH = 640 +THEME_MAX_BYTES = 120_000 + + +def theme_scene(s): + """One column: a C file with its syntax colours and a selection, a + shell that ran make (gcc's colours), and git diff paged into +Pager.""" + env = dict(clean_env(), HOME=str(HOME), GIT_AUTHOR_NAME='demo', GIT_AUTHOR_EMAIL='demo@example.com', + GIT_COMMITTER_NAME='demo', GIT_COMMITTER_EMAIL='demo@example.com') + for args in (['init', '-q'], ['add', '.'], ['commit', '-qm', 'hello'], ['config', 'diff.context', '1']): + subprocess.run(['git', '-C', str(PROJECT), *args], check=True, env=env, capture_output=True) + main = PROJECT / 'src/main.c' + main.write_text(main.read_text().replace('i <= 4', 'i <= 5')) + s.write('/pane/1/exec', 'Tty\n') + s.wait(lambda: 2 in s.panes(), 'the terminal') + s.write('/pane/2/pty/data', f"cd {PROJECT}; PS1='$ '; clear; make; git diff\r") + s.wait(lambda: len(s.panes()) == 3, 'the pager') + s.wait(lambda: 'Error 1' in s.read('/pane/2/body'), 'make') + s.write('/pane/1/dot', '12\n') + # The pager shows its hunk, the end of the diff. + pager = next(n for n, kind in s.panes().items() if n not in (1, 2)) + s.write(f'/pane/{pager}/dot', '$\n') + + +def theme_order(s): + """The themes as the Themes builtin lists them, up to the imported + ones: pardes's own, the ports and the legacy pair (src/themes).""" + s.write('/ctl', 'Themes\n') + s.wait(lambda: any(s.read(f'/pane/{n}/name').strip().endswith('+Themes') for n in s.panes()), '+Themes') + pane = next(n for n in s.panes() if s.read(f'/pane/{n}/name').strip().endswith('+Themes')) + names = [] + for line in s.read(f'/pane/{pane}/body').splitlines(): + if line.startswith('# Imported'): + break + if line.startswith('Theme '): + names.append(line.split()[1]) + s.write(f'/pane/{pane}/ctl', 'Del\n') + s.wait(lambda: pane not in s.panes(), '+Themes to close') + return names + + +def save_theme_png(data, path): + """The capture at THEME_WIDTH, as small a PNG as reads: full colour if it + fits THEME_MAX_BYTES, else 256 colours. Answers light or dark, from the + colour most of the window is.""" + import io + img = Image.open(io.BytesIO(data)).convert('RGB') + ground = max(img.getcolors(1 << 24), key=lambda c: c[0])[1] + lum = sum(w * (v / 255) ** 2.2 for w, v in zip((.2126, .7152, .0722), ground)) + small = img.resize((THEME_WIDTH, round(img.height * THEME_WIDTH / img.width)), Image.LANCZOS) + small.save(path, optimize=True) + if path.stat().st_size > THEME_MAX_BYTES: + small.quantize(256, method=Image.Quantize.MEDIANCUT, dither=Image.Dither.NONE).save(path, optimize=True) + return 'light' if lum > .18 else 'dark' + + +def record_themes(binary, work): + """docs/site/media/themes/.png for every theme of src/themes, in + the Themes builtin's order, and themes.toml listing them.""" + make_project() + s = Session(binary, work / 'themes', 'rec-themes', [PROJECT / 'src/main.c'], rows=22) + try: + theme_scene(s) + names = theme_order(s) + THEMES.mkdir(parents=True, exist_ok=True) + rows = [] + for name in names: + s.write('/ctl', f'Theme {name}\n') + # A pointer move puts away the word's flash that a command + # leaves up until the pointer moves. + s.mouse('motion', 0, *s.cell_px(COLS - 2, 1)) + s.mouse('motion', 0, *s.cell_px(COLS - 3, 1)) + kind = save_theme_png(s.settle(), THEMES / f'{name}.png') + rows.append((name, kind)) + print(f'{name}.png {kind} {(THEMES / f"{name}.png").stat().st_size / 1e3:.0f} KB', flush=True) + finally: + s.close() + toml = ['# The Themes page gallery, in the order the Themes builtin walks them:', + '# media/themes/ for each, made by test/record_demos.py themes.', + 'ready = true', ''] + for name, kind in rows: + toml += ['[[theme]]', f'name = "{name}"', f'file = "{name}.png"', f'kind = "{kind}"', ''] + (THEMES / 'themes.toml').write_text('\n'.join(toml)) CLIPS = { 'text-is-the-interface': dict( - run=text_is_the_interface, args=[PROJECT / 'README'], - caption='Middle-click runs a word; right-click an error opens the file.'), + setup=hero_setup, run=text_is_the_interface, args=[PROJECT / 'README'], + caption='Middle-click runs a word; right-click an error opens its line.'), 'terminals-are-panes': dict( setup=shell_setup, run=terminals_are_panes, args=[PROJECT / 'src/main.c'], - caption='A shell is a pane: Ctrl-b, then move over its output.'), + caption='A terminal is a pane: Ctrl-b, then move over its output.'), 'scripting-over-9p': dict( setup=mounted_shell_setup, run=scripting_over_9p, args=[PROJECT / 'README'], - caption='The session is files: a shell script reads and writes its panes.'), + caption='A script drives the session through its virtual filesystem (9P).'), 'diff-review': dict( setup=diff_setup, run=diff_review, args=[PROJECT / 'README'], - caption='git diff pages into a pane; right-click a change to open it.'), + caption='Right-click a diff line to open that line of the file.'), + 'pdf-navigation': dict( + setup=pdf_setup, run=pdf_navigation, args=pdf_args, + caption='A 2,515-page PDF: page, jump to CPUID, search, step hits.'), + 'pdf-tint-fit': dict( + setup=pdf_tint_setup, run=pdf_tint_fit, args=pdf_args, + caption='PdfTint tints the page, PdfFit fits it, a page address jumps.'), + 'image-pane': dict( + setup=image_setup, run=image_pane, args=[PROJECT / 'README'], + caption="Right-click a picture's name to open it; Petscii redraws it."), } def record(binary, work, name): clip = CLIPS[name] make_project() - s = Session(binary, work / name, 'rec-' + name, clip['args'], init=clip.get('init', '')) + args = clip['args']() if callable(clip['args']) else clip['args'] + s = Session(binary, work / name, 'rec-' + name, args, init=clip.get('init', '')) try: if 'setup' in clip: clip['setup'](s) @@ -586,19 +873,26 @@ def record(binary, work, name): def main(): parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument('binary', type=Path, help='a pardes-gui built with -Dplatform=gui') - parser.add_argument('clips', nargs='*', help='which clips (default: all): ' + ', '.join(CLIPS)) + parser.add_argument('clips', nargs='*', + help='which clips (default: all), or themes for the theme gallery: ' + ', '.join(CLIPS)) parser.add_argument('--work', type=Path, default=REPO.parent / '.scratch/rec/work', help='frames and intermediates (large; default %(default)s)') parser.add_argument('--theme', default=THEME[0], help='a theme name, or default (default %(default)s)') + parser.add_argument('--pdf', type=Path, default=PDF[0], + help='the PDF the pdf clips page through, opened read-only (default %(default)s)') args = parser.parse_args() THEME[0] = args.theme + PDF[0] = args.pdf.resolve() names = args.clips or list(CLIPS) for name in names: - if name not in CLIPS: + if name not in CLIPS and name != 'themes': parser.error(f'no clip {name!r}: ' + ', '.join(CLIPS)) try: for name in names: - record(args.binary, args.work.resolve(), name) + if name == 'themes': + record_themes(args.binary, args.work.resolve()) + else: + record(args.binary, args.work.resolve(), name) finally: shutil.rmtree(PROJECT, ignore_errors=True) shutil.rmtree(HOME, ignore_errors=True) @@ -606,7 +900,8 @@ def main(): lines = dict(line.split(': ', 1) for line in captions.read_text().splitlines() if ': ' in line) \ if captions.exists() else {} for name in names: - lines[name] = CLIPS[name]['caption'] + if name in CLIPS: + lines[name] = CLIPS[name]['caption'] captions.write_text(''.join(f'{name}: {lines[name]}\n' for name in CLIPS if name in lines)) -- cgit v1.3 From fa39a4998ccf547004f5b209c395e4868b319c00 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 1 Oct 2026 13:22:53 -0300 Subject: The hero clip opens its output pane when make is clicked; the image clip shows the Mandelbrot set and a seahorse-valley zoom, no Petscii; the landing lists the PDF and image clips first record_demos.py: text-is-the-interface starts on README and main.c alone, and the middle-click on make brings up the output pane before the right-click puts main.c on line 12. image-pane draws two PNGs, the classic view and a zoom into the seahorse valley; ls lists them, a right-click opens the set, Del closes it and a right-click opens the zoom. clips.toml and CLIPS run pdf-navigation, image-pane, pdf-tint-fit, then the hero, terminals, scripting and diff-review. Co-Authored-By: Claude Opus 5.5 --- docs/site/media/captions.txt | 6 +-- docs/site/media/clips.toml | 28 +++++----- docs/site/media/image-pane.mp4 | Bin 182755 -> 294819 bytes docs/site/media/image-pane.png | Bin 189612 -> 199517 bytes docs/site/media/image-pane.webm | Bin 223710 -> 433434 bytes docs/site/media/text-is-the-interface.mp4 | Bin 208679 -> 276620 bytes docs/site/media/text-is-the-interface.png | Bin 84827 -> 84823 bytes docs/site/media/text-is-the-interface.webm | Bin 279200 -> 353359 bytes test/record_demos.py | 82 +++++++++++++++++------------ 9 files changed, 64 insertions(+), 52 deletions(-) (limited to 'test/record_demos.py') diff --git a/docs/site/media/captions.txt b/docs/site/media/captions.txt index 73ad850c..47245043 100644 --- a/docs/site/media/captions.txt +++ b/docs/site/media/captions.txt @@ -1,7 +1,7 @@ +pdf-navigation: A 2,515-page PDF: page, jump to CPUID, search, step hits. +image-pane: Right-click an image's name, even in a shell, to open it. +pdf-tint-fit: PdfTint tints the page, PdfFit fits it, a page address jumps. text-is-the-interface: Middle-click runs a word; right-click an error opens its line. terminals-are-panes: A terminal is a pane: Ctrl-b, then move over its output. scripting-over-9p: A script drives the session through its virtual filesystem (9P). diff-review: Right-click a diff line to open that line of the file. -pdf-navigation: A 2,515-page PDF: page, jump to CPUID, search, step hits. -pdf-tint-fit: PdfTint tints the page, PdfFit fits it, a page address jumps. -image-pane: Right-click a picture's name to open it; Petscii redraws it. diff --git a/docs/site/media/clips.toml b/docs/site/media/clips.toml index 3ce07fa3..f630930c 100644 --- a/docs/site/media/clips.toml +++ b/docs/site/media/clips.toml @@ -5,36 +5,36 @@ # no video, so the site builds before a recording exists. [[clip]] -name = "text-is-the-interface" -caption = "Middle-click runs a word; right-click an error opens its line." +name = "pdf-navigation" +caption = "A 2,515-page PDF: page, jump to CPUID, search, step hits." ready = true [[clip]] -name = "terminals-are-panes" -caption = "A terminal is a pane: Ctrl-b, then move over its output." +name = "image-pane" +caption = "Right-click an image's name, even in a shell, to open it." ready = true [[clip]] -name = "scripting-over-9p" -caption = "A script drives the session through its virtual filesystem (9P)." +name = "pdf-tint-fit" +caption = "PdfTint tints the page, PdfFit fits it, a page address jumps." ready = true [[clip]] -name = "diff-review" -caption = "Right-click a diff line to open that line of the file." +name = "text-is-the-interface" +caption = "Middle-click runs a word; right-click an error opens its line." ready = true [[clip]] -name = "pdf-navigation" -caption = "A 2,515-page PDF: page, jump to CPUID, search, step hits." +name = "terminals-are-panes" +caption = "A terminal is a pane: Ctrl-b, then move over its output." ready = true [[clip]] -name = "pdf-tint-fit" -caption = "PdfTint tints the page, PdfFit fits it, a page address jumps." +name = "scripting-over-9p" +caption = "A script drives the session through its virtual filesystem (9P)." ready = true [[clip]] -name = "image-pane" -caption = "Right-click a picture's name to open it; Petscii redraws it." +name = "diff-review" +caption = "Right-click a diff line to open that line of the file." ready = true diff --git a/docs/site/media/image-pane.mp4 b/docs/site/media/image-pane.mp4 index de60b945..9fb1a0e9 100644 Binary files a/docs/site/media/image-pane.mp4 and b/docs/site/media/image-pane.mp4 differ diff --git a/docs/site/media/image-pane.png b/docs/site/media/image-pane.png index 3f77e2ac..94eb7b50 100644 Binary files a/docs/site/media/image-pane.png and b/docs/site/media/image-pane.png differ diff --git a/docs/site/media/image-pane.webm b/docs/site/media/image-pane.webm index 46de130b..764be10c 100644 Binary files a/docs/site/media/image-pane.webm and b/docs/site/media/image-pane.webm differ diff --git a/docs/site/media/text-is-the-interface.mp4 b/docs/site/media/text-is-the-interface.mp4 index 253d1f39..35a3086c 100644 Binary files a/docs/site/media/text-is-the-interface.mp4 and b/docs/site/media/text-is-the-interface.mp4 differ diff --git a/docs/site/media/text-is-the-interface.png b/docs/site/media/text-is-the-interface.png index b0d40b15..95a508c5 100644 Binary files a/docs/site/media/text-is-the-interface.png and b/docs/site/media/text-is-the-interface.png differ diff --git a/docs/site/media/text-is-the-interface.webm b/docs/site/media/text-is-the-interface.webm index 07cf62e6..8a8baa89 100644 Binary files a/docs/site/media/text-is-the-interface.webm and b/docs/site/media/text-is-the-interface.webm differ diff --git a/test/record_demos.py b/test/record_demos.py index 71bf1055..9256e81e 100644 --- a/test/record_demos.py +++ b/test/record_demos.py @@ -485,26 +485,32 @@ def encode(lossless, name, poster, crf_webm=30, crf_mp4=20): # the clips def hero_setup(s): - """README, main.c under it and an output pane under that, all on - screen from the first frame: the output pane is a finished `clear`, - which `make` will reuse.""" + """README and main.c under it; `make` in the README's tag.""" s.write('/pane/1/look', f'{PROJECT}/src/main.c\n') s.wait(lambda: len(s.panes()) == 2, 'main.c') - s.write('/pane/1/exec', 'clear\n') - s.wait(lambda: any(kind == 'cmd' and 'exit' in s.tag(n) for n, kind in s.panes().items()), 'the output pane') s.write('/pane/1/tag', ' make') s.mouse('motion', 0, *s.cell_px(36, 9)) +def pane_rows(s, name, rows=6): + """The first `rows` screen rows under the tag that starts with `name`.""" + screen = s.screen() + top = next(i for i, line in enumerate(screen) if line[3:].startswith(name)) + return screen[top + 1:top + 1 + rows] + + def text_is_the_interface(s): - """B2 on `make` in a tag runs it; B3 on the error opens main.c there.""" - output = next(n for n, kind in s.panes().items() if kind == 'cmd') + """B2 on `make` in a tag opens its output pane; B3 on the error there + puts main.c on line 12.""" s.pointer = s.cell_px(36, 9) - s.shot(1.2) + s.shot(1.4) col, row = s.find('make', 0) - s.click(2, *s.tag_px(col + 1, row), done=lambda: '(make) exit' in s.tag(output), what='make') + s.click(2, *s.tag_px(col + 1, row), + done=lambda: any(kind == 'cmd' and '(make) exit' in s.tag(n) for n, kind in s.panes().items()), + what='make', after=1.2) col, row = s.find('src/main.c:12:5', 0) - s.click(3, *s.cell_px(col + 4, row), done=lambda: any(line.startswith(' 12 ') for line in s.screen()[6:12]), + s.click(3, *s.cell_px(col + 4, row), + done=lambda: any(line.startswith(' 12 ') for line in pane_rows(s, f'{PROJECT}/src/main.c')), what='main.c at line 12', after=2.8) s.shots[-1]['poster'] = True @@ -593,24 +599,29 @@ def diff_review(s): s.shots[-1]['poster'] = True -def mandelbrot(path, width=1200, height=800): - """The classic view of the Mandelbrot set, smoothly coloured.""" +def mandelbrot(path, center=(-0.75, 0.0), span=3.2, limit=200, width=1200, height=800, bands=40): + """The Mandelbrot set around `center`, `span` wide, smoothly coloured: + a deep blue through white to gold, the inside black. `bands` is the + escape count one sweep of the palette takes (a deep zoom cycles it).""" import numpy as np - x = np.linspace(-2.35, 0.85, width) - y = np.linspace(-1.0667, 1.0667, height) + x = np.linspace(center[0] - span / 2, center[0] + span / 2, width) + half = span * height / width / 2 + y = np.linspace(center[1] + half, center[1] - half, height) c = x[None, :] + 1j * y[:, None] z = np.zeros_like(c) count = np.zeros(c.shape) alive = np.ones(c.shape, bool) - limit = 200 for n in range(limit): z[alive] = z[alive] ** 2 + c[alive] escaped = alive & (np.abs(z) > 4) # The smooth (normalised) iteration count, so the bands blend. count[escaped] = n + 1 - np.log2(np.log2(np.abs(z[escaped]))) alive &= ~escaped - t = np.sqrt(np.clip(count / 40, 0, 1)) - # A deep blue through gold to white, the inside black. + if limit > 2 * bands: + t = (count / bands) % 1 # a zoom: the palette repeats down the spirals + t = np.where(t < .5, t * 2, (1 - t) * 2) + else: + t = np.sqrt(np.clip(count / bands, 0, 1)) stops = np.array([[0, 7, 100], [32, 107, 203], [237, 255, 255], [255, 170, 0], [80, 2, 0]], float) pos = np.linspace(0, 1, len(stops)) rgb = np.stack([np.interp(t, pos, stops[:, k]) for k in range(3)], axis=-1) @@ -619,30 +630,31 @@ def mandelbrot(path, width=1200, height=800): def image_setup(s): - """A lone terminal at the project, which holds a picture.""" + """A lone terminal at the project, which holds two pictures: the + Mandelbrot set and a zoom into its seahorse valley.""" mandelbrot(PROJECT / 'mandelbrot.png') + mandelbrot(PROJECT / 'seahorse.png', center=(-0.7453, 0.1127), span=0.012, limit=600, bands=60) shell_setup(s) s.write('/pane/1/exec', 'Del\n') s.wait(lambda: list(s.panes()) == [2], 'the README to close') def image_pane(s): - """ls in a shell; B3 on the PNG's name opens it in a pane.""" + """ls in a shell; B3 on each PNG's name opens it in a pane.""" s.pointer = s.cell_px(40, 8) s.shot(1.0) s.type('ls', lambda typed: at_prompt(s, typed)()) s.keys('\r') - s.wait(lambda: any('mandelbrot.png' in line for line in s.terminal_rows()), 'ls') + s.wait(lambda: any('seahorse.png' in line for line in s.terminal_rows()), 'ls') s.shot(.9) col, row = s.find('mandelbrot.png', 0) - s.click(3, *s.cell_px(col + 5, row), done=lambda: len(s.panes()) == 2, what='the picture', after=2.2) + s.click(3, *s.cell_px(col + 4, row), done=lambda: len(s.panes()) == 2, what='the set', after=2.4) s.shots[-1]['poster'] = True + # Del gives its rows back, so the zoom opens as large. image = next(n for n, kind in s.panes().items() if kind == 'image') - # Petscii, a word typed into the picture's tag, redraws it as a C64's - # character art would. - s.write(f'/pane/{image}/tag', ' Petscii') - s.click(2, *s.tag_word(image, 'Petscii'), done=lambda: 'petscii:on' in s.tag(image), what='petscii', - after=2.6) + s.click(2, *s.tag_word(image, 'Del'), done=lambda: len(s.panes()) == 1, what='Del', after=.6) + col, row = s.find('seahorse.png', 0) + s.click(3, *s.cell_px(col + 4, row), done=lambda: len(s.panes()) == 2, what='the zoom', after=3.0) # The Intel 64 and IA-32 SDM, vol. 2 (2,515 pages), opened where it is. @@ -827,6 +839,15 @@ def record_themes(binary, work): CLIPS = { + 'pdf-navigation': dict( + setup=pdf_setup, run=pdf_navigation, args=pdf_args, + caption='A 2,515-page PDF: page, jump to CPUID, search, step hits.'), + 'image-pane': dict( + setup=image_setup, run=image_pane, args=[PROJECT / 'README'], + caption="Right-click an image's name, even in a shell, to open it."), + 'pdf-tint-fit': dict( + setup=pdf_tint_setup, run=pdf_tint_fit, args=pdf_args, + caption='PdfTint tints the page, PdfFit fits it, a page address jumps.'), 'text-is-the-interface': dict( setup=hero_setup, run=text_is_the_interface, args=[PROJECT / 'README'], caption='Middle-click runs a word; right-click an error opens its line.'), @@ -839,15 +860,6 @@ CLIPS = { 'diff-review': dict( setup=diff_setup, run=diff_review, args=[PROJECT / 'README'], caption='Right-click a diff line to open that line of the file.'), - 'pdf-navigation': dict( - setup=pdf_setup, run=pdf_navigation, args=pdf_args, - caption='A 2,515-page PDF: page, jump to CPUID, search, step hits.'), - 'pdf-tint-fit': dict( - setup=pdf_tint_setup, run=pdf_tint_fit, args=pdf_args, - caption='PdfTint tints the page, PdfFit fits it, a page address jumps.'), - 'image-pane': dict( - setup=image_setup, run=image_pane, args=[PROJECT / 'README'], - caption="Right-click a picture's name to open it; Petscii redraws it."), } -- cgit v1.3 From d19cce311a827e7fb176ecc35cb0a49f2bc6899f Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 1 Oct 2026 13:40:05 -0300 Subject: The hero clip middle-clicks make in the README's text, not a word added to its tag: text in a document runs as a tag word does Co-Authored-By: Claude Opus 5.5 --- docs/site/media/captions.txt | 2 +- docs/site/media/clips.toml | 2 +- docs/site/media/text-is-the-interface.mp4 | Bin 276620 -> 275812 bytes docs/site/media/text-is-the-interface.png | Bin 84823 -> 84504 bytes docs/site/media/text-is-the-interface.webm | Bin 353359 -> 351601 bytes test/record_demos.py | 13 ++++++------- 6 files changed, 8 insertions(+), 9 deletions(-) (limited to 'test/record_demos.py') diff --git a/docs/site/media/captions.txt b/docs/site/media/captions.txt index 47245043..e4370744 100644 --- a/docs/site/media/captions.txt +++ b/docs/site/media/captions.txt @@ -1,7 +1,7 @@ pdf-navigation: A 2,515-page PDF: page, jump to CPUID, search, step hits. image-pane: Right-click an image's name, even in a shell, to open it. pdf-tint-fit: PdfTint tints the page, PdfFit fits it, a page address jumps. -text-is-the-interface: Middle-click runs a word; right-click an error opens its line. +text-is-the-interface: Middle-click make in the README; right-click the error. terminals-are-panes: A terminal is a pane: Ctrl-b, then move over its output. scripting-over-9p: A script drives the session through its virtual filesystem (9P). diff-review: Right-click a diff line to open that line of the file. diff --git a/docs/site/media/clips.toml b/docs/site/media/clips.toml index f630930c..adb97762 100644 --- a/docs/site/media/clips.toml +++ b/docs/site/media/clips.toml @@ -21,7 +21,7 @@ ready = true [[clip]] name = "text-is-the-interface" -caption = "Middle-click runs a word; right-click an error opens its line." +caption = "Middle-click make in the README; right-click the error." ready = true [[clip]] diff --git a/docs/site/media/text-is-the-interface.mp4 b/docs/site/media/text-is-the-interface.mp4 index 35a3086c..b4a12c87 100644 Binary files a/docs/site/media/text-is-the-interface.mp4 and b/docs/site/media/text-is-the-interface.mp4 differ diff --git a/docs/site/media/text-is-the-interface.png b/docs/site/media/text-is-the-interface.png index 95a508c5..a31dcb78 100644 Binary files a/docs/site/media/text-is-the-interface.png and b/docs/site/media/text-is-the-interface.png differ diff --git a/docs/site/media/text-is-the-interface.webm b/docs/site/media/text-is-the-interface.webm index 8a8baa89..76c2c06b 100644 Binary files a/docs/site/media/text-is-the-interface.webm and b/docs/site/media/text-is-the-interface.webm differ diff --git a/test/record_demos.py b/test/record_demos.py index 9256e81e..3cc07f15 100644 --- a/test/record_demos.py +++ b/test/record_demos.py @@ -485,10 +485,9 @@ def encode(lossless, name, poster, crf_webm=30, crf_mp4=20): # the clips def hero_setup(s): - """README and main.c under it; `make` in the README's tag.""" + """README and main.c under it.""" s.write('/pane/1/look', f'{PROJECT}/src/main.c\n') s.wait(lambda: len(s.panes()) == 2, 'main.c') - s.write('/pane/1/tag', ' make') s.mouse('motion', 0, *s.cell_px(36, 9)) @@ -500,12 +499,12 @@ def pane_rows(s, name, rows=6): def text_is_the_interface(s): - """B2 on `make` in a tag opens its output pane; B3 on the error there - puts main.c on line 12.""" + """B2 on `make` in the README's text runs it, opening its output pane; + B3 on the error there puts main.c on line 12.""" s.pointer = s.cell_px(36, 9) s.shot(1.4) - col, row = s.find('make', 0) - s.click(2, *s.tag_px(col + 1, row), + col, row = s.find('with make,', 0) + s.click(2, *s.cell_px(col + 6, row), done=lambda: any(kind == 'cmd' and '(make) exit' in s.tag(n) for n, kind in s.panes().items()), what='make', after=1.2) col, row = s.find('src/main.c:12:5', 0) @@ -850,7 +849,7 @@ CLIPS = { caption='PdfTint tints the page, PdfFit fits it, a page address jumps.'), 'text-is-the-interface': dict( setup=hero_setup, run=text_is_the_interface, args=[PROJECT / 'README'], - caption='Middle-click runs a word; right-click an error opens its line.'), + caption='Middle-click make in the README; right-click the error.'), 'terminals-are-panes': dict( setup=shell_setup, run=terminals_are_panes, args=[PROJECT / 'src/main.c'], caption='A terminal is a pane: Ctrl-b, then move over its output.'), -- cgit v1.3 From 54948bf22fb891bd31fcd5dc33e0bce7552fe1d4 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 1 Oct 2026 14:04:47 -0300 Subject: A chords clip for the guide: B1 sweeps and stays down, B2 cuts, B3 pastes, B2 then B3 copies, every held button drawn record_demos.py chords: a small notes file; each chord glides, stops, presses B1 and keeps it down while B2 or B3 clicks. The pointer wears a ring per button down and a mouse whose held buttons are lit, named "left held + middle-click" and the like; B1 is drawn blue. clips.toml lists it with landing = false, for the guide to embed. Co-Authored-By: Claude Opus 5.5 --- docs/site/media/captions.txt | 1 + docs/site/media/chords.mp4 | Bin 0 -> 150705 bytes docs/site/media/chords.png | Bin 0 -> 33061 bytes docs/site/media/chords.webm | Bin 0 -> 139047 bytes docs/site/media/clips.toml | 6 ++ test/record_demos.py | 143 ++++++++++++++++++++++++++++++++++++++++--- 6 files changed, 141 insertions(+), 9 deletions(-) create mode 100644 docs/site/media/chords.mp4 create mode 100644 docs/site/media/chords.png create mode 100644 docs/site/media/chords.webm (limited to 'test/record_demos.py') diff --git a/docs/site/media/captions.txt b/docs/site/media/captions.txt index e4370744..6a1a2274 100644 --- a/docs/site/media/captions.txt +++ b/docs/site/media/captions.txt @@ -5,3 +5,4 @@ text-is-the-interface: Middle-click make in the README; right-click the error. terminals-are-panes: A terminal is a pane: Ctrl-b, then move over its output. scripting-over-9p: A script drives the session through its virtual filesystem (9P). diff-review: Right-click a diff line to open that line of the file. +chords: Hold left, click middle to cut; click right to paste. diff --git a/docs/site/media/chords.mp4 b/docs/site/media/chords.mp4 new file mode 100644 index 00000000..43bc556b Binary files /dev/null and b/docs/site/media/chords.mp4 differ diff --git a/docs/site/media/chords.png b/docs/site/media/chords.png new file mode 100644 index 00000000..a140347c Binary files /dev/null and b/docs/site/media/chords.png differ diff --git a/docs/site/media/chords.webm b/docs/site/media/chords.webm new file mode 100644 index 00000000..42a6f4e6 Binary files /dev/null and b/docs/site/media/chords.webm differ diff --git a/docs/site/media/clips.toml b/docs/site/media/clips.toml index ca3002d0..11f6e8f3 100644 --- a/docs/site/media/clips.toml +++ b/docs/site/media/clips.toml @@ -39,3 +39,9 @@ ready = true name = "diff-review" caption = "Right-click a diff line to open that line of the file." ready = true + +[[clip]] +name = "chords" +caption = "Hold left, click middle to cut; click right to paste." +ready = true +landing = false diff --git a/test/record_demos.py b/test/record_demos.py index 3cc07f15..7ab22d95 100644 --- a/test/record_demos.py +++ b/test/record_demos.py @@ -110,6 +110,7 @@ def make_project(): (PROJECT / 'src/main.c').write_text(MAIN_C) (PROJECT / 'Makefile').write_text(MAKEFILE) (PROJECT / 'README').write_text(README) + (PROJECT / 'notes.txt').write_text(NOTES) class Session: @@ -157,6 +158,7 @@ class Session: self.pointer = None # the drawn pointer's (x, y), None for none self.button = None # the SDL button held, drawn as a ring and its name self.badge = None # a key or two, drawn in the corner + self.held = [] # the buttons a chord holds, each drawn as a ring and on a mouse self.settle() def _drain(self): @@ -309,16 +311,43 @@ class Session: path.write_bytes(data) self.shots.append(dict(frame=path, secs=seconds, start=self.pointer, end=self.pointer, button=self.button, badge=self.badge, poster=poster, ring=ring, - ring_button=ring_button or self.button)) + ring_button=ring_button or self.button, held=tuple(self.held))) def glide(self, x, y, seconds=.6): """Glide the drawn pointer to (x, y) over the frame on screen, then move the window's pointer there (dragging any button held).""" if self.shots and self.pointer is not None: last = self.shots[-1] - self.shots.append(dict(last, secs=seconds, start=self.pointer, end=(x, y), poster=False, ring=None)) + self.shots.append(dict(last, secs=seconds, start=self.pointer, end=(x, y), poster=False, ring=None, + held=tuple(self.held))) self.pointer = (x, y) - self.mouse('motion', self.button or 0, x, y) + self.mouse('motion', self.button or (self.held[0] if self.held else 0), x, y) + + def chord_press(self, x, y, rest=.4, hold=.5): + """Glide to (x, y), stop, and press B1 there, holding it.""" + if self.pointer != (x, y): + self.glide(x, y) + self.shot(rest) + self.mouse('down', 1, x, y) + self.held = [1] + self.shot(hold) + + def chord_click(self, button, done, what, hold=.45, after=1.0): + """With B1 held and the pointer still, click `button`: both rings + and the mouse's two buttons lit on the press, then a pulse.""" + self.mouse('down', button, *self.pointer) + self.held.append(button) + self.shot(hold, ring='press', ring_button=button) + self.mouse('up', button, *self.pointer) + self.held.remove(button) + self.wait(done, what) + self.shot(after, ring='pulse', ring_button=button) + + def chord_release(self, after=.6): + """Let B1 go, the pointer still.""" + self.mouse('up', 1, *self.pointer) + self.held = [] + self.shot(after) def click(self, button, x, y, done=None, what='the click', rest=.4, hold=.35, after=1.0): """Glide to (x, y) and stop; a beat later press `button` (SDL: 1 @@ -368,8 +397,9 @@ def pointer_sprite(scale): return im -# acme's colours for the buttons: B2 red, B3 green. -BUTTONS = {1: ('click', (70, 70, 70)), 2: ('middle-click', (170, 0, 0)), 3: ('right-click', (0, 110, 40))} +# acme's colours for the buttons: B2 red, B3 green; B1, which acme leaves +# black, is blue here so a held left button shows on the mouse. +BUTTONS = {1: ('click', (30, 80, 190)), 2: ('middle-click', (170, 0, 0)), 3: ('right-click', (0, 110, 40))} def draw_badge(img, text, xy, font, fill=(40, 40, 40), anchor='lt'): @@ -386,7 +416,50 @@ class Painter: self.font = ImageFont.truetype(str(BADGE_FONT), 24) self.size = size - def paint(self, img, pointer, badge, ring=None, button=None, since=0.0): + def chord(self, img, x, y, held, ring, button, since): + """A chord: a ring for every button down (left inside, middle, + right outside), a mouse whose held buttons are lit, and its name.""" + w, h = self.size + d = ImageDraw.Draw(img, 'RGBA') + radius = {1: 15, 2: 23, 3: 31} + for b in held: + r = radius[b] + d.ellipse((x - r, y - r, x + r, y + r), outline=BUTTONS[b][1] + (255,), width=4) + clicked = [b for b in held if b != 1] + if ring == 'pulse' and button and button not in held: + t = min(since / .45, 1) + r = radius[button] + 18 * t + if t < 1: + d.ellipse((x - r, y - r, x + r, y + r), outline=BUTTONS[button][1] + (int(255 * (1 - t)),), width=4) + if since < .7: + clicked = [button] + lit = set(held) | set(clicked) + names = {2: 'middle', 3: 'right'} + label = 'left held' + ''.join(f' + {names[b]}-click' for b in clicked) + width = self.font.getlength(label) + 14 + # The mouse, below and right of the pointer (else left of it): three + # buttons over a body, the held ones lit, the name beside it. + mx, my, mw, mh = x + 40, y + 30, 52, 74 + if my + mh + 8 > h: + my = y - 34 - mh + if mx + mw + 12 + width + 16 > w: + mx = x - 40 - mw + d.rounded_rectangle((mx, my, mx + mw, my + mh), radius=18, fill=(250, 250, 250, 245), outline=(30, 30, 30, 255), + width=3) + third = mw / 3 + for b in (1, 2, 3): + box = (mx + third * (b - 1) + 3, my + 3, mx + third * b - 3, my + mh * .42) + if b in lit: + d.rectangle(box, fill=BUTTONS[b][1] + (255,)) + d.line((mx + 3, my + mh * .42 + 2, mx + mw - 3, my + mh * .42 + 2), fill=(30, 30, 30, 255), width=2) + for b in (1, 2): + lx = mx + third * b + d.line((lx, my + 3, lx, my + mh * .42), fill=(30, 30, 30, 255), width=2) + colour = BUTTONS[clicked[-1]][1] if clicked else BUTTONS[1][1] + lx = mx + mw + 12 if mx > x else mx - 12 - width + draw_badge(img, label, (lx, my + mh / 2), self.font, fill=colour, anchor='lm') + + def paint(self, img, pointer, badge, ring=None, button=None, since=0.0, held=()): """`img` with the badge, the pointer, and a click: `ring` 'press' (a ring and the button's name) or 'pulse' (`since` seconds after the release: the ring widening and fading, the name kept a moment).""" @@ -396,7 +469,9 @@ class Painter: draw_badge(img, badge, (w - 16, h - 16), self.font, anchor='rb') if pointer is not None: x, y = pointer - if ring and button: + if held: + self.chord(img, x, y, held, ring, button, since) + elif ring and button: label, colour = BUTTONS[button] d = ImageDraw.Draw(img, 'RGBA') if ring == 'press': @@ -446,10 +521,13 @@ def compose(shots, out): for i in range(n): t = ease((i + 1) / n) frame = painter.paint(img, lerp(shot['start'], shot['end'], t), shot['badge'], shot['ring'], - shot['ring_button'], i / FPS) + shot['ring_button'], i / FPS, shot.get('held', ())) ff.stdin.write(frame.tobytes()) if shot['poster'] and poster is None: - poster = painter.paint(img, shot['end'], None) + # A chord's still keeps its rings and mouse; a click's has none. + chord = shot.get('held') or () + poster = painter.paint(img, shot['end'], None, shot['ring'] if chord else None, shot['ring_button'], 0.0, + chord) emitted += n last = shots[-1] n = round(.7 * FPS) @@ -837,6 +915,50 @@ def record_themes(binary, work): (THEMES / 'themes.toml').write_text('\n'.join(toml)) +NOTES = '''To buy: apples plums pears + + + +In the bowl: bananas +''' + + +def chords_setup(s): + s.mouse('motion', 0, *s.cell_px(COLS - 2, ROWS - 1)) + + +def body_text(s): + return s.read('/pane/1/body') + + +def chords(s): + """acme's chords: B1 sweeps and stays down; B2 cuts, B3 pastes, B2 then + B3 copies.""" + s.pointer = s.cell_px(40, 12) + s.shot(.8) + # Cut: sweep " plums", B2 with B1 still down. + col, row = s.find(' plums', 0) + s.chord_press(*s.cell_px(col, row), rest=.25, hold=.3) + s.glide(*s.cell_px(col + 7, row), seconds=.45) + s.shot(.3) + s.chord_click(2, lambda: 'plums' not in body_text(s), 'the cut', after=.75) + s.shots[-2]['poster'] = True + s.chord_release(after=.25) + # Paste after "bananas": B1 down there, B3. + col, row = s.find('bananas', 0) + s.chord_press(*s.cell_px(col + 7, row), rest=.25, hold=.3) + s.chord_click(3, lambda: 'bananas plums' in body_text(s), 'the paste', after=.8) + s.chord_release(after=.25) + # Copy: sweep "apples", B2 then B3 with B1 down: it is back, and kept. + col, row = s.find('apples', 0) + s.chord_press(*s.cell_px(col, row), rest=.25, hold=.3) + s.glide(*s.cell_px(col + 6, row), seconds=.45) + s.shot(.3) + s.chord_click(2, lambda: 'apples' not in body_text(s), 'the copy\'s cut', after=.45) + s.chord_click(3, lambda: 'apples' in body_text(s), 'the copy\'s paste', after=.8) + s.chord_release(after=1.0) + + CLIPS = { 'pdf-navigation': dict( setup=pdf_setup, run=pdf_navigation, args=pdf_args, @@ -859,6 +981,9 @@ CLIPS = { 'diff-review': dict( setup=diff_setup, run=diff_review, args=[PROJECT / 'README'], caption='Right-click a diff line to open that line of the file.'), + 'chords': dict( + setup=chords_setup, run=chords, args=[PROJECT / 'notes.txt'], + caption='Hold left, click middle to cut; click right to paste.'), } -- cgit v1.3 From 5ed124dba2e1d7b1fc5c52baf82919a91f990311 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 1 Oct 2026 15:37:59 -0300 Subject: Three guide clips: columns (Newcol, a look into the new column, Alt-c), search (Grep, n and N over +Search, a look at a hit) and where-commands-run (pwd from the column's tag and from a file's) record_demos.py: a clip may set its own window size (columns is 80x26, scaled to 960 wide), and col_tag_px finds a word in a column's tag. clips.toml lists the three with landing = false. Co-Authored-By: Claude Opus 5.5 --- docs/site/media/captions.txt | 3 + docs/site/media/clips.toml | 18 +++++ docs/site/media/columns.mp4 | Bin 0 -> 294124 bytes docs/site/media/columns.png | Bin 0 -> 157329 bytes docs/site/media/columns.webm | Bin 0 -> 416479 bytes docs/site/media/search.mp4 | Bin 0 -> 280626 bytes docs/site/media/search.png | Bin 0 -> 89899 bytes docs/site/media/search.webm | Bin 0 -> 343657 bytes docs/site/media/where-commands-run.mp4 | Bin 0 -> 199240 bytes docs/site/media/where-commands-run.png | Bin 0 -> 64070 bytes docs/site/media/where-commands-run.webm | Bin 0 -> 239871 bytes test/record_demos.py | 116 +++++++++++++++++++++++++++++++- 12 files changed, 136 insertions(+), 1 deletion(-) create mode 100644 docs/site/media/columns.mp4 create mode 100644 docs/site/media/columns.png create mode 100644 docs/site/media/columns.webm create mode 100644 docs/site/media/search.mp4 create mode 100644 docs/site/media/search.png create mode 100644 docs/site/media/search.webm create mode 100644 docs/site/media/where-commands-run.mp4 create mode 100644 docs/site/media/where-commands-run.png create mode 100644 docs/site/media/where-commands-run.webm (limited to 'test/record_demos.py') diff --git a/docs/site/media/captions.txt b/docs/site/media/captions.txt index 6a1a2274..c8b59699 100644 --- a/docs/site/media/captions.txt +++ b/docs/site/media/captions.txt @@ -6,3 +6,6 @@ terminals-are-panes: A terminal is a pane: Ctrl-b, then move over its output. scripting-over-9p: A script drives the session through its virtual filesystem (9P). diff-review: Right-click a diff line to open that line of the file. chords: Hold left, click middle to cut; click right to paste. +columns: Newcol adds a column; a look opens there; Alt-c moves a pane. +search: Grep lists the hits; n and N walk them; right-click opens one. +where-commands-run: A file's tag runs in its directory; the column tag, in the session's. diff --git a/docs/site/media/clips.toml b/docs/site/media/clips.toml index 37dc9db9..e6cee9bd 100644 --- a/docs/site/media/clips.toml +++ b/docs/site/media/clips.toml @@ -45,3 +45,21 @@ name = "chords" caption = "Hold left, click middle to cut; click right to paste." ready = true landing = false + +[[clip]] +name = "columns" +caption = "Newcol adds a column; a look opens there; Alt-c moves a pane." +ready = true +landing = false + +[[clip]] +name = "search" +caption = "Grep lists the hits; n and N walk them; right-click opens one." +ready = true +landing = false + +[[clip]] +name = "where-commands-run" +caption = "A file's tag runs in its directory; the column tag, in the session's." +ready = true +landing = false diff --git a/docs/site/media/columns.mp4 b/docs/site/media/columns.mp4 new file mode 100644 index 00000000..48bc462b Binary files /dev/null and b/docs/site/media/columns.mp4 differ diff --git a/docs/site/media/columns.png b/docs/site/media/columns.png new file mode 100644 index 00000000..f8cc1801 Binary files /dev/null and b/docs/site/media/columns.png differ diff --git a/docs/site/media/columns.webm b/docs/site/media/columns.webm new file mode 100644 index 00000000..ddb6bdfc Binary files /dev/null and b/docs/site/media/columns.webm differ diff --git a/docs/site/media/search.mp4 b/docs/site/media/search.mp4 new file mode 100644 index 00000000..6c9c9445 Binary files /dev/null and b/docs/site/media/search.mp4 differ diff --git a/docs/site/media/search.png b/docs/site/media/search.png new file mode 100644 index 00000000..40e5bed5 Binary files /dev/null and b/docs/site/media/search.png differ diff --git a/docs/site/media/search.webm b/docs/site/media/search.webm new file mode 100644 index 00000000..e1581570 Binary files /dev/null and b/docs/site/media/search.webm differ diff --git a/docs/site/media/where-commands-run.mp4 b/docs/site/media/where-commands-run.mp4 new file mode 100644 index 00000000..c4bd83fe Binary files /dev/null and b/docs/site/media/where-commands-run.mp4 differ diff --git a/docs/site/media/where-commands-run.png b/docs/site/media/where-commands-run.png new file mode 100644 index 00000000..5af438cc Binary files /dev/null and b/docs/site/media/where-commands-run.png differ diff --git a/docs/site/media/where-commands-run.webm b/docs/site/media/where-commands-run.webm new file mode 100644 index 00000000..c9d35176 Binary files /dev/null and b/docs/site/media/where-commands-run.webm differ diff --git a/test/record_demos.py b/test/record_demos.py index 7ab22d95..9ee5ba53 100644 --- a/test/record_demos.py +++ b/test/record_demos.py @@ -959,6 +959,110 @@ def chords(s): s.chord_release(after=1.0) +def column(s, serial): + """Column `serial`'s (first cell, width) from /layout.""" + for line in s.read('/layout').splitlines(): + parts = line.split() + if parts and parts[0] == str(serial): + return int(parts[2]), int(parts[3]) + raise LookupError(f'no column {serial}') + + +def col_tag_px(s, serial, at, offset=.5): + """The pixel over character `at` of column `serial`'s tag (row 1 of the + window, wrapping at the column's width in the tagline font).""" + x0, width = column(s, serial) + w, h = s.size() + cw, ch = w / s.cols, h / s.rows + per_row = int((width * cw - 3 * cw) // TAG_W) + return int((x0 + 3) * cw + (at % per_row + offset) * TAG_W), int((1 + at // per_row + .55) * ch) + + +def columns_setup(s): + s.write('/pane/1/look', f'{PROJECT}/src/main.c\n') + s.wait(lambda: len(s.panes()) == 2, 'main.c') + s.mouse('motion', 0, *s.cell_px(s.cols - 2, s.rows - 1)) + + +def columns(s): + """Newcol makes a column; a name typed in its tag and looked at opens + there; Alt-c gives a pane a column of its own.""" + s.pointer = s.cell_px(30, 12) + s.shot(1.0) + s.click(2, *s.tag_px(3, 0, start=0), done=lambda: len(s.read('/layout').splitlines()) == 3, what='Newcol', + after=.8) + new = s.read('/layout').splitlines()[1].split()[0] + tag = s.read(f'/col/{new}/tag').rstrip('\n') + # B1 just past the tag's last word puts the typing there. + s.click(1, *col_tag_px(s, new, len(tag), offset=.4), after=.2) + s.type(' Makefile', lambda typed: s.read(f'/col/{new}/tag').rstrip('\n').endswith(typed), per_key=.06) + s.shot(.3) + at = s.read(f'/col/{new}/tag').index('Makefile') + 4 + s.click(3, *col_tag_px(s, new, at), done=lambda: len(s.panes()) == 3, what='the Makefile', after=1.3) + # Alt-c on main.c: it leaves for a column of its own. + main = next(n for n in s.panes() if s.read(f'/pane/{n}/name').strip().endswith('main.c')) + col, row = s.find('int main', 0) + s.click(1, *s.cell_px(col + 4, row), done=lambda: s.read('/focus').strip() == str(main), what='focus', + after=.3) + s.badge = 'Alt-c' + s.keys('\x1bc') + s.wait(lambda: len(s.read('/layout').splitlines()) == 4, 'the new column') + s.shot(2.2, poster=True) + s.badge = None + + +def search_setup(s): + (PROJECT / 'tests').mkdir() + (PROJECT / 'tests/check.sh').write_text('#!/bin/sh\n# 1 + 4 + 9 + 16: the sum of the squares is 30\n' + './hello | grep -q "sum: 30"\n') + s.write('/pane/1/look', f'{PROJECT}/src/main.c\n') + s.wait(lambda: len(s.panes()) == 2, 'main.c') + s.write('/focus', '2\n') + s.mouse('motion', 0, *s.cell_px(COLS - 2, ROWS - 1)) + + +def search(s): + """Grep (SPC f g) lists the hits in +Search; n and N walk them; B3 on + one opens its file there.""" + s.pointer = s.cell_px(44, 8) + s.shot(1.0) + s.press([(' ', 'SPC'), ('f', 'SPC f'), ('g', 'SPC f g')], per_key=.35) + s.badge = 'SPC f g square' + s.type('square', lambda typed: True, per_key=.07) + s.badge = 'Enter' + s.keys('\r') + s.wait(lambda: any(s.read(f'/pane/{n}/name').strip().endswith('+Search') for n in s.panes()), '+Search') + s.shot(1.0) + s.press([('n', 'n'), ('n', 'n n'), ('N', 'n n N')], per_key=.7) + s.shots[-2]['poster'] = True # the listing whole, the second hit current + s.badge = None + col, row = s.find('check.sh:', 0) + s.click(3, *s.cell_px(col + 3, row), done=lambda: len(s.panes()) == 4, what='check.sh', after=2.2) + + +def where_setup(s): + """main.c, with pwd in the column's tag and in main.c's.""" + s.write('/col/1/tag', ' pwd') + s.write('/pane/1/tag', ' pwd') + s.mouse('motion', 0, *s.cell_px(COLS - 2, ROWS - 1)) + + +def where_commands_run(s): + """pwd from the column's tag prints the session's directory; from + main.c's tag, main.c's.""" + s.pointer = s.cell_px(40, 12) + s.shot(1.2) + tag = s.read('/col/1/tag') + s.click(2, *col_tag_px(s, 1, tag.index('pwd') + 1), + done=lambda: any(kind == 'cmd' and 'exit' in s.tag(n) for n, kind in s.panes().items()), what='pwd', + after=1.6) + s.click(2, *s.tag_word(1, 'pwd'), + done=lambda: any(kind == 'cmd' and s.read(f'/pane/{n}/body').startswith('% pwd\n/tmp/hello/src') + and 'exit' in s.tag(n) for n, kind in s.panes().items()), + what='pwd in src', after=2.6) + s.shots[-1]['poster'] = True + + CLIPS = { 'pdf-navigation': dict( setup=pdf_setup, run=pdf_navigation, args=pdf_args, @@ -984,6 +1088,15 @@ CLIPS = { 'chords': dict( setup=chords_setup, run=chords, args=[PROJECT / 'notes.txt'], caption='Hold left, click middle to cut; click right to paste.'), + 'columns': dict( + setup=columns_setup, run=columns, args=[PROJECT / 'README'], cols=80, rows=26, + caption='Newcol adds a column; a look opens there; Alt-c moves a pane.'), + 'search': dict( + setup=search_setup, run=search, args=[PROJECT / 'README'], + caption='Grep lists the hits; n and N walk them; right-click opens one.'), + 'where-commands-run': dict( + setup=where_setup, run=where_commands_run, args=[PROJECT / 'src/main.c'], + caption="A file's tag runs in its directory; the column tag, in the session's."), } @@ -991,7 +1104,8 @@ def record(binary, work, name): clip = CLIPS[name] make_project() args = clip['args']() if callable(clip['args']) else clip['args'] - s = Session(binary, work / name, 'rec-' + name, args, init=clip.get('init', '')) + s = Session(binary, work / name, 'rec-' + name, args, init=clip.get('init', ''), + cols=clip.get('cols', COLS), rows=clip.get('rows', ROWS)) try: if 'setup' in clip: clip['setup'](s) -- cgit v1.3 From ff102e082105c78f4cc27487f550ee84d364c16c Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 1 Oct 2026 15:56:55 -0300 Subject: Two scripting clips: edit-via-ctl (an Edit written to a pane's ctl from a shell, then one Undo) and wait-editor (git commit with EDITOR='pardes --wait', its message a pane, Save and Del) record_demos.py: Esc goes to the test window as CSI u (ESC [27u): a bare ESC byte waited in the stdin feed's parser and joined the next mouse event, which then typed itself into the pane. clips.toml lists both with landing = false. Co-Authored-By: Claude Opus 5.5 --- docs/site/media/captions.txt | 2 + docs/site/media/clips.toml | 12 ++++++ docs/site/media/edit-via-ctl.mp4 | Bin 0 -> 140021 bytes docs/site/media/edit-via-ctl.png | Bin 0 -> 59240 bytes docs/site/media/edit-via-ctl.webm | Bin 0 -> 134014 bytes docs/site/media/wait-editor.mp4 | Bin 0 -> 165106 bytes docs/site/media/wait-editor.png | Bin 0 -> 70946 bytes docs/site/media/wait-editor.webm | Bin 0 -> 165519 bytes test/record_demos.py | 83 ++++++++++++++++++++++++++++++++++++++ 9 files changed, 97 insertions(+) create mode 100644 docs/site/media/edit-via-ctl.mp4 create mode 100644 docs/site/media/edit-via-ctl.png create mode 100644 docs/site/media/edit-via-ctl.webm create mode 100644 docs/site/media/wait-editor.mp4 create mode 100644 docs/site/media/wait-editor.png create mode 100644 docs/site/media/wait-editor.webm (limited to 'test/record_demos.py') diff --git a/docs/site/media/captions.txt b/docs/site/media/captions.txt index c8b59699..4879cb12 100644 --- a/docs/site/media/captions.txt +++ b/docs/site/media/captions.txt @@ -9,3 +9,5 @@ chords: Hold left, click middle to cut; click right to paste. columns: Newcol adds a column; a look opens there; Alt-c moves a pane. search: Grep lists the hits; n and N walk them; right-click opens one. where-commands-run: A file's tag runs in its directory; the column tag, in the session's. +edit-via-ctl: An Edit written to ctl changes every sum; one Undo restores. +wait-editor: git commit's message opens in a pane; Del returns it to git. diff --git a/docs/site/media/clips.toml b/docs/site/media/clips.toml index 0ad8b173..f2406396 100644 --- a/docs/site/media/clips.toml +++ b/docs/site/media/clips.toml @@ -63,3 +63,15 @@ name = "where-commands-run" caption = "File tags run in their directory; column tags, in the session's." ready = true landing = false + +[[clip]] +name = "edit-via-ctl" +caption = "An Edit written to ctl changes every sum; one Undo restores." +ready = true +landing = false + +[[clip]] +name = "wait-editor" +caption = "git commit's message opens in a pane; Del returns it to git." +ready = true +landing = false diff --git a/docs/site/media/edit-via-ctl.mp4 b/docs/site/media/edit-via-ctl.mp4 new file mode 100644 index 00000000..d63f6e7f Binary files /dev/null and b/docs/site/media/edit-via-ctl.mp4 differ diff --git a/docs/site/media/edit-via-ctl.png b/docs/site/media/edit-via-ctl.png new file mode 100644 index 00000000..7a21d734 Binary files /dev/null and b/docs/site/media/edit-via-ctl.png differ diff --git a/docs/site/media/edit-via-ctl.webm b/docs/site/media/edit-via-ctl.webm new file mode 100644 index 00000000..77639d34 Binary files /dev/null and b/docs/site/media/edit-via-ctl.webm differ diff --git a/docs/site/media/wait-editor.mp4 b/docs/site/media/wait-editor.mp4 new file mode 100644 index 00000000..49adadd6 Binary files /dev/null and b/docs/site/media/wait-editor.mp4 differ diff --git a/docs/site/media/wait-editor.png b/docs/site/media/wait-editor.png new file mode 100644 index 00000000..1d029f4c Binary files /dev/null and b/docs/site/media/wait-editor.png differ diff --git a/docs/site/media/wait-editor.webm b/docs/site/media/wait-editor.webm new file mode 100644 index 00000000..5afda502 Binary files /dev/null and b/docs/site/media/wait-editor.webm differ diff --git a/test/record_demos.py b/test/record_demos.py index 9ee5ba53..3c64f55c 100644 --- a/test/record_demos.py +++ b/test/record_demos.py @@ -1063,6 +1063,83 @@ def where_commands_run(s): s.shots[-1]['poster'] = True +GIT_ID = dict(GIT_AUTHOR_NAME='demo', GIT_AUTHOR_EMAIL='demo@example.com', + GIT_COMMITTER_NAME='demo', GIT_COMMITTER_EMAIL='demo@example.com') + + +def edit_setup(s): + """main.c over a shell that sees the session as files ($m, as in the + scripting chapter: 9ns mounts the pane's $PARDES_9P), and Undo in + main.c's tag.""" + shell_setup(s) + mount = HOME / 'n' + mount.mkdir() + s.write('/pane/2/pty/data', f'exec 9ns --unix "$PARDES_9P" --mount {mount} -- /bin/sh\r') + time.sleep(1.5) # 9ns mounts and starts the shell that reads the next line + s.write('/pane/2/pty/data', f"m=$NINE_MOUNT; cd {PROJECT}; PS1='$ '; clear\r") + s.wait(lambda: [line.rstrip() for line in s.terminal_rows() if line.strip()] == [' $'], 'the mounted shell') + s.write('/pane/1/tag', ' Undo') + s.write('/pane/1/dot', '$\n') + s.mouse('motion', 0, *s.cell_px(COLS - 2, 1)) + + +def edit_via_ctl(s): + """An Edit written to the pane's ctl changes every sum; one Undo puts + them all back.""" + s.pointer = s.cell_px(44, 7) + s.shot(1.0) + command = "echo 'Edit ,x/sum/c/total/' > $m/pane/1/ctl" + s.type(command, lambda typed: at_prompt(s, typed)(), per_key=.055) + s.keys('\r') + s.wait(lambda: 'sum' not in s.read('/pane/1/body'), 'the edit') + s.shot(1.6, poster=True) + s.click(2, *s.tag_word(1, 'Undo'), done=lambda: s.read('/pane/1/body').count('sum') == 4, what='Undo', + after=2.0) + + +def wait_setup(s): + """A git repo with a change staged, and a lone shell whose EDITOR is + pardes --wait (a `pardes` on its PATH: this pardes-gui).""" + env = dict(clean_env(), HOME=str(HOME), **GIT_ID) + for args in (['init', '-q'], ['add', '.'], ['commit', '-qm', 'hello']): + subprocess.run(['git', '-C', str(PROJECT), *args], check=True, env=env, capture_output=True) + main = PROJECT / 'src/main.c' + main.write_text(main.read_text().replace('pritnf', 'printf')) + (HOME / 'bin').mkdir() + (HOME / 'bin/pardes').symlink_to(s.binary) + shell_setup(s) + ids = ' '.join(f'{k}={v}' for k, v in GIT_ID.items()) + s.write('/pane/2/pty/data', f"export PATH=$HOME/bin:$PATH EDITOR='pardes --wait' {ids}; git add -A; clear\r") + s.write('/pane/1/exec', 'Del\n') + s.wait(lambda: list(s.panes()) == [2], 'the README to close') + s.wait(lambda: [line.rstrip() for line in s.terminal_rows() if line.strip()] == [' $'], 'the prompt') + + +def wait_editor(s): + """git commit opens its message in a pane of this session; Save and + Del, and git commit returns.""" + s.pointer = s.cell_px(44, 9) + s.shot(1.0) + s.type('git commit', lambda typed: at_prompt(s, typed)(), per_key=.07) + s.keys('\r') + s.wait(lambda: len(s.panes()) == 2, 'the message pane') + msg = next(n for n in s.panes() if n != 2) + s.shot(1.0) + s.press([('i', 'i')], per_key=.3) + s.badge = 'i' + s.type('Fix the printf typo', lambda typed: typed in s.read(f'/pane/{msg}/body'), per_key=.05) + # Esc as a CSI u sequence: a bare ESC byte waits in the stdin feed's + # parser for what follows, and the next mouse event would join it. + s.press([('\x1b[27u', 'Esc')], per_key=.4) + s.shots[-1]['poster'] = True # git waiting, its message typed in the pane + s.click(2, *s.tag_word(msg, 'Save'), done=lambda: s.read(f'/pane/{msg}/dirty').strip() == '0', what='Save', + after=.6) + s.click(2, *s.tag_word(msg, 'Del'), done=lambda: list(s.panes()) == [2], what='Del', after=.3) + s.wait(lambda: any('Fix the printf typo' in line for line in s.terminal_rows()), 'git commit') + s.wait(lambda: [line.rstrip() for line in s.terminal_rows() if line.strip()][-1] == ' $', 'the prompt') + s.shot(2.4) + + CLIPS = { 'pdf-navigation': dict( setup=pdf_setup, run=pdf_navigation, args=pdf_args, @@ -1097,6 +1174,12 @@ CLIPS = { 'where-commands-run': dict( setup=where_setup, run=where_commands_run, args=[PROJECT / 'src/main.c'], caption="A file's tag runs in its directory; the column tag, in the session's."), + 'edit-via-ctl': dict( + setup=edit_setup, run=edit_via_ctl, args=[PROJECT / 'src/main.c'], + caption='An Edit written to ctl changes every sum; one Undo restores.'), + 'wait-editor': dict( + setup=wait_setup, run=wait_editor, args=[PROJECT / 'README'], + caption="git commit's message opens in a pane; Del returns it to git."), } -- cgit v1.3