2019-11-17 03:40:03 +01:00
|
|
|
module clipboard
|
|
|
|
|
2021-01-21 12:45:59 +01:00
|
|
|
// new returns a new `Clipboard` instance allocated on the heap.
|
|
|
|
// The `Clipboard` resources can be released with `free()`
|
2019-11-17 03:40:03 +01:00
|
|
|
pub fn new() &Clipboard {
|
|
|
|
return new_clipboard()
|
|
|
|
}
|
|
|
|
|
2021-01-21 12:45:59 +01:00
|
|
|
// copy copies `text` into the clipboard.
|
2020-05-17 13:51:18 +02:00
|
|
|
pub fn (mut cb Clipboard) copy(text string) bool {
|
2019-11-17 03:40:03 +01:00
|
|
|
return cb.set_text(text)
|
|
|
|
}
|
|
|
|
|
2021-01-21 12:45:59 +01:00
|
|
|
// paste returns current entry as a `string` from the clipboard.
|
2020-05-17 13:51:18 +02:00
|
|
|
pub fn (mut cb Clipboard) paste() string {
|
2019-11-17 03:40:03 +01:00
|
|
|
return cb.get_text()
|
|
|
|
}
|
|
|
|
|
2021-01-21 12:45:59 +01:00
|
|
|
// clear_all clears the clipboard.
|
2020-05-17 13:51:18 +02:00
|
|
|
pub fn (mut cb Clipboard) clear_all() {
|
2019-11-17 03:40:03 +01:00
|
|
|
cb.clear()
|
2019-12-07 13:22:28 +01:00
|
|
|
}
|
2019-11-17 03:40:03 +01:00
|
|
|
|
2021-01-21 12:45:59 +01:00
|
|
|
// destroy destroys the clipboard and free it's resources.
|
2020-05-17 13:51:18 +02:00
|
|
|
pub fn (mut cb Clipboard) destroy() {
|
2019-11-17 03:40:03 +01:00
|
|
|
cb.free()
|
|
|
|
}
|
|
|
|
|
2021-01-21 12:45:59 +01:00
|
|
|
// check_ownership returns `true` if the `Clipboard` has the content ownership.
|
2019-12-06 21:02:09 +01:00
|
|
|
pub fn (cb Clipboard) check_ownership() bool {
|
2019-11-17 03:40:03 +01:00
|
|
|
return cb.has_ownership()
|
|
|
|
}
|
|
|
|
|
2021-01-21 12:45:59 +01:00
|
|
|
// is_available returns `true` if the clipboard is available for use.
|
2019-11-17 03:40:03 +01:00
|
|
|
pub fn (cb &Clipboard) is_available() bool {
|
|
|
|
return cb.check_availability()
|
|
|
|
}
|