Cocoa text system

Last updated

The Cocoa text system (formerly known simply by the primary class name NSText) 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 macOS, 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] It is possible to implement a fully featured rich text editor in only a few lines of code. [4] [5]

Formerly embodied [6] in developer NeXT Inc.'s OpenStep API specification, and implemented in NeXT's OPENSTEP operating system, and probably also in the earlier NeXTSTEP [ citation needed ] platform, Cocoa's NSText has additionally been implemented via the OpenStep API specification successfully in third-party implementations such as the free-and-open-source GNUstep. [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. 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. [9]

Cocoa adopts many Emacs keybindings familiar to programmers. [10]

Related Research Articles

<span class="mw-page-title-main">NeXTSTEP</span> Operating system from NeXT Computer

NeXTSTEP is a discontinued object-oriented, multitasking operating system based on the Mach kernel and the UNIX-derived BSD. It was developed by NeXT Computer, founded by Steve Jobs, in the late 1980s and early 1990s and was initially used for its range of proprietary workstation computers such as the NeXTcube. It was later ported to several other computer architectures.

Darwin is the core Unix operating system of macOS, iOS, watchOS, tvOS, iPadOS, visionOS, and bridgeOS. It previously existed as an independent open-source operating system, first released by Apple Inc. in 2000. It is composed of code derived from NeXTSTEP, FreeBSD, other BSD operating systems, Mach, and other free software projects' code, as well as code developed by Apple.

<span class="mw-page-title-main">OpenStep</span> Defunct object-oriented application programming interface specification

OpenStep is an object-oriented application programming interface (API) specification that was developed by NeXT Computer. It provides a framework for building graphical user interfaces (GUIs) and developing software applications. OpenStep was designed to be platform-independent, allowing developers to write code that could run on multiple operating systems, including NeXTSTEP, Windows NT, and various Unix-based systems. It has influenced the development of other GUI frameworks, such as Cocoa for macOS and GNUstep.

<span class="mw-page-title-main">TextEdit</span> Open-source word processor and text editor

TextEdit is an open-source word processor and text editor, first featured in NeXT's NeXTSTEP and OPENSTEP. It is now distributed with macOS since Apple Inc.'s acquisition of NeXT, and available as a GNUstep application for other Unix-like operating systems such as Linux. It is powered by Apple Advanced Typography.

Cocoa is Apple's native object-oriented application programming interface (API) for its desktop operating system macOS.

<span class="mw-page-title-main">GNUstep</span> Open source widget toolkit and application development tools

GNUstep is a free software implementation of the Cocoa Objective-C frameworks, widget toolkit, and application development tools for Unix-like operating systems and Microsoft Windows. It is part of the GNU Project.

Carbon was one of two primary C-based application programming interfaces (APIs) developed by Apple for the macOS operating system. Carbon provided a good degree of backward compatibility for programs that ran on Mac OS 8 and 9. Developers could use the Carbon APIs to port (“carbonize”) their “classic” Mac applications and software to the Mac OS X platform with little effort, compared to porting the app to the entirely different Cocoa system, which originated in OPENSTEP. With the release of macOS 10.15 Catalina, the Carbon API was officially discontinued and removed, leaving Cocoa as the sole primary API for developing macOS applications.

The Enterprise Objects Framework, or simply EOF, was introduced by NeXT in 1994 as a pioneering object-relational mapping product for its NeXTSTEP and OpenStep development platforms. EOF abstracts the process of interacting with a relational database by mapping database rows to Java or Objective-C objects. This largely relieves developers from writing low-level SQL code.

Portable Distributed Objects (PDO) is an application programming interface (API) for creating object-oriented code that can be executed remotely on a network of computers. It was created by NeXT Computer, Inc. using their OpenStep system, whose use of Objective-C made the package very easy to write. It was characterized by its very light weight and high speed in comparison to similar systems such as CORBA.

