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> |
||
|---|---|---|
| examples | Fix panic: defer document swaps to frame top (Open/New with timeline open) | |
| fonts | Initial commit: Fountain bridge + read-only screenplay viewer | |
| scripts | Editing milestone: selection, formatting, clipboard, Final Draft interop | |
| src | Pagination cache: O(1) measure / O(visible) draw during scroll | |
| test | Fix scroll fps drop on large scripts (timeline/outline rebuilds + labels) | |
| .gitignore | Fix scroll fps drop on large scripts (timeline/outline rebuilds + labels) | |
| build.zig | Consume zfdx: clipboard RTF via the lib + .fdx open/save | |
| build.zig.zon | Consume zfdx: clipboard RTF via the lib + .fdx open/save | |
| CLAUDE.md | Initial commit: Fountain bridge + read-only screenplay viewer | |
| context.md | Consume zfdx: clipboard RTF via the lib + .fdx open/save | |
| DESIGN.md | Pagination cache: O(1) measure / O(visible) draw during scroll | |
| TODO.md | Add theming + outline sidebar | |