Platform-neutral clipboard abstractions, to access platform-specific clipboards (copy/paste) without platform-specific code.
The clipboard can be thought of as an ordered dictionary keyed on format, with the value as the payload. This dictionary is implemented and accessed differently on different operating systems (OS’s).
Interfaces include:
Clipboard
: reading/pasting from the clipboard.ScopedClipboardWriter
: writing/copying to the clipboard.ClipboardObserver
: notifications of clipboard events.ClipboardFormatType
: specifying clipboard formats.While most platform-specific behavior should be abstracted away, some may still be exposed. For some notable platform-specific behavior exposed by these interfaces:
ClipboardAndroid
has a more limited set of supported formats.ClipboardObserver
is only supported on some platforms, as other platforms may require (inefficient) polling to implement.ClipboardX11
supports both the usual clipboard buffer (CLIPBOARD selection), as well as the middle-click paste buffer (PRIMARY selection). X11 selections are documented in more detail in X11 documentation.DataTransferPolicyController
is only currently exercised in ChromeOS.ClipboardWin
and ClipboardX11
have limits to the amount of registered clipboard formats. Windows has the smallest limit on the number of formats, at 16384, and explored in this article. After these system resources are exhausted, the underlying OS may be rendered unusable.