Live data from Hacker News

Nerdy internals of an Apple text editor

papereditor.app

31–40 of 93 posts

Re: Nerdy internals of an Apple text editor

#35

It's a real shame that Apple doesn't release the source to a recent version of TextEdit. Given its structure (more or less just a stock objects from the API) it would be super educational for anyone who wants to use NSTextView et al.

Yeah, you can get pretty close to TextEdit by just dropping an NSTextView into the document window XIB of a document-based Mac app, hooking up the data methods in your Document class to it, and doing a little bit of wiring of menu items to the textview. Text formatting bar, rulers, Find in Page, font panel, etc. There’s a few things missing but not a ton.

The document-based app template gets you a lot for “free” too, including tabs and conversion of windows into tabs and vice versa.

Re: Nerdy internals of an Apple text editor

#36
I'm a little confused at the part about decorative attributes being done outside of the editing transaction, saying "And they are not even aware of the transaction since they live in the NSLayoutManager itself, not in NSTextStorage". Decorative attributes like color do normally live in the NSTextStorage! Is the author implying that the colors applied to markdown characters are being done with NSLayoutManager's temporary attributes support (typically used to color misspelled words)? What would be the purpose of that?

Re: Nerdy internals of an Apple text editor

#37

The UI of this doc is absolutely beautiful

There are several elements that are practically invisible though: play/pause buttons on the sides, comments in parentheses, explanatory text on graphics.

It's a shame because otherwise the presentation is really good.

Post reply on HN