Expand description
The system clipboard over arboard (feature clipboard): the
clipboard’s SystemBackend for files, images, HTML and text, and
the primary selection on X11 and Wayland.
egui-pop’s default backend writes text through egui and reads
nothing. SystemClipboardPlugin installs Arboard instead
(egui_pop_api::clipboard::set_backend): a copy writes its richest
standard representation, a paste reads every format the clipboard
holds as one external item, and the paste key works when the
clipboard holds no text (a file manager’s files, a browser’s image).
| Writes (one per copy, the first it has) | Reads | |
|---|---|---|
| files | text/uri-list (file:// URIs) | yes |
| an image | image/png | yes |
| HTML | text/html, with the text as its alternative | yes |
| text | text/plain | yes |
arboard writes one format per copy (HTML takes its text along):
files win over an image, an image over HTML, HTML over text. Private
types stay in the owner; a kernel wanting them on the system
clipboard gives its own backend (Clipboard::system).
The platform’s path (Arboard::path, in the clipboard
collector):
- Windows (the Win32 clipboard), macOS (
NSPasteboard) and X11 (selections, through x11rb) as arboard reaches them. - Wayland: through XWayland by default. A copy then reaches native
Wayland applications only when the compositor hands XWayland’s
selection over, which some do only while an X11 window has the
focus. The
clipboard-waylandfeature adds the data-control protocol (arboard’swayland-data-control, through wl-clipboard-rs): used where the compositor offers it (wlroots compositors, KDE Plasma), XWayland elsewhere. The core protocol, which needs the window’s input serial, is what egui-winit’s own text clipboard uses (smithay-clipboard); arboard does not. - The web: nothing (the module is not built for
wasm32).
The primary selection (select to copy, middle-click to paste) is
read and written on X11 and Wayland (clipboard::primary_text,
clipboard::set_primary_text); elsewhere there is none. egui-pop’s
own widgets do not use it yet (ADR 0015: opt-in, for text inputs and
the code editor).
The clipboard is opened on first use, not when the plugin connects, so connecting it touches nothing (tests, catalogues).
use egui_pop_platform::clipboard::{file_uris, paths_of};
let list = file_uris(&[std::path::PathBuf::from("/tmp/a b.png")]);
assert_eq!(list, "file:///tmp/a%20b.png");
assert_eq!(paths_of(&list), [std::path::PathBuf::from("/tmp/a b.png")]);Structs§
- Arboard
- The system clipboard through arboard, opened on first use.
- System
Clipboard Plugin - Installs
Arboardas the clipboard’s system backend when it connects, and egui’s text again when it disconnects. Needs the clipboard plugin (egui_pop_api::clipboard::ClipboardPlugin).
Constants§
- PLUGIN
- The plugin’s id: with it added,
run_nativeturns eframe’s clipboard shortcuts off and the keymap runs the copy, cut and paste chords, in text fields too (egui_pop_api::clipboard::set_keymap_shortcuts).