TextEdit's full (?) source code is available online
developer.apple.com
developer.apple.com
(see: http://www.musingsfrommars.org/2007/03/using-text-edit-as-ht...)
While researching ways to parse the Web Archive HTML format it outputs, and was surprised to find Apple makes the entire source code for TextEdit available to any developer. Nice!