---
name: "Clipbrd"
section: "2"
platform: "linux"
package: "perl-tk"
version: "b11.02-5"
release: "Debian 1.3 (Bo)"
platforms: ["linux"]
url: "https://new.carta.tech/Clipbrd"
---

# Clipbrd(2)

Manage the clipboard

## NAME

Tk\_ClipboardClear, Tk\_ClipboardAppend - Manage the clipboard

## SYNOPSIS

```
#include <tk.h>

int
Tk_ClipboardClear(interp, tkwin)

int
Tk_ClipboardAppend(interp, tkwin, target, format, buffer)
```

## ARGUMENTS

Interpreter to use for reporting errors. Window that determines which display's clipboard to manipulate. Conversion type for this clipboard item;  has same meaning as *target* argument to **Tk\_CreateSelHandler**. Representation to use when data is retrieved;  has same meaning as *format* argument to **Tk\_CreateSelHandler**. Null terminated string containing the data to be appended to the clipboard.

## DESCRIPTION

These two procedures manage the clipboard for Tk. The clipboard is typically managed by calling **Tk\_ClipboardClear** once, then calling **Tk\_ClipboardAppend** to add data for any number of targets.

**Tk\_ClipboardClear** claims the CLIPBOARD selection and frees any data items previously stored on the clipboard in this application.   It normally returns TCL\_OK, but if an error occurs it returns TCL\_ERROR and leaves an error message in *interp-\>result*. **Tk\_ClipboardClear** must be called before a sequence of **Tk\_ClipboardAppend** calls can be issued.

**Tk\_ClipboardAppend** appends a buffer of data to the clipboard. The first buffer for a given *target* determines the *format* for that *target*. Any successive appends for that *target* must have the same format or an error will be returned. **Tk\_ClipboardAppend** returns TCL\_OK if the buffer is successfully copied onto the clipboard.  If the clipboard is not currently owned by the application, either because **Tk\_ClipboardClear** has not been called or because ownership of the clipboard has changed since the last call to **Tk\_ClipboardClear**, **Tk\_ClipboardAppend** returns TCL\_ERROR and leaves an error message in *interp-\>result*.

In order to guarantee atomicity, no event handling should occur between **Tk\_ClipboardClear** and the following **Tk\_ClipboardAppend** calls (otherwise someone could retrieve a partially completed clipboard or claim ownership away from this application).

**Tk\_ClipboardClear** may invoke callbacks, including arbitrary Tcl scripts, as a result of losing the CLIPBOARD selection, so any calling function should take care to be reentrant at the point **Tk\_ClipboardClear** is invoked.

## KEYWORDS

append, clipboard, clear, format, type
