Search guides and the APICtrl K
  1. API reference
  2. Native GUI

gfx/clipboard.h

The system clipboard.

#include <sonore/gfx/clipboard.h>
On this page

Design notes

Why this is not optional

TextEditor had select-all and no copy, cut or paste. A field somebody cannot paste a preset name or a file path into is not a text field -- it is a shape that looks like one. Every other control in this SDK degrades gracefully when something is missing; a text field without the clipboard just does not work.

The three platforms are genuinely different

Windows: a global object you open, read and close. Ownership is not a thing.

macOS: NSPasteboard, likewise a global with a change count.

X11: there is no clipboard. There is a SELECTION, which is a protocol -- the application that copied still OWNS the text and must answer requests for it, and when it quits the clipboard goes with it. That is why pasting on X11 is asynchronous and why copying means agreeing to serve data later. A plugin that ignored this would appear to copy and then paste nothing.

The interface here hides none of that in the sense that matters: setText is best-effort everywhere, and getText can genuinely fail on X11 if nothing is serving, which is a real state and not an error.

Types 1

The Windows clipboard.

Every call opens and closes it. Holding it open would block every other application on the desktop from copying, and a plugin holding a global lock because somebody left an editor open is not acceptable.

↑↓ to move↵ to openEvery public name in the headers, and every guide