LavaUI docs GitHub

enum ClipboardBridge

Swift

enum ClipboardBridge

Indirection so LavaUI views can reach the clipboard without every view carrying an Editor reference. The app installs this once at startup.

Sources/LavaUI/TextField.swift:1094

Properties

static var canWriteImage: Bool { get }

Whether a picture can be copied at all here — worth asking before offering the user a Copy button that would do nothing.

Sources/LavaUI/TextField.swift:1132

nonisolated(unsafe) static var imageFileWriter: ((String) -> Void)?

Offers the PNG at a path as the selection. Nil if the host cannot hold a picture, which is every windowed build: GLFW's clipboard is text and nothing else, and a copy that silently did nothing would be discovered in another application some minutes later.

A path, like ScreenCapture, and for the same reason: a picture does not fit in a shared-memory message. The host reads the file before it answers, so the caller may delete it immediately.

Sources/LavaUI/TextField.swift:1110

nonisolated(unsafe) static var imageReader: (() -> [UInt8])?

PNG of the seat selection, when it is an image. Nil if the host cannot read pictures (windowed GLFW) or the selection is text.

Sources/LavaUI/TextField.swift:1101

nonisolated(unsafe) static var primaryReader: (() -> String)?

The primary selection — what middle-click pastes. A second selection, filled by the act of selecting rather than by a copy command, which is why a widget writes it from wherever a drag ends rather than from a keybinding.

Separate closures rather than a flag, because the two are separate protocols under a compositor and the host wires whichever it has: left nil, primary simply does nothing, and middle-click pastes nothing.

Sources/LavaUI/TextField.swift:1120

nonisolated(unsafe) static var primaryWriter: ((String) -> Void)?

Sets the primary selection, as selecting text does.

Sources/LavaUI/TextField.swift:1122

nonisolated(unsafe) static var reader: (() -> String)?

Reads the clipboard's text. Installed by the host app.

Sources/LavaUI/TextField.swift:1096

nonisolated(unsafe) static var writer: ((String) -> Void)?

Replaces the clipboard's text. Installed by the host app.

Sources/LavaUI/TextField.swift:1098

Methods

static func read() -> String

The clipboard's text, or empty when no reader is installed.

Sources/LavaUI/TextField.swift:1125

static func readImage() -> [UInt8]?

The clipboard's picture as PNG bytes, or nil when there is none or it cannot be read here.

Sources/LavaUI/TextField.swift:1129

static func readPrimary() -> String

The primary selection's text, or empty when there is none here.

Sources/LavaUI/TextField.swift:1142

static func write(_ text: String)

Puts text on the clipboard. Does nothing when no writer is installed.

Sources/LavaUI/TextField.swift:1127

@discardableResult static func writeImage(file path: String) -> Bool

Puts the PNG at path on the clipboard. Returns false when this host cannot hold a picture. The file may be deleted as soon as this returns.

Sources/LavaUI/TextField.swift:1136

static func writePrimary(_ text: String)

Sets the primary selection. Does nothing when this host has none.

Sources/LavaUI/TextField.swift:1144