hogbaysoftware.com
1d ago
I released WriteRoom "distraction-free writing" in 2006. The original was a NSTextView wrapper. Jump forward 20 years, a few failed rewrites, and I've built something new. From the simplest thing that could possibly work, to the opposite! This version is built from scratch. Maybe not smart, but has some benefits. Here's what I did and what it allowed me. WriteRoom is a Swift document based app. It supports macOS technologies back to AppleScript. It also supports Shortcuts and a terminal command with MCP. I think it's a Mac-assed app. The editor component is custom built in Rust, using the GPU for display. At a high level the editor is: 1. Ropey[^1] crate for text storage 2. Ported/Modified CodeMirror Markdown tree 3. Sorted range lists, for selection, folds and annotations 4. CodeMirror-style height map tree for scrolling 5. WGPU crate for text atlas drawing 6. CoreText for text shaping/layout 7. Wrapped in NSView for native scrolling, integration What fun things does this setup allow? Flexible themes. Such as a DEC terminal as described in [^2]. Scanlines are applied at text atlas level to DEC ROM characters. Optional screen curvature is also applied. Can't do that with NSTextView. Extreme performance. I test with the Moby Dick Workout [^3] * 1000. Over a gigabyte of Markdown structure loads in about a second and finishes parsing a few seconds later. Typing/scrolling/etc feel as fast as when typing in an empty document. Full control makes it possible to make things really fast. Word/char counts are surprisingly expensive. Ropey and the Markdown tree are both cheap to snapshot because they share structure, so the parse and the word count both run on background threads and catch up while you type. Mixing in IDE features such as sticky headings and minimap scrollers. That at runtime require an markdown tree for good performance and ability to do a lot of fast text drawing. Numbered headings is another nice feature, but hard to implement without custom markdown tree.
Listed via hackernews
Comments
sign in to join the conversation.
~JustBuildApps