Source code, published until OS X 10.9: https://developer.apple.com/library/archive/samplecode/TextE...