| 1 | //NSPasteboard* darwin_new_pasteboard() { |
| 2 | void* darwin_new_pasteboard() { |
| 3 | return (__bridge void*) [NSPasteboard generalPasteboard]; |
| 4 | } |
| 5 | |
| 6 | char* darwin_get_pasteboard_text(void* pb) { |
| 7 | NSString *ns_clip = [((__bridge NSPasteboard*)pb) stringForType:NSStringPboardType]; //NSPasteboardTypeString |
| 8 | if (ns_clip == nil) { |
| 9 | return ""; |
| 10 | } |
| 11 | return [ns_clip UTF8String]; |
| 12 | } |
| 13 | |
| 14 | bool darwin_set_pasteboard_text(void* _pb, string text) { |
| 15 | NSPasteboard* pb = (__bridge NSPasteboard*) _pb; |
| 16 | NSString *ns_clip = [[ NSString alloc ] initWithBytesNoCopy:text.str length:text.len encoding:NSUTF8StringEncoding freeWhenDone: false]; |
| 17 | [pb declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:nil]; |
| 18 | bool ret = [pb setString:ns_clip forType:NSStringPboardType]; |
| 19 | //[ns_clip release]; |
| 20 | int serial = [pb changeCount]; |
| 21 | //OSAtomicCompareAndSwapLong(cb.last_cb_serial, serial, &cb.last_cb_serial); |
| 22 | return ret; |
| 23 | } |
| 24 | |