clipboard

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 6, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Clipboard

type Clipboard interface {
	// Read reads the clipboard and returns the MIME type and
	// the raw bytes data in the clipboard
	Read() (types.MIME, []byte)
	// Write write the given data as the given MIME type and
	// returns true if success or false if failed.
	Write(types.MIME, []byte) bool
}

Clipboard is an interface that defines the operations of a clipboard

type LocalClipboard

type LocalClipboard interface {
	Clipboard
	// Watch watches a given type of data from local clipboard and
	// send the data back through a provided channel.
	Watch(ctx context.Context, dt types.MIME) <-chan []byte
}

LocalClipboard is an extension to the Clipboard interface for local purpose

var Local LocalClipboard = &local{
	buf: []byte{},
}

Local is a local clipboard that can interact with the OS clipboard.

type UniversalClipboard

type UniversalClipboard interface {
	Clipboard
	// ReadAs reads the clipboard as a given MIME type and return
	// the raw bytes if the type matches or nil if it does not.
	// This method is generally faster than the Clipboard.Read because
	// it avoids data copy if the MIME type does not match.
	ReadAs(t types.MIME) []byte
}

UniversalClipboard is an of Clipboard interface for universal purpose

var Universal UniversalClipboard = &universal{
	typ: types.MIMEPlainText,
	buf: []byte{},
}

Universal is the Midgard's universal clipboard, it keeps the data in memory and logs its change history to the data store of midgard.

It holds a global shared storage that can be edited/fetched at anytime.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL