Tk\_ClipboardClear(3) Tk Library Procedures Tk\_ClipboardClear(3)

```

```

# [NAME](#NAME)

Tk\_ClipboardClear, Tk\_ClipboardAppend - Manage the clipboard

# [SYNOPSIS](#SYNOPSIS)

```
#include <tk.h>

int
Tk_ClipboardClear(interp, tkwin)

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

# [ARGUMENTS](#ARGUMENTS)

Tcl\_Interp *\*interp* (in)

Interpreter to use for reporting errors.

Tk\_Window *tkwin* (in)

Window that determines which display's clipboard to manipulate.

Atom *target* (in)

Conversion type for this clipboard item; has same meaning as *target* argument to **Tk\_CreateSelHandler**.

Atom *format* (in)

Representation to use when data is retrieved; has same meaning as *format* argument to **Tk\_CreateSelHandler**.

const char *\*buffer* (in)

Null terminated string containing the data to be appended to the clipboard.

```
    
```

# [DESCRIPTION](#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 interpreter *interp*'s 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 the result of interpreter *interp*.

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 re-entrant at the point **Tk\_ClipboardClear** is invoked.

# [KEYWORDS](#KEYWORDS)

append, clipboard, clear, format, type

4.0 Tk

---

Document: Tk_ClipboardAppend(3) from tk 9.1.0-r0 (Chainguard OS)
Source: https://downloads.sourceforge.net/sourceforge/tcl/tk9.1.0-src.tar.gz
