aboutsummaryrefslogtreecommitdiff
path: root/v_windows/v/vlib/clipboard/clipboard_darwin.c.v
diff options
context:
space:
mode:
authorIndrajith K L2022-12-03 17:00:20 +0530
committerIndrajith K L2022-12-03 17:00:20 +0530
commitf5c4671bfbad96bf346bd7e9a21fc4317b4959df (patch)
tree2764fc62da58f2ba8da7ed341643fc359873142f /v_windows/v/vlib/clipboard/clipboard_darwin.c.v
downloadcli-tools-windows-f5c4671bfbad96bf346bd7e9a21fc4317b4959df.tar.gz
cli-tools-windows-f5c4671bfbad96bf346bd7e9a21fc4317b4959df.tar.bz2
cli-tools-windows-f5c4671bfbad96bf346bd7e9a21fc4317b4959df.zip
Adds most of the toolsHEADmaster
Diffstat (limited to 'v_windows/v/vlib/clipboard/clipboard_darwin.c.v')
-rw-r--r--v_windows/v/vlib/clipboard/clipboard_darwin.c.v70
1 files changed, 70 insertions, 0 deletions
diff --git a/v_windows/v/vlib/clipboard/clipboard_darwin.c.v b/v_windows/v/vlib/clipboard/clipboard_darwin.c.v
new file mode 100644
index 0000000..13c9ee8
--- /dev/null
+++ b/v_windows/v/vlib/clipboard/clipboard_darwin.c.v
@@ -0,0 +1,70 @@
+module clipboard
+
+#include <libkern/OSAtomic.h>
+#include <Cocoa/Cocoa.h>
+#flag -framework Cocoa
+#include "@VEXEROOT/vlib/clipboard/clipboard_darwin.m"
+
+pub struct Clipboard {
+ pb voidptr
+ last_cb_serial i64
+mut:
+ foo int // TODO remove, for mut hack
+}
+
+fn C.darwin_new_pasteboard() voidptr
+
+fn C.darwin_get_pasteboard_text(voidptr) &byte
+
+fn C.darwin_set_pasteboard_text(voidptr, string) bool
+
+fn new_clipboard() &Clipboard {
+ cb := &Clipboard{
+ pb: C.darwin_new_pasteboard() // pb
+ }
+ return cb
+}
+
+pub fn (cb &Clipboard) check_availability() bool {
+ return cb.pb != C.NULL
+}
+
+pub fn (mut cb Clipboard) clear() {
+ cb.foo = 0
+ cb.set_text('')
+ //#[cb->pb clearContents];
+}
+
+pub fn (mut cb Clipboard) free() {
+ cb.foo = 0
+ // nothing to free
+}
+
+pub fn (cb &Clipboard) has_ownership() bool {
+ if cb.last_cb_serial == 0 {
+ return false
+ }
+ //#return [cb->pb changeCount] == cb->last_cb_serial;
+ return false
+}
+
+fn C.OSAtomicCompareAndSwapLong()
+
+pub fn (mut cb Clipboard) set_text(text string) bool {
+ return C.darwin_set_pasteboard_text(cb.pb, text)
+}
+
+pub fn (mut cb Clipboard) get_text() string {
+ cb.foo = 0
+ if isnil(cb.pb) {
+ return ''
+ }
+ utf8_clip := C.darwin_get_pasteboard_text(cb.pb)
+ return unsafe { tos_clone(&byte(utf8_clip)) }
+}
+
+// new_primary returns a new X11 `PRIMARY` type `Clipboard` instance allocated on the heap.
+// Please note: new_primary only works on X11 based systems.
+pub fn new_primary() &Clipboard {
+ panic('Primary clipboard is not supported on non-Linux systems.')
+}