beetlebug▾
/

clipboard append

Adds data to the end of the data of a type on the clipboard.

clipboard append ?-displayof WINDOW? ?-format FORMAT? ?-type TYPE? ?--? DATA

Description

Adds DATA to the end of the data of TYPE, STRING by default. Each call adds to the data of the earlier calls, so a script calls clipboard clear first to replace the text. Then the text of the type STRING goes to the clipboard of the system.

The options come before DATA. The word -- ends the options, so DATA can start with a -.

Options

OptionTypeDefaultDescription
-displayofwindownoneA window of the display whose clipboard gets the data.
-formatstringSTRINGThe format of the data for the X selection protocol.
-typestringSTRINGThe type of the data, such as STRING.

-displayof WINDOW

A window of the display whose clipboard gets the data.

ztk has one clipboard for each app, so the window only has to exist.

% clipboard clear
> clipboard append -displayof . text
> clipboard get
text
% clipboard append -displayof .nope x
bad window path name ".nope"
-errorcode NONE

-format FORMAT

The format of the data for the X selection protocol.

In Tk on X11, the format tells how another program reads the data, such as STRING or ATOM. ztk accepts any value and stores the data as text, so the option has no effect.

% clipboard clear
> clipboard append -format ATOM x
> clipboard get
x

ztk accepts any format.

-type TYPE

The type of the data, such as STRING.

A type keeps its own data. Only the data of STRING goes to the clipboard of the system. A script can put data of its own type, such as text/html, and read it back with clipboard get -type.

% clipboard clear
> clipboard append plain
> clipboard append -type text/html <b>bold</b>
> list [clipboard get] [clipboard get -type text/html]
plain <b>bold</b>

# The last word is DATA, also when it looks like an option.
% clipboard clear
> clipboard append -type
> clipboard get
-type

ztk accepts any name of a type.

Returns

An empty string.

Examples

% clipboard clear
> clipboard append one
> clipboard append " two"
> clipboard get
one two

% clipboard clear
> clipboard append -- -5
> clipboard get
-5

Errors

% clipboard append
wrong # args: should be "clipboard append ?-option value ...? data"
-errorcode TCL WRONGARGS

% clipboard append a b
wrong # args: should be "clipboard append ?-option value ...? data"
-errorcode TCL WRONGARGS

% clipboard append -size 1 x
bad option "-size": must be -displayof, -format, or -type
-errorcode NONE

Facts

Capability
None.
Tcl release
Tcl 9.1 and 8.6.
Since
ztk 1.0.0-beta.1

See also