Cocoa text system
The Cocoa text system is the linked network of classes, protocols, interfaces and objects that provide typography and text field editing capabilities to Cocoa applications on OSX. Although "extremely complex", the standard text-handling abilities of the Cocoa text system have been called "unmatched on any platform".[1] GNUSTEP implements a similar, broadly-compatible system.[2]
Derived from OPENSTEP, the Cocoa text system can use many Emacs keybindings for programmer familiarity.[3] Users interact with two classes, NSTextField (providing single-line edit fields) or NSTextView (providing multi-line editing). Each NSTextField uses a shared instance of a NSTextView called the "field editor". This was done to reduce high memory requirements that would arise if every field implemented its own NSTextView object graph when only one field can actually have focus at any time.
The Cocoa text system uses a Model-View-Controller layout.[4] The view layer is handled by NSTextView and NSTextField, NSLayoutManager and NSTextContainer are the controller layer, and NSTextStorage (a mutable string subclass) is the model.
The Cocoa text system also interacts with Services to provide standard streams functionality in a GUI environment. It is possible to implement a fully featured rich text editor in only a few lines of code.[5]
External links
References
- ↑ "Cocoa Programming".
- ↑ "NSTextView.html".
- ↑ "Cocoa Text System".
- ↑ "The Cocoa text system’s architecture is both modular and layered to enhance its ease of use and flexibility. Its modular design reflects the Model-View-Controller paradigm (originating with Smalltalk-80) where the data, its visual representation, and the logic that links the two are represented by separate objects. In the case of the text system, NSTextStorage holds the model’s text data, NSTextContainer models the geometry of the layout area, NSTextView presents the view, and NSLayoutManager intercedes as the controller to make sure that the data and its representation onscreen stay in agreement.".
- ↑ "Rich Text Handling".