Jump to content

Cocoa text system

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by 119.18.13.17 (talk) at 01:00, 16 August 2020 (improve wording to move *Step description further down page). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

The Cocoa text system is the linked network of classes, protocols, interfaces and objects that provide typography and text field editing capabilities and to Cocoa applications on Apple's OSX, where it is the primary text-handling system.[1] Although "extremely complex", the standard text-handling abilities of the Cocoa text system have been widely praised as without peer.[2][3]

Derived from Next Inc.'s OpenStep API specification (implemented in NeXT's OPENSTEP operating system, and probably also in the earlier NeXTSTEP[citation needed] platform), the bulk of Cocoa has been implemented successfully in third-party implementations such as the opensource GNUStep.[4] the Cocoa text system can use many of the Emacs keybindings that programmers are familiar with.[5] 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.[6]

The Cocoa text system uses a Model-View-Controller design pattern.[7] The view layer is handled by NSTextView and NSTextField, NSLayoutManager and NSTextContainer are the controller layer, and NSTextStorage (a mutable attributed string subclass) is the model.[8]

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.[9][10]

References

  1. ^ "About the Cocoa Text System".
  2. ^ "Cocoa Programming".
  3. ^ "Arise Aqua!". You'll build a word processor capable of handling kerning, justification, sub and superscripting, full Unicode support, spell checking, multiple font and paragraph styles, drag and drop of embedded graphics and colors, rulers with adjustable tab stops, reading and writing of conforming RTFD files, all in less than 13 lines of code! You cannot do this in any other development environment on the planet.
  4. ^ "GNUStep". gnustep.org. Retrieved 2020-08-16.
  5. ^ "Cocoa Text System".
  6. ^ "Beginning Objective C".
  7. ^ "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".
  8. ^ "From Win32 to Cocoa: a Windows user's conversion to Mac OS X?Part III".
  9. ^ "Rich Text Handling".
  10. ^ "Getting Started Developing For Mac OS X". There is very little custom code in TE and what is there is basically only the code necessary to make the AppKit behave like a text editor.