clipboard #
Description
clipboard provides access to the platform's clipboard mechanism. You can use it to read from the system clipboard, and write to it from your applications.
Examples
import clipboard
fn main() {
mut c := clipboard.new()
println(c.get_text())
}
fn new #
fn new() &Clipboard
new returns a new Clipboard instance allocated on the heap. The Clipboard resources can be released with free()
fn new_primary #
fn new_primary() &Clipboard
new_primary returns a new X11 PRIMARY type Clipboard instance allocated on the heap. Please note: new_primary only works on X11 based systems.
type Clipboard #
Available on Android, Termux and Solaris only.
type Clipboard = dummy.Clipboard
Available on macOS only.
@[heap]
struct Clipboard {
pb voidptr
last_cb_serial i64
mut:
foo int // TODO: remove, for mut hack
}
Available on all platforms except macOS, Windows, Android, Termux and Solaris.
type Clipboard = x11.Clipboard
Available on Windows only.
@[heap]
struct Clipboard {
max_retries int
retry_delay int
mut:
hwnd voidptr
foo int // TODO: remove
}
Clipboard represents a system clipboard.
System "copy" and "paste" actions utilize the clipboard for temporary storage.
fn (Clipboard) copy #
fn (mut cb Clipboard) copy(text string) bool
copy copies text into the clipboard.
fn (Clipboard) paste #
fn (mut cb Clipboard) paste() string
paste returns current entry as a string from the clipboard.
fn (Clipboard) clear_all #
fn (mut cb Clipboard) clear_all()
clear_all clears the clipboard.
fn (Clipboard) destroy #
fn (mut cb Clipboard) destroy()
destroy destroys the clipboard and frees its resources.
fn (Clipboard) check_ownership #
fn (cb Clipboard) check_ownership() bool
check_ownership returns true if the Clipboard has the content ownership.
fn (Clipboard) is_available #
fn (cb &Clipboard) is_available() bool
is_available returns true if the clipboard is available for use.
fn (Clipboard) check_availability #
Available on macOS and Windows only.
fn (cb &Clipboard) check_availability() bool
check_availability returns true if the clipboard is ready to be used.
fn (Clipboard) clear #
Available on macOS and Windows only.
fn (mut cb Clipboard) clear()
clear empties the clipboard contents.
fn (Clipboard) free #
Available on macOS and Windows only.
fn (mut cb Clipboard) free()
free releases all memory associated with the clipboard instance.
fn (Clipboard) has_ownership #
Available on macOS and Windows only.
fn (cb &Clipboard) has_ownership() bool
has_ownership returns true if the contents of the clipboard were created by this clipboard instance.
fn (Clipboard) set_text #
Available on macOS and Windows only.
fn (mut cb Clipboard) set_text(text string) bool
set_text transfers text to the system clipboard. This is often associated with a copy action (Ctrl + C).
fn (Clipboard) get_text #
Available on macOS and Windows only.
fn (mut cb Clipboard) get_text() string
get_text retrieves the contents of the system clipboard. This is often associated with a paste action (Ctrl + V).