diff options
author | Indrajith K L | 2022-12-03 17:00:20 +0530 |
---|---|---|
committer | Indrajith K L | 2022-12-03 17:00:20 +0530 |
commit | f5c4671bfbad96bf346bd7e9a21fc4317b4959df (patch) | |
tree | 2764fc62da58f2ba8da7ed341643fc359873142f /v_windows/v/vlib/clipboard/clipboard_darwin.m | |
download | cli-tools-windows-master.tar.gz cli-tools-windows-master.tar.bz2 cli-tools-windows-master.zip |
Diffstat (limited to 'v_windows/v/vlib/clipboard/clipboard_darwin.m')
-rw-r--r-- | v_windows/v/vlib/clipboard/clipboard_darwin.m | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/v_windows/v/vlib/clipboard/clipboard_darwin.m b/v_windows/v/vlib/clipboard/clipboard_darwin.m new file mode 100644 index 0000000..cabc744 --- /dev/null +++ b/v_windows/v/vlib/clipboard/clipboard_darwin.m @@ -0,0 +1,23 @@ +//NSPasteboard* darwin_new_pasteboard() { +void* darwin_new_pasteboard() { + return (__bridge void*) [NSPasteboard generalPasteboard]; +} + +char* darwin_get_pasteboard_text(void* pb) { + NSString *ns_clip = [((__bridge NSPasteboard*)pb) stringForType:NSStringPboardType]; //NSPasteboardTypeString + if (ns_clip == nil) { + return ""; + } + return [ns_clip UTF8String]; +} + +bool darwin_set_pasteboard_text(void* _pb, string text) { + NSPasteboard* pb = (__bridge NSPasteboard*) _pb; + NSString *ns_clip = [[ NSString alloc ] initWithBytesNoCopy:text.str length:text.len encoding:NSUTF8StringEncoding freeWhenDone: false]; + [pb declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:nil]; + bool ret = [pb setString:ns_clip forType:NSStringPboardType]; + //[ns_clip release]; + int serial = [pb changeCount]; + //OSAtomicCompareAndSwapLong(cb.last_cb_serial, serial, &cb.last_cb_serial); + return ret; +} |