Show HN: WriteRoom – Dec Terminal, Markdown, Fast (macOS)

www.hogbaysoftware.com

8 points by jessegrosjean 1 day 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. The feature is that your ### headings are rendered as numbers, so you might see 1.2.3 for a level 3 heading in first section. Feels quite nice and different in longer structured documents.

Overview mode is another feature, it mixes the minimap display with your regular document. So for example you can "zoom" and see your headings in normal text while everything else is minimap. All with a fast smooth animation. Inspired by MakePad editor[^4].

Thoughts and questions welcome.

[^1] Ropey – A UTF8 text rope for editing large text - https://news.ycombinator.com/item?id=42711966

[^2] Raster CRT Typography (According to DEC) - https://news.ycombinator.com/item?id=19528618

[^3] Moby Dick Workout - https://news.ycombinator.com/item?id=48791266

[^4] MakePad - https://makepad.dev

Gabrielmfern 19 hours ago

Congrats on the release! Have some questions I'm interested on for learning more about from people building UI apps like these:

What part of having a native feel do you think matters more to you? I'm always intrigued by those who are of the opinion apps are better when they feel closer to the operating system even at other costs.

What part of doing what NSTextView did from scratch do you think was the hardest? IME, accessibility or spell checking? Also interested in if it has any of these or not.

Did you think about using any other stack? Perhaps, building it in the web, perhaps using some UI framework/library, another language?

Sorry for the barrage of questions, I'd be fine if you answered only one if you could :)

  • jessegrosjean 18 hours ago

    > What part of having a native feel do you think matters more to you?

    I think scroll behavior is most noticeable. If an app doesn't have same scroll characteristics provided by NSScrollView then it immediately feels off to me.

  • jessegrosjean 18 hours ago

    > What part of doing what NSTextView did from scratch do you think was the hardest?

    Hard to say... it's all solvable. Just lots of separate steps. I guess spell checking might be most complex since it needs to be asynchronous. While IME is always source of bugs because it has so much different behaviors, depending on language, so you never really know if it's fully working.

    Apple should really generate some automatic test suites for these kinds of things.

    WriteRoom support Spell check, IME, Accessibility, Writing Tools... plugs into everything it can.

  • jessegrosjean 18 hours ago

    > Did you think about using any other stack? Perhaps, building it in the web, perhaps using some UI framework/library, another language?

    I wanted a good Mac app, so the idea was always to embed editor in standard Mac app. I did original start with embedding a CodeMirror web view into the app and took that quite far. CodeMirror is really great. But in the end I couldn't do the DEC theme using WebView like I wanted. And at some point I decided I wanted full control of the editor to unlock abilities like overview mode.