clipboard (computing)
{{short description|Data storage used to support copy and paste operations}}
{{For|the physical equivalent|Clipboard}}
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.{{Cite news|url=https://www.techopedia.com/definition/4646/clipboard|title=What is a Clipboard in Computing? - Definition from Techopedia|work=Techopedia.com|access-date=2018-02-01|language=en|archive-url=https://web.archive.org/web/20180202200114/https://www.techopedia.com/definition/4646/clipboard|archive-date=2018-02-02|url-status=live}}
The 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 and macOS support a single clipboard transaction.{{Cite journal|last=Kimmatkar|first=Sarang B.|date=2014|title=Extending functionalities of default clipboard.|journal=(IJCSIT) International Journal of Computer Science and Information Technologies 5|volume=6}}{{Cite book|last=Stephens|first=Rod|url=https://archive.org/details/visualbasicprogr00step_709|title=Visual Basic 2010 : programmer's reference|date=2010|publisher=Indianapolis, IN : Wiley Pub., Inc.|others=Library Genesis|isbn=978-0-470-49983-2|urinalysis=limited}}
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.{{cite book|last= Moggridge|first= Bill|date= 2007|title= Designing interactions|location= Cambridge, Massachusetts|publisher= MIT Press|page= [https://archive.org/details/designinginterac00mogg/page/65 65ff]|isbn= 9780262134743|url-access= registration|url= https://archive.org/details/designinginterac00mogg/page/65}} 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.{{cite web|author=Larry Tesler|title=A User Experience Retrospective|url=http://www.nomodes.com/Larry_Tesler_Consulting/Retrospective/Pages/CHI_Retrospective.html|access-date=23 January 2018|archive-url=https://web.archive.org/web/20180202071746/http://www.nomodes.com/Larry_Tesler_Consulting/Retrospective/Pages/CHI_Retrospective.html|archive-date=2018-02-02|url-status=live}}
Data formats
Applications communicate through the clipboard by providing either serialized representations of an object, or a promise (for larger objects).{{cite web |title=Dragging Files |url=https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/DragandDrop/Tasks/DraggingFiles.html |website=developer.apple.com |access-date=9 December 2018}} 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 (Rich text), 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.{{cite web |title=NSPasteboard - AppKit {{!}} Apple Developer Documentation |url=https://developer.apple.com/documentation/appkit/nspasteboard |website=developer.apple.com |access-date=9 December 2018 |archive-url=https://web.archive.org/web/20180526202133/https://developer.apple.com/documentation/appkit/nspasteboard |archive-date=2018-05-26 |url-status=live }}{{cite web |title=Adopting Uniform Type Identifiers |url=https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/understanding_utis/understand_utis.tasks/understand_utis_tasks.html#//apple_ref/doc/uid/TP40001319-CH203-BABHCIAC |website=developer.apple.com |access-date=9 December 2018 |archive-url=https://web.archive.org/web/20180721122838/https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/understanding_utis/understand_utis.tasks/understand_utis_tasks.html#//apple_ref/doc/uid/TP40001319-CH203-BABHCIAC#//apple_ref/doc/uid/TP40001319-CH203-BABHCIAC |archive-date=2018-07-21 |url-status=live }}
==Computer security==
Clipboard hijacking or clipboard injection 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.{{cite web|title=What is clipboard hijack attack? - Definition from WhatIs.com|url=http://whatis.techtarget.com/definition/clipboard-hijack-attack|website=WhatIs.com|access-date=4 January 2017|archive-url=https://web.archive.org/web/20170105083320/http://whatis.techtarget.com/definition/clipboard-hijack-attack|archive-date=2017-01-05|url-status=live}} For example, if a user copies a cryptocurrency receiving address into the clipboard, a hijacking program can overwrite it with an address controlled by the hijacker, so that when the user pastes the address their cryptocurrency is transmitted to the hijacker instead of the intended recipient.{{Cite web |date=2023-03-28 |title=Clipboard injector distributed under the guise of Tor Browser |url=https://securelist.com/copy-paste-heist-clipboard-injector-targeting-cryptowallets/109186/ |access-date=2024-05-15 |website=securelist.com |language=en-US}} While some security-holes were patched, JavaScript can still be used to modify clipboard content via an attack dubbed 'pastejacking'.{{cite web|last1=Chirgwin|first1=Richard|title=Pastejack attack turns your clipboard into a threat|url=https://www.theregister.co.uk/2016/05/25/pastejack_attack_turns_your_clipboard_into_a_vector/|publisher=The Register|access-date=4 January 2017|archive-url=https://web.archive.org/web/20170104235824/http://www.theregister.co.uk/2016/05/25/pastejack_attack_turns_your_clipboard_into_a_vector/|archive-date=2017-01-04|url-status=live}}{{cite web|title=Researcher warns of 'pastejacking' hack attacks targeting users' clipboards|url=https://www.grahamcluley.com/researcher-warns-pastejacking-hack-attacks-targeting-users-clipboards/|publisher=Graham Cluley|access-date=4 January 2017|date=26 May 2016|archive-url=https://web.archive.org/web/20170105001104/https://www.grahamcluley.com/researcher-warns-pastejacking-hack-attacks-targeting-users-clipboards/|archive-date=2017-01-05|url-status=live}} 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.{{cite web|title=dxa4481/Pastejacking|url=https://github.com/dxa4481/Pastejacking|website=GitHub|access-date=4 January 2017|archive-url=https://web.archive.org/web/20170104074050/https://github.com/dxa4481/Pastejacking|archive-date=2017-01-04|url-status=live}}
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.{{cite book|chapter=Hey, You, Get Off of My Clipboard|doi=10.1007/978-3-642-39884-1_12|chapter-url=http://fc13.ifca.ai/proc/4-2.pdf|access-date=4 January 2017|volume=7859|pages=144–161|archive-url=https://web.archive.org/web/20170919070257/http://fc13.ifca.ai/proc/4-2.pdf|archive-date=2017-09-19|url-status=live|title=Financial Cryptography and Data Security|series=Lecture Notes in Computer Science|year=2013|last1=Fahl|first1=Sascha|last2=Harbach|first2=Marian|last3=Oltrogge|first3=Marten|last4=Muders|first4=Thomas|last5=Smith|first5=Matthew|isbn=978-3-642-39883-4}} Joe Siegrist notes that this is an "OS-level issue that impacts everything running on Android".{{cite web|title=Using a password manager on Android? It may be wide open to sniffing attacks|date=21 November 2014|url=https://arstechnica.com/security/2014/11/using-a-password-manager-on-android-it-may-be-wide-open-to-sniffing-attacks/|publisher=Ars Technica|access-date=4 January 2017|archive-url=https://web.archive.org/web/20170104235202/http://arstechnica.com/security/2014/11/using-a-password-manager-on-android-it-may-be-wide-open-to-sniffing-attacks/|archive-date=2017-01-04|url-status=live}}
Clipboard management and extensions
File:Glipper menu.png, an example of a clipboard management program]]
{{see also|Clipboard manager#List of clipboard software|Snippet management}}
Clipboard manager 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 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 (e.g. Windows, macOS, Linux, X11, Android, iOS) 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 (for example, while logging into remote Windows server, one cannot copy and paste their user name and password).
Operating system-specific clipboards
{{see also|Cut, copy, and paste#Common keyboard shortcuts}}
= AmigaOS =
The Amiga operating system uses 256 units, so one has multiple clipboards at the same time.{{cite web |title=Clipboard Device - AmigaOS Documentation Wiki |url=http://wiki.amigaos.net/wiki/Clipboard_Device#Multiple_Clips |url-status=live |archive-url=https://web.archive.org/web/20180205000829/http://wiki.amigaos.net/wiki/Clipboard_Device#Multiple_Clips#Multiple_Clips |archive-date=2018-02-05 |access-date=2018-02-03 |website=wiki.amigaos.net |language=en}}
= 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.{{cite web |title=Copy and Paste {{!}} Android Developers |url=https://developer.android.com/guide/topics/text/copy-paste.html |url-status=live |archive-url=https://web.archive.org/web/20180207122225/https://developer.android.com/guide/topics/text/copy-paste.html |archive-date=2018-02-07 |access-date=2018-02-06 |website=developer.android.com |language=en}}
To interact with the clipboard, an app uses the class ClipboardManager{{cite web |title=ClipboardManager {{!}} Android Developers |url=https://developer.android.com/reference/android/text/ClipboardManager.html |url-status=live |archive-url=https://web.archive.org/web/20180207062710/https://developer.android.com/reference/android/text/ClipboardManager.html |archive-date=2018-02-07 |access-date=2018-02-02 |website=developer.android.com |language=en}} 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.
= 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.{{cite web |title=Pasteboard |url=https://developer.apple.com/library/content/documentation/General/Conceptual/Devpedia-CocoaApp/Pasteboard.html |url-status=live |archive-url=https://web.archive.org/web/20180207063018/https://developer.apple.com/library/content/documentation/General/Conceptual/Devpedia-CocoaApp/Pasteboard.html |archive-date=2018-02-07 |access-date=2018-02-01 |website=developer.apple.com |language=en}}
The formats are identified by Uniform Type Identifiers (UTI).{{cite web |title=Uniform Type Identifier |url=https://developer.apple.com/library/content/documentation/General/Conceptual/DevPedia-CocoaCore/UniformTypeIdentifier.html#//apple_ref/doc/uid/TP40008195-CH60 |url-status=live |archive-url=https://web.archive.org/web/20180207062907/https://developer.apple.com/library/content/documentation/General/Conceptual/DevPedia-CocoaCore/UniformTypeIdentifier.html#//apple_ref/doc/uid/TP40008195-CH60#//apple_ref/doc/uid/TP40008195-CH60 |archive-date=2018-02-07 |access-date=2018-02-06 |website=developer.apple.com |language=en}}
The data contained in the pasteboard cannot be accessed via the GUI but only from the system and applications
= macOS =
The clipboard in 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.{{cite web |title=ClipboardViewer |url=https://developer.apple.com/library/content/samplecode/ClipboardViewer/Introduction/Intro.html |url-status=live |archive-url=https://web.archive.org/web/20180207063107/https://developer.apple.com/library/content/samplecode/ClipboardViewer/Introduction/Intro.html |archive-date=2018-02-07 |access-date=2018-02-06 |website=developer.apple.com |language=en}}
Using the following commands the clipboard can be accessed from the command line:{{cite web |title=Copy to clipboard from terminal in OS X |url=http://blog.rogeriopvl.com/archives/copy-to-clipboard-from-terminal-in-os-x/ |url-status=dead |archive-url=https://web.archive.org/web/20130815002844/http://blog.rogeriopvl.com/archives/copy-to-clipboard-from-terminal-in-os-x/ |archive-date=2013-08-15 |access-date=2013-07-02 |work=rogeriopvl.com}}{{cite web |title=pbcopy(1) Mac OS X Manual Page |url=https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/pbcopy.1.html |url-status=live |archive-url=https://web.archive.org/web/20140328023751/https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/pbcopy.1.html |archive-date=2014-03-28 |access-date=2013-07-02 |work=apple.com}}
$ # to copy data into the clipboard:
$ echo 'hello world' | pbcopy
$ # to paste from the clipboard:
$ pbpaste
hello world
= Microsoft Windows and ReactOS =
{{Infobox software
| name = clip
| logo =
| screenshot = ReactOS-0.4.13 clip command 667x434.png
| screenshot size =
| caption = The ReactOS clip
command
| developer = Microsoft, ReactOS Contributors
| released =
| latest release version =
| latest release date =
| operating system = Windows, ReactOS
| genre = Command
| license = Windows: Proprietary commercial software
ReactOS: GNU General Public License
| website = {{URL|https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/clip}}
}}
The clipboard in Microsoft Windows and ReactOS 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:{{cite web|url=https://msdn.microsoft.com/en-us/library/windows/desktop/ms649013(v=vs.85).aspx|title=Clipboard Formats (Windows)|website=msdn.microsoft.com|language=en|access-date=2018-02-03|archive-url=https://web.archive.org/web/20180207122331/https://msdn.microsoft.com/en-us/library/windows/desktop/ms649013(v=vs.85).aspx|archive-date=2018-02-07|url-status=live}}
- standard formats{{cite web|url=https://msdn.microsoft.com/en-us/library/windows/desktop/ff729168(v=vs.85).aspx|title=Standard Clipboard Formats (Windows)|website=msdn.microsoft.com|language=en|access-date=2018-02-03|archive-url=https://web.archive.org/web/20180207122513/https://msdn.microsoft.com/en-us/library/windows/desktop/ff729168(v=vs.85).aspx|archive-date=2018-02-07|url-status=live}} (e.g. CF_BITMAP, or CF_UNICODETEXT),
- registered formats{{cite web|url=https://msdn.microsoft.com/en-us/library/aa767917(VS.85).aspx|title=HTML Clipboard Format (Internet Explorer)|website=msdn.microsoft.com|date=15 August 2017 |language=en|access-date=2018-02-03|archive-url=https://web.archive.org/web/20180207122510/https://msdn.microsoft.com/en-us/library/aa767917(VS.85).aspx|archive-date=2018-02-07|url-status=live}} (e.g. CF_HTML)
- private formats for internal use
Up to and including Windows XP the clipboard could be accessed via the ClipBook Viewer application.{{Cite news|url=http://www.thewindowsclub.com/windows-clipboard-manager-viewer|title=View & Manage Clipboard In Windows 10/8/7|date=2013-04-12|work=The Windows Club|access-date=2018-02-06|language=en-US|archive-url=https://web.archive.org/web/20180212151136/http://www.thewindowsclub.com/windows-clipboard-manager-viewer|archive-date=2018-02-12|url-status=live}} In newer versions of Windows the content can be accessed via clipboard managers.
Data can be stored to the Windows{{cite web|url=https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/clip |title=clip | Microsoft Docs |publisher=Docs.microsoft.com |date=2017-10-16 |access-date=2019-09-26}} and ReactOS{{cite web|url=https://github.com/reactos/reactos/tree/master/base/applications/cmdutils/clip |title=reactos/base/applications/cmdutils/clip at master · reactos/reactos · GitHub |publisher=Github.com |access-date=2019-09-26}} clipboard via command line using the clip command:{{cite web|url=https://www.labnol.org/software/copy-command-output-to-clipboard/2506/|title=How to Copy Command Line Output to the Windows Clipboard|website=www.labnol.org|date=8 August 2013 |language=en-US|access-date=2018-02-06|archive-url=https://web.archive.org/web/20180207122226/https://www.labnol.org/software/copy-command-output-to-clipboard/2506/|archive-date=2018-02-07|url-status=live}}
$ # to paste the content of a folder to the clipboard:
$ dir | clip
The clipboard can also be accessed via PowerShell:{{cite web|url=https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/get-clipboard?view=powershell-5.1|title=Get-Clipboard (Microsoft.PowerShell.Management)|last=sdwheeler|website=docs.microsoft.com|language=en-us|access-date=2018-02-06|archive-url=https://web.archive.org/web/20180126105455/https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/get-clipboard?view=powershell-5.1|archive-date=2018-01-26|url-status=live}}{{cite web|url=https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/set-clipboard?view=powershell-5.1|title=Set-Clipboard (Microsoft.PowerShell.Management)|last=sdwheeler|website=docs.microsoft.com|language=en-us|access-date=2018-02-06|archive-url=https://web.archive.org/web/20180207122353/https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/set-clipboard?view=powershell-5.1|archive-date=2018-02-07|url-status=live}}
- to paste the content of a directory to the clipboard
Set-Clipboard -Path "C:\directory\"
- to get the content of the clipboard
Get-Clipboard
Windows 10 and Windows 11 include the Clipboard application, allowing for the storage of multiple text-based clipboard items. It can be accessed by pressing Windows+V.
= Symbian =
Symbian S60 (Series 60), depending on edition, has a built-in clipboard with image and richtext storing support.{{Cite web |title=Files and clipboard in Text content |url=https://docs.huihoo.com/symbian/s60-3rd-edition-cpp-developers-library-v1.1/GUID-35228542-8C95-4849-A73F-2B4F082F0C44/html/SDL_93/doc_source/guide/Application-Framework-subsystem-guide/TextAndTextAttributes/TextAndTextAttributesGuide1/TextContentFilesClipboard.guide.html |access-date=2024-10-23 |website=docs.huihoo.com}}{{Cite web |last=Schkatula |first=Yury |date=2010-03-28 |title=Symbianic life: Integrate with Symbian clipboard |url=https://symbianic-life.blogspot.com/2010/03/integrate-with-symbian-clipboard.html |access-date=2024-10-23 |website=Symbianic life}}{{Citation |last=Fiodar |title=fedor4ever/symbianClipboard |date=2019-03-06 |url=https://github.com/fedor4ever/symbianClipboard |access-date=2024-10-23}}
{{Quote|text=To copy and paste text, while pressing and holding {{Key|#}}, scroll left or right to highlight text. To copy the text to the clipboard, while still holding {{Key|#}}, select {{Code|Copy}}. To insert the text into a document, press and hold {{Key|#}}, and select {{Code|Paste}}.|author=Nokia|title=Nokia N82 User Guide|source=Messaging: Edit text and lists}}
In S60v3 (S60 3rd Edition, Symbian 9.1-9.2) examples of clipboard provided with the SDK: ..\Examples\SysLibs\Clipboard\Basics
. To read and write clipboard used CPlainText
Class:
{{Quote|text={{Code|CPlainText}} could be very nice solution. But in Symbian reality, let read the manual. There is one small but important phrase which can figure out {{Code|CPlainText}} as non-acceptable solution in your case:
{{quote|“…all line feeds are converted into paragraph delimiters…”|Nokia|Clipboard Copy/Cut/Paste|http://wiki.forum.nokia.com/index.php/Clipboard_Copy/Cut/Paste}}|author=Yury Schkatula|title=Integrate with Symbian clipboard|source=https://symbianic-life.blogspot.com/2010/03/integrate-with-symbian-clipboard.html}}
In Symbian Belle, clipboard support defined with CClipboard
Class in the Basic Application Framework Library (BAFL).{{Cite web |title=Basic Application Framework Library |url=http://devlib.symbian.slions.net/belle/GUID-C8BD333E-8384-534B-822B-F61B2F7C8B9F.html |access-date=2024-10-23 |website=devlib.symbian.slions.net |language=en}}{{Cite web |title=Basics: Store and Restore Object using Clipboard |url=http://devlib.symbian.slions.net/belle/GUID-C156607A-5929-5971-8077-E8974FA43B3C.html |access-date=2024-10-23 |website=devlib.symbian.slions.net |language=en}}
There was a number of free and commercial third party clipboard managing applications with multi-item clipboard support created for different Symbian editions.{{Cite web |date=2014-04-08 |title=ClipBook, the multi-item Symbian clipboard manager |url=http://www.allaboutsymbian.com/flow/item/19633_ClipBook_the_multi-item_Symbia.php |access-date=2024-10-23 |website=All About Symbian |language=en}}{{Cite web |last=Litchfield |first=Steve |title=Curated Symbian application store |url=https://stevelitchfield.com/appstore.htm |access-date= |website=stevelitchfield.com |quote=ClipBook: ClipBoard Manager (free)}}{{Cite web |title=Mclip V1.4 Symbian App - Download for free on PHONEKY |url=https://phoneky.com/applications/?id=y1y22257 |access-date=2024-10-23 |website=phoneky.com |language=en}}{{Cite web |title=Download MagicKeys 2.12 for Symbian |url=https://magickeys.soft32.com/ |access-date=2024-10-23 |website=magickeys.soft32.com}}
= X Window System =
The X Window System commonly used on Unix and Linux systems provides three clipboards, which are named "CLIPBOARD", "PRIMARY" and "SECONDARY".{{cite web|url=https://wiki.archlinux.org/index.php/Clipboard|title=Clipboard - ArchWiki|website=wiki.archlinux.org|language=en|access-date=2018-02-16|archive-url=https://web.archive.org/web/20180217023932/https://wiki.archlinux.org/index.php/Clipboard|archive-date=2018-02-17|url-status=live}} 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.{{cite web |url=http://www.freedesktop.org/wiki/Specifications/clipboards-spec/ |title=clipboards-spec |publisher=freedesktop.org |access-date=2014-08-16 |archive-url=https://web.archive.org/web/20141224001434/http://www.freedesktop.org/wiki/Specifications/clipboards-spec/ |archive-date=2014-12-24 |url-status=live }} 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 (middle) mouse button.{{cite web|url=https://wiki.mi.ur.de/lehre/ss17/itt/copyandpaste|title=Copy & Paste, Drag & Drop [MI Wiki]|website=wiki.mi.ur.de|language=de|access-date=2018-02-16|archive-url=https://web.archive.org/web/20180216204616/https://wiki.mi.ur.de/lehre/ss17/itt/copyandpaste|archive-date=2018-02-16|url-status=live}} This copied data is usually separated from the CLIPBOARD selection and does not change its contents.{{cite web|url=https://www.gnu.org/software/emacs/manual/html_node/emacs/Primary-Selection.html|title=gnu.org|website=www.gnu.org|language=en|access-date=2018-02-16|archive-url=https://web.archive.org/web/20171224062228/http://www.gnu.org/software/emacs/manual/html_node/emacs/Primary-Selection.html|archive-date=2017-12-24|url-status=live}} SECONDARY was planned as an alternative to PRIMARY but is only used inconsistently.
There are two command line tools (xsel and xclip) which can access the clipboard:{{cite web|url=https://fernandobasso.github.io/en/shell/copy-paste-from-command-line-xclip-xsel-clipboard.html#about-xclip-and-xsel|title=Copying and Pasting To and From the System Clipboard On The Command Line — Fernando Basso|website=fernandobasso.github.io|language=en|access-date=2018-02-06|archive-url=https://web.archive.org/web/20180207122218/https://fernandobasso.github.io/en/shell/copy-paste-from-command-line-xclip-xsel-clipboard.html#about-xclip-and-xsel|archive-date=2018-02-07|url-status=dead}}
$ # 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 ownership 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.{{cite web|url=https://www.jwz.org/doc/x-cut-and-paste.html|title=X Selections, X Cut Buffers, and Emacs Kill Rings|website=www.jwz.org|access-date=2018-02-02|archive-url=https://web.archive.org/web/20180304195944/https://www.jwz.org/doc/x-cut-and-paste.html|archive-date=2018-03-04|url-status=live}}
APIs
Applications can access the clipboard or its data via APIs.
= JavaScript =
In JavaScript a class which detects changes in the users clipboard data (ClipboardEvent){{cite web|url=https://www.w3.org/TR/clipboard-apis/#clipboard-events-and-interfaces|title=Clipboard API and events – ClipboardEvent|website=www.w3.org|archive-url=https://web.archive.org/web/20180128044120/https://www.w3.org/TR/clipboard-apis/#clipboard-events-and-interfaces#clipboard-events-and-interfaces|archive-date=2018-01-28|url-status=live|access-date=2018-02-08}} and functions to alter the content of a clipboard or read from it (clipboardData.getData(), clipboardData.setData()){{cite web|url=https://www.w3.org/TR/clipboard-apis/#sync-clipboard-api|title=Clipboard API and events – Synchronous Clipboard API|website=www.w3.org|language=en|archive-url=https://web.archive.org/web/20180128044120/https://www.w3.org/TR/clipboard-apis/#sync-clipboard-api#sync-clipboard-api|archive-date=2018-01-28|url-status=live|access-date=2018-02-08}} exist, but aren't supported by every browser since altering the clipboard of a user can represent a security issue.
= Qt =
In Qt a wrapper for every supported platform{{cite web|url=http://code.qt.io/cgit/qt/qtbase.git/tree/src/plugins/platforms|title=platforms\plugins\src - qt/qtbase.git - Qt Base (Core, Gui, Widgets, Network, ...)|website=code.qt.io|language=en|access-date=2018-02-02|archive-url=https://web.archive.org/web/20180209064223/http://code.qt.io/cgit/qt/qtbase.git/tree/src/plugins/platforms|archive-date=2018-02-09|url-status=live}} exists. It provides access to window system clipboards with the use of the class QClipboard. This class facilitates access to common data types by functions.{{cite web|url=http://doc.qt.io/qt-5/qclipboard.html|title=QClipboard Class {{!}} Qt GUI 5.10|website=doc.qt.io|language=en|access-date=2018-02-02|archive-url=https://web.archive.org/web/20180202011104/http://doc.qt.io/qt-5/QClipboard.html|archive-date=2018-02-02|url-status=live}} The data type of the element stored in the clipboard is indicated via MIME and MIME data can also be put in the clipboard with help of functions from this class.
See also
References
{{reflist}}
Further reading
- {{Cite book|first=William R.|last=Stanek|year=2008|title=Windows Command-Line Administrator's Pocket Consultant, 2nd Edition|publisher=Microsoft Press|isbn=978-0735622623}}
- {{Cite book|author-last=McElhearn|author-first=Kirk|title=The Mac OS X Command Line: Unix Under the Hood|date=2006|publisher=John Wiley & Sons|isbn=978-0470113851}}
External links
{{Wikibooks|Guide to Windows Commands}}
- [https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/clip clip | Microsoft Docs]
- [http://tronche.com/gui/x/icccm/sec-2.html 2. Peer-to-Peer Communication by Means of Selections] in the ICCCM
- [https://msdn.microsoft.com/en-us/library/windows/desktop/bb776905(v=vs.85).aspx Windows Dev Center: Transferring Shell Objects with Drag-and-Drop and the Clipboard]
- [http://blogs.msdn.com/b/ntdebugging/archive/2012/03/16/how-the-clipboard-works-part-1.aspx Microsoft Developer Network: How the Clipboard Works, Part 1]
- [http://blogs.msdn.com/b/ntdebugging/archive/2012/03/29/how-the-clipboard-works-part-2.aspx Microsoft Developer Network: How the Clipboard Works, Part 2]
- [https://msdn.microsoft.com/en-us/library/cc241081.aspx Microsoft Developer Network: Delayed Rendering of Clipboard Data]
{{Windows commands}}