1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00
v/vlib/clipboard/clipboard.v

40 lines
971 B
V
Raw Permalink Normal View History

module clipboard
// new returns a new `Clipboard` instance allocated on the heap.
// The `Clipboard` resources can be released with `free()`
pub fn new() &Clipboard {
return new_clipboard()
}
// copy copies `text` into the clipboard.
2020-05-17 14:51:18 +03:00
pub fn (mut cb Clipboard) copy(text string) bool {
return cb.set_text(text)
}
// paste returns current entry as a `string` from the clipboard.
2020-05-17 14:51:18 +03:00
pub fn (mut cb Clipboard) paste() string {
return cb.get_text()
}
// clear_all clears the clipboard.
2020-05-17 14:51:18 +03:00
pub fn (mut cb Clipboard) clear_all() {
cb.clear()
}
// destroy destroys the clipboard and frees its resources.
2020-05-17 14:51:18 +03:00
pub fn (mut cb Clipboard) destroy() {
2022-08-20 08:03:07 +03:00
unsafe {
cb.free()
}
}
// check_ownership returns `true` if the `Clipboard` has the content ownership.
2019-12-06 23:02:09 +03:00
pub fn (cb Clipboard) check_ownership() bool {
return cb.has_ownership()
}
// is_available returns `true` if the clipboard is available for use.
pub fn (cb &Clipboard) is_available() bool {
return cb.check_availability()
}