2019-11-17 05:40:03 +03:00
|
|
|
module clipboard
|
|
|
|
|
2021-01-21 14:45:59 +03:00
|
|
|
// new returns a new `Clipboard` instance allocated on the heap.
|
|
|
|
// The `Clipboard` resources can be released with `free()`
|
2019-11-17 05:40:03 +03:00
|
|
|
pub fn new() &Clipboard {
|
|
|
|
return new_clipboard()
|
|
|
|
}
|
|
|
|
|
2021-01-21 14:45:59 +03:00
|
|
|
// copy copies `text` into the clipboard.
|
2020-05-17 14:51:18 +03:00
|
|
|
pub fn (mut cb Clipboard) copy(text string) bool {
|
2019-11-17 05:40:03 +03:00
|
|
|
return cb.set_text(text)
|
|
|
|
}
|
|
|
|
|
2021-01-21 14:45:59 +03:00
|
|
|
// 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 {
|
2019-11-17 05:40:03 +03:00
|
|
|
return cb.get_text()
|
|
|
|
}
|
|
|
|
|
2021-01-21 14:45:59 +03:00
|
|
|
// clear_all clears the clipboard.
|
2020-05-17 14:51:18 +03:00
|
|
|
pub fn (mut cb Clipboard) clear_all() {
|
2019-11-17 05:40:03 +03:00
|
|
|
cb.clear()
|
2019-12-07 15:22:28 +03:00
|
|
|
}
|
2019-11-17 05:40:03 +03:00
|
|
|
|
2021-01-21 14:45:59 +03:00
|
|
|
// destroy destroys the clipboard and free it's resources.
|
2020-05-17 14:51:18 +03:00
|
|
|
pub fn (mut cb Clipboard) destroy() {
|
2019-11-17 05:40:03 +03:00
|
|
|
cb.free()
|
|
|
|
}
|
|
|
|
|
2021-01-21 14:45:59 +03:00
|
|
|
// 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 {
|
2019-11-17 05:40:03 +03:00
|
|
|
return cb.has_ownership()
|
|
|
|
}
|
|
|
|
|
2021-01-21 14:45:59 +03:00
|
|
|
// is_available returns `true` if the clipboard is available for use.
|
2019-11-17 05:40:03 +03:00
|
|
|
pub fn (cb &Clipboard) is_available() bool {
|
|
|
|
return cb.check_availability()
|
|
|
|
}
|