The Foundation Kit, or just Foundation for short, is an Objective-C framework in the OpenStep specification described by NeXT Computer, Inc.. It provides basic classes such as wrapper classes and data structure classes. This framework uses the prefix NS. It is also part of Cocoa and of the Swift standard library.

<span class="mw-page-title-main">WebObjects</span> Java web application server and framework originally developed by NeXT Software

WebObjects is a discontinued Java web application server and a server-based web application framework originally developed by NeXT Software, Inc.

Apple events are the message-based interprocess communication mechanism in Mac OS, first making an appearance in System 7 and supported by every version of the classic Mac OS since then and by macOS. Apple events describe "high-level" events such as "open document" or "print file", whereas earlier OSs had supported much more basic events, namely "click" and "keypress". Apple events form the basis of the Mac OS scripting system, the Open Scripting Architecture.

<span class="mw-page-title-main">AppKit</span> Graphical user interface toolkit

AppKit is a graphical user interface toolkit. It initially served as the UI framework for NeXTSTEP. Along with Foundation and Display PostScript, it became one of the core parts of the OpenStep specification of APIs. Later, AppKit and Foundation became part of Cocoa, the Objective-C API framework of macOS. GNUstep, GNU's implementation of the OpenStep/Cocoa API, also contains an implementation of the AppKit API.

Core Data is an object graph and persistence framework provided by Apple in the macOS and iOS operating systems. It was introduced in Mac OS X 10.4 Tiger and iOS with iPhone SDK 3.0. It allows data organized by the relational entity–attribute model to be serialized into XML, binary, or SQLite stores. The data can be manipulated using higher level objects representing entities and their relationships. Core Data manages the serialized version, providing object lifecycle and object graph management, including persistence. Core Data interfaces directly with SQLite, insulating the developer from the underlying SQL.

In the macOS, iOS, NeXTSTEP, and GNUstep programming frameworks, property list files are files that store serialized objects. Property list files use the filename extension .plist, and thus are often referred to as p-list files.

<span class="mw-page-title-main">Architecture of macOS</span> Layers of the operating system

The architecture of macOS describes the layers of the operating system that is the culmination of Apple Inc.'s decade-long research and development process to replace the classic Mac OS.

The term target–action design paradigm refers to a kind of software architecture, where a computer program is divided into objects which dynamically establish relationships by telling each other which object they should target and what action or message to send to that target when an event occurs. This is especially useful when implementing graphical user interfaces, which are by nature event-driven.

Cocoa Touch is the application development environment for building software programs to run on iOS for the iPhone and iPod Touch, iPadOS for the iPad, watchOS for the Apple Watch, and tvOS for the Apple TV, from Apple Inc.

Objective-C is a high-level general-purpose, object-oriented programming language that adds Smalltalk-style messaging to the C programming language. Originally developed by Brad Cox and Tom Love in the early 1980s, it was selected by NeXT for its NeXTSTEP operating system. Due to Apple macOS’s direct lineage from NeXTSTEP, Objective-C was the standard programming language used, supported, and promoted by Apple for developing macOS and iOS applications until the introduction of the Swift programming language in 2014.

References

  1. Apple Inc. (2014-02-11). "About the Cocoa Text System". Cocoa Text Architecture Guide. Retrieved 2023-02-19.
  2. Anguish, Scott; Buck, Erik M.; Yacktman, Donald A. (2003). Cocoa Programming. ISBN   9780672322303.
  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. "Rich Text Handling". O'Reilly Commons. 2008-03-07. Archived from the original on 2016-07-21.
  5. "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.
  6. 1 2 "GNUstep". gnustep.org. Retrieved 2020-08-16.
  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. Bright, Peter (2008-06-01). "From Win32 to Cocoa: a Windows user's would-be conversion to Mac OS X, Part III". Ars Technica . Retrieved 2023-02-19.
  9. Dovey, James; Furrow, Ashley Alonzo Hale (4 January 2013). Beginning Objective C. ISBN   9781430243694.
  10. Rus, Jacob (2006-03-20). "Customizing the Cocoa Text System". Archived from the original on 2018-10-07.