v / vlib / clipboard
Raw file | 39 loc (32 sloc) | 971 bytes | Latest commit hash 46f32fc10
1module clipboard
2
3// new returns a new `Clipboard` instance allocated on the heap.
4// The `Clipboard` resources can be released with `free()`
5pub fn new() &Clipboard {
6 return new_clipboard()
7}
8
9// copy copies `text` into the clipboard.
10pub fn (mut cb Clipboard) copy(text string) bool {
11 return cb.set_text(text)
12}
13
14// paste returns current entry as a `string` from the clipboard.
15pub fn (mut cb Clipboard) paste() string {
16 return cb.get_text()
17}
18
19// clear_all clears the clipboard.
20pub fn (mut cb Clipboard) clear_all() {
21 cb.clear()
22}
23
24// destroy destroys the clipboard and frees its resources.
25pub fn (mut cb Clipboard) destroy() {
26 unsafe {
27 cb.free()
28 }
29}
30
31// check_ownership returns `true` if the `Clipboard` has the content ownership.
32pub fn (cb Clipboard) check_ownership() bool {
33 return cb.has_ownership()
34}
35
36// is_available returns `true` if the clipboard is available for use.
37pub fn (cb &Clipboard) is_available() bool {
38 return cb.check_availability()
39}