Clipboard (computing)
The clipboard is a buffer that some operating systems provide for short-term storage and transfer within and between application programs. The clipboard is usually temporary and unnamed, and its contents reside in the computer's RAM. The clipboard is sometimes called the paste buffer.
An operating system that supports a clipboard provides an application programming interface by which programs can specify cut, copy and paste operations. It is left to the program to define methods for the user to command these operations, which may include keybindings and menu selections. When an element is copied or cut, the clipboard must store enough information to enable a sensible result no matter where the element is pasted. Application programs may extend the clipboard functions that the operating system provides. A clipboard manager may give the user additional control over the clipboard. Specific clipboard semantics vary among operating systems, can also vary between versions of the same system, and can sometimes be changed by programs and by user preferences.
Windows, Linux and macOS support a single clipboard transaction. Each cut or copy overwrites the previous contents. Normally, paste operations copy the contents, leaving the contents available in the clipboard for further pasting.
The pointing device gesture of drag and drop may let a user move information within and between applications, independent of the clipboard.
History
Clipboards as buffers for small text snippets were first used by Pentti Kanerva when he used it to store deleted texts in order to restore them. Since one could delete a text in one place and restore it in another, the term "delete" wasn't what one would expect in this case. Larry Tesler renamed this in 1973 as cut, copy, and paste and coined the term "clipboard" for this buffer, since these techniques need a clipboard for temporary saving the copied or cut data.Data formats
Applications communicate through the clipboard by providing either serialized representations of an object, or a promise. In some circumstances the transfer of certain common data formats may be achieved opaquely through the use of an abstract factory, for example Mac OS X uses a class called NSImage to provide access to image data stored on the clipboard, though the actual format of the image data backing the object is hidden. The sending and receiving application negotiate the formats which can be transferred in between them, oftentimes with the active GUI widget responsible for providing acceptable type transformations. The pasteboard allows for transfer of common items such as URLs, colors, images, strings, attributed strings, and sounds. The operating system and GUI toolkit may provide some common conversions, for example converting from rich text to plain text and vice versa. Various type identifiers for data transfer are supported by modern operating systems, which may automatically provide acceptable mappings between type systems, such as between MIME and Uniform Type Identifier.Computer security
Clipboard hijacking is an exploit in which a person's clipboard's content is replaced by malicious data, such as a link to a malicious web site. While some security-holes were patched, JavaScript can still be used to modify clipboard content via an attack dubbed 'pastejacking'. Dylan Ayrey who developed the attack set up a website that demonstrates how this exploit can be used to trick a user into running commands they didn't want to run.There have been exploits where web pages grab clipboard data. In early 2013 researchers exposed risks stemming from Android-based password managers and documented how passwords in 21 of the most popular of these apps could be accessed by any other app on an Android device including those with extremely low-level privileges. Joe Siegrist notes that this is an "OS-level issue that impacts everything running on Android".
Clipboard management and extensions
extensions add functionality to the integrated clipboard functions of an operating system. They are applications that enable the user to manipulate the clipboard. On platforms such as linux where that use multiple incompatible GUI toolkits, clipboard managers are often used to transfer data between applications using different such frameworks.When a clipboard manager provides multiple cut and paste transactions, the clipboard is treated as a stack or scrap book, with new cuts and copies being placed on a list of recent transactions. The standard paste operation copies the most recent transaction, while specialized pastes provide access to the other stored transactions. These managers generally also provide a window that displays the transaction history and allows the user to select earlier copies, edit them, change their format and even search amongst them.
Since most operating systems do not save the clipboard contents to any persistent storage – when a user logs out or reboots the system the clipboard contents are deleted – an added functionality is to save the clipboard persistently. Another example is making the local clipboard work with online applications by saving the clipboard data to the online location upon a copy or cut event, making this data available to online applications for pasting. Clipboard managers can also serve as tools to overcome the limitation of software not supporting copying and pasting.
Operating system-specific clipboards
Microsoft Windows and ReactOS
The clipboard in Microsoft Windows holds one item in multiple available formats.Every item has at least one clipboard format, but can have different types of format of the same data. The three different types of possible formats are:
- standard formats,
- registered formats
- private formats for internal use
Data can be stored to the Windows and ReactOS clipboard via command line using the clip command:
$ # to paste the content of a folder to the clipboard:
$ dir | clip
The clipboard can also be accessed via PowerShell:
- to paste the content of a directory to the clipboard
- to get the content of the clipboard
Apple macOS
The clipboard in Apple macOS holds one item in multiple available formats.The contents of the clipboard can be viewed by selecting the Show Clipboard menu item from the Finder's Edit menu. The raw data and the stored formats can be seen using the ClipboardViewer.
Using the following commands the clipboard can be accessed from the command line:
$ # to copy data into the clipboard:
$ echo 'hello world' | pbcopy
$ # to paste from the clipboard:
$ pbpaste
hello world
X Window System
The X Window System commonly used on Unix and Linux systems provides three clipboards, which are named "PRIMARY", "SECONDARY" and "CLIPBOARD".The usage and handling of various selections is not standardized. However most modern toolkits and desktop environments, such as GNOME or KDE, follow a widely accepted convention, outlined in the freedesktop.org specification. One selection, CLIPBOARD, is used for traditional clipboard semantics, with shortcuts identical to Windows. Another selection, PRIMARY, is an X11-specific mechanism. Data is "copied" immediately upon highlighting and pasted with the third mouse button. This copied data is usually separated from the CLIPBOARD selection and does not change its contents. SECONDARY was planned as an alternative to PRIMARY but is only used inconsistently.
There are two command line tools which can access the clipboard:
$ # to paste standard output to the clipboard using xclip
$ echo text | xclip -in -selection clipboard
$ # to paste standard output to the clipboard using xsel
$ echo text | xsel --clipboard
The main difference to OS X and Windows is, that no data is actually stored in the CLIPBOARD-clipboard but only the reference to the copied or cut data. The application claims the owernship of the CLIPBOARD selection and communicates its ownership to the X Server. When pasting this data, the data and its available formats are requested from the application that owns the CLIPBOARD selection.
AmigaOS
The Amiga operating system uses 256 units, so one has multiple clipboards at the same time.Android
Android provides a clipboard that can hold up to one clip object and is accessible system-wide. Simple text is stored directly in the clipboard; complex data are stored by reference. The clip object has one of three formats: text string, URI object, or intent.To interact with the clipboard, an app uses the class ClipboardManager and system calls to cut, copy, and paste objects.
In Android 8.0, the clipboard first appears in the user interface: In a situation where the user prepares to paste from the clipboard, a "Clipboard" option appears that gives the user access to many objects copied or cut to the clipboard in the past. Apart from that, and in earlier versions, the user has no access to the clipboard except in apps that make it available to the user.
Apple iOS
The clipboard is called "pasteboard" in iOS similar to OS X. Apps on this operating system can create additional pasteboards, called instances of the UIPasteboard class, which can be public or private. One instance can hold a single item or multiple items in different formats.The formats are identified by Uniform Type Identifiers.
The data contained in the pasteboard can't be accessed via the GUI but only from the system and applications.