mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
clipboard: add doc strings to all implementations (#13932)
This commit is contained in:
@@ -5,6 +5,9 @@ module clipboard
|
||||
#flag -framework Cocoa
|
||||
#include "@VEXEROOT/vlib/clipboard/clipboard_darwin.m"
|
||||
|
||||
// Clipboard represents a system clipboard.
|
||||
//
|
||||
// System "copy" and "paste" actions utilize the clipboard for temporary storage.
|
||||
pub struct Clipboard {
|
||||
pb voidptr
|
||||
last_cb_serial i64
|
||||
@@ -25,21 +28,27 @@ fn new_clipboard() &Clipboard {
|
||||
return cb
|
||||
}
|
||||
|
||||
// check_availability returns true if the clipboard is ready to be used.
|
||||
pub fn (cb &Clipboard) check_availability() bool {
|
||||
return cb.pb != C.NULL
|
||||
}
|
||||
|
||||
// clear empties the clipboard contents.
|
||||
pub fn (mut cb Clipboard) clear() {
|
||||
cb.foo = 0
|
||||
cb.set_text('')
|
||||
//#[cb->pb clearContents];
|
||||
}
|
||||
|
||||
// free releases all memory associated with the clipboard
|
||||
// instance.
|
||||
pub fn (mut cb Clipboard) free() {
|
||||
cb.foo = 0
|
||||
// nothing to free
|
||||
}
|
||||
|
||||
// has_ownership returns true if the contents of
|
||||
// the clipboard were created by this clipboard instance.
|
||||
pub fn (cb &Clipboard) has_ownership() bool {
|
||||
if cb.last_cb_serial == 0 {
|
||||
return false
|
||||
@@ -50,10 +59,15 @@ pub fn (cb &Clipboard) has_ownership() bool {
|
||||
|
||||
fn C.OSAtomicCompareAndSwapLong()
|
||||
|
||||
// set_text transfers `text` to the system clipboard.
|
||||
// This is often associated with a *copy* action (`Cmd` + `C`).
|
||||
pub fn (mut cb Clipboard) set_text(text string) bool {
|
||||
return C.darwin_set_pasteboard_text(cb.pb, text)
|
||||
}
|
||||
|
||||
// get_text retrieves the contents of the system clipboard
|
||||
// as a `string`.
|
||||
// This is often associated with a *paste* action (`Cmd` + `V`).
|
||||
pub fn (mut cb Clipboard) get_text() string {
|
||||
cb.foo = 0
|
||||
if isnil(cb.pb) {
|
||||
|
||||
Reference in New Issue
Block a user