1
0
Fork
You've already forked reveal
0
A screenwriting editor application.
  • Zig 92.4%
  • Scheme 5.9%
  • Python 1.3%
  • Swift 0.4%
Mikael Säker f94772edba Pagination cache: O(1) measure / O(visible) draw during scroll
The measure and draw passes re-flowed the entire document into pages every
frame. The flow is deterministic given (edit_version, page size, title-page
presence) and expressed in page-size-relative LINE units, so scroll and zoom
don't change it — memoize it.
`paginate(g)` fills g_pg (per-block page + start line + span + dual-pair end),
keyed on that signature; reset on doc swap. `renderDocument` reads positions
from the cache:
- measure: O(1) — caret via computeCaret (the cursor block may be off-screen),
 the whole-doc walk runs only when there's a click to resolve;
- draw: O(visible) — firstVisibleUnit binary-searches the first on-screen block,
 then the loop stops once past the viewport.
Verified identical output: Big Fish still 129 pages, deep scroll (caret at block
2400 → page 113/129) renders correctly with the right page numbers and caret.
Measured (Debug, simulated scroll, timeline open):
- Big Fish (2.7k blocks): 3.6ms → 2.2ms/frame.
- Monster (43.5k blocks): 39ms → 14.5ms/frame (1031ms → 14.5ms overall).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026年07月03日 20:13:59 +02:00
examples Fix panic: defer document swaps to frame top (Open/New with timeline open) 2026年07月01日 09:25:49 +02:00
fonts Initial commit: Fountain bridge + read-only screenplay viewer 2026年06月09日 14:51:43 +02:00
scripts Editing milestone: selection, formatting, clipboard, Final Draft interop 2026年06月17日 14:18:01 +02:00
src Pagination cache: O(1) measure / O(visible) draw during scroll 2026年07月03日 20:13:59 +02:00
test Fix scroll fps drop on large scripts (timeline/outline rebuilds + labels) 2026年07月03日 12:53:46 +02:00
.gitignore Fix scroll fps drop on large scripts (timeline/outline rebuilds + labels) 2026年07月03日 12:53:46 +02:00
build.zig Consume zfdx: clipboard RTF via the lib + .fdx open/save 2026年07月01日 08:35:13 +02:00
build.zig.zon Consume zfdx: clipboard RTF via the lib + .fdx open/save 2026年07月01日 08:35:13 +02:00
CLAUDE.md Initial commit: Fountain bridge + read-only screenplay viewer 2026年06月09日 14:51:43 +02:00
context.md Consume zfdx: clipboard RTF via the lib + .fdx open/save 2026年07月01日 08:35:13 +02:00
DESIGN.md Pagination cache: O(1) measure / O(visible) draw during scroll 2026年07月03日 20:13:59 +02:00
TODO.md Add theming + outline sidebar 2026年06月17日 18:05:40 +02:00