New Version of the Clipboard Specification

Toni Ruottu toni.ruottu at iki.fi
Thu Jun 14 08:54:13 PDT 2007


  Hi!

I finally "finished" rewriting the Clipboard Specification. I'm hoping
to get comments, discussion and/or silent approval. :-)

  --Toni
-------------- next part --------------

---- Terms ----

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in the normative parts of this document are to be interpreted as described in RFC2119.

---- Introduction ----

In colloquial language clipboard refers to an idea of an abstract temporary data storage manipulated by copy, paste and cut operations. Copy and paste are a set of operations used to transfer data between applications. From the users point of view copy creates an infinite amount of copies of some selected content and paste attaches a copy of the previously copied content to the active application. Cut is a short cut for making the copy operation and deleting the selected content after copying it first.

---- Scope ----

Almost every desktop operating system provides an explicit copy/paste feature. In addition many system provide an implicit copy/paste feature for advanced users.

Many legacy systems have differing characteristics. Modern systems implement different sets of those characteristics. While most differences are small, they result in broken user experiences as users switch from one system to another differing systems.

This specification attempts to define a standard for clipboard behavior and provide rationale for the described behavior. The specification defines a reasonable default behavior for desktop systems. Implementers are encouraged to provide optional behaviors for users who feel uncomfortable with the default behavior.

---- Conformance ----

To conform to this specification a system MUST provide an explicit copy/paste feature for copying data between applications. An implicit alternative SHOULD be provided for advanced users. In each case the system MUST follow the given restrictions.

Behaviour regarding cut will not be handled separately, but everything that applies to copy applies to cut respectively. However, in some cases copy operations do not have sensible cut-equivalents. This may happen when the copy operation does not relate to any selection or the selected content is read-only. For example, a browser might provide "copy URL" option, enabling user to paste URL for the web page he is currently reading. In such cases implementing cut-functionality is not required.

---- Attaching Point ----

When text is being pasted, attaching is done at the point where cursor resides in currently active text field. When the text field has a selection the selected content gets overwritten by the attached content. Attaching points for more complex data types is out of the scope of this specification.

---- Explicit copy/paste ----

Explicit copy refers to any user action with copying as its goal. This includes selecting "copy" option from a menu, pressing copy button on the toolbar, selecting option "copy URL" from a menu in a web browser, etc. Explicit paste refers to any user action with pasting as its goal.

A system implementing the explicit copy/paste feature MUST provide a CLIPBOARD pointer which points to the application which holds the copied data of the latest explicit copy. In this context pointer is used as an abstract term not necessarily referring to any specific way of pointing. The application holding the data is the host application for the particular copy operation. When a copy action is executed the CLIPBOARD pointer is set to point at the host application and the host application is made ready for sending data, if pasting happens.

Loosing data when host application closes MAY be prevented by creating a clipboard manager application which immediately after a copy operation pastes the data to itself and recopies it from there. These operations do not have to be visible to a user. Clipboard managers are not in the scope of this specification and are described elsewhere in greater detail.

---- Implicit copy/paste ----

Implicit copy refers to an act where the user either selects some text or does any explicit copy-action that results in text being copied. Implicit copying happens even when user does not command the system to do so. This, how ever, does not imply that implicit copying should not happen when user gives a copy command. Implicit paste refers to the ( explicit ) user action reserved for pasting the text that was copied earlier with an implicit copy action. A system that implements implicit paste SHOULD allow user to execute implicit pasting with middle mouse button.

Implicit paste which is performed on a text field MUST attach the pasted text at the current location of the text cursor without moving it first. Selecting the point of attachment on forehand separately by moving cursor reduces errors, as the point can be confirmed, even altered, before actual pasting takes place. In some applications it may also be hard to move the cursor at pasting time. These applications include many terminal emulators, for instance.

An implicit paste which is performed on an element other than a text field MAY launch some convenient operation based on the pasted text. E.g. a web browser might use this feature for entering a web site when the text is an URL or launching a web search when the text is something else. Just to give an example. A reasonable behaviour depends a lot on application and pasted text, and is out of the scope of this specification.

A system implementing the implicit copy/paste feature MUST have a PRIMARY pointer which points to the host application with the latest implicit copy action and a SECONDARY pointer which points to the host with the preceding implicit copy-action. I.e. SECONDARY stores one step of copy history. Implicit paste-action pastes PRIMARY, unless data pasted from PRIMARY would be equal to the current selection. In such case SECONDARY would be pasted instead. Implementing implicit copy/paste this way, should make it possible for two implicitly copied items to take turns, enabling user to overwrite the items multiple times with each other by simply executing implicit paste on the same selection continuously.

---- Restrictions ----

A selection becoming unselected MUST NOT have any affect on any of the three pointers (CLIPBOARD, PRIMARY, SECONDARY). Altering any of the three pointers (CLIPBOARD, PRIMARY, SECONDARY) MUST NOT affect any selections. Making a selection in one application MUST NOT affect selections in other applications.

The implicit actions MUST NOT affect nor paste CLIPBOARD. The explicit paste commands MUST NOT paste PRIMARY nor SECONDARY.


---- References ----

- the ICCCM
- http://www.xfree86.org/~keithp/talks/selection.ps
- http://www.jwz.org/doc/x-cut-and-paste.html
- Freedesktop.org wiki http://www.freedesktop.org/wiki/ClipboardManager
- RFC2119


---- Acknowledgments ----

Using SECONDARY to store the old implicit copy for pasting it over a selection was proposed by Frisco M. Rose on Freedesktop.org wiki. ICCCM specifies similar uses for SECONDARY, but not this particular one. 




More information about the xdg mailing list