1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

clipboard: fix clear() on macos

This commit is contained in:
Alexander Medvednikov 2020-11-20 11:58:53 +01:00
parent 7c2c187743
commit 412e2a43e9
3 changed files with 4 additions and 4 deletions

View File

@ -31,7 +31,7 @@ fn (cb &Clipboard) check_availability() bool {
fn (mut cb Clipboard) clear() { fn (mut cb Clipboard) clear() {
cb.foo = 0 cb.foo = 0
cb.set_text('') cb.set_text('')
#[cb->pb clearContents]; //#[cb->pb clearContents];
} }
fn (mut cb Clipboard) free() { fn (mut cb Clipboard) free() {

View File

@ -16,7 +16,7 @@ bool darwin_set_pasteboard_text(void* _pb, string text) {
NSString *ns_clip = [[ NSString alloc ] initWithBytesNoCopy:text.str length:text.len encoding:NSUTF8StringEncoding freeWhenDone: false]; NSString *ns_clip = [[ NSString alloc ] initWithBytesNoCopy:text.str length:text.len encoding:NSUTF8StringEncoding freeWhenDone: false];
[pb declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:nil]; [pb declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:nil];
bool ret = [pb setString:ns_clip forType:NSStringPboardType]; bool ret = [pb setString:ns_clip forType:NSStringPboardType];
[ns_clip release]; //[ns_clip release];
int serial = [pb changeCount]; int serial = [pb changeCount];
//OSAtomicCompareAndSwapLong(cb.last_cb_serial, serial, &cb.last_cb_serial); //OSAtomicCompareAndSwapLong(cb.last_cb_serial, serial, &cb.last_cb_serial);
return ret; return ret;

View File

@ -5,9 +5,9 @@ fn run_test(is_primary bool) {
if !cb.is_available() { if !cb.is_available() {
return return
} }
//assert cb.check_ownership() == false assert cb.check_ownership() == false
assert cb.copy('I am a good boy!') == true assert cb.copy('I am a good boy!') == true
//assert cb.check_ownership() == true // assert cb.check_ownership() == true TODO
assert cb.paste() == 'I am a good boy!' assert cb.paste() == 'I am a good boy!'
cb.clear_all() cb.clear_all()
assert cb.paste().len <= 0 assert cb.paste().len <= 0