factor/library/ui/cocoa/pasteboard-utils.factor

22 lines
672 B
Factor
Raw Normal View History

2006-05-24 19:34:30 -04:00
! Copyright (C) 2006 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
IN: cocoa
2006-05-24 19:34:30 -04:00
USING: arrays kernel objc-NSPasteboard sequences ;
2006-05-24 19:34:30 -04:00
: NSStringPboardType "NSStringPboardType" ;
2006-05-24 19:34:30 -04:00
: pasteboard-string? ( type id -- seq )
NSStringPboardType swap [types] CF>string-array member? ;
: pasteboard-string ( id -- str )
2006-05-24 19:34:30 -04:00
NSStringPboardType <NSString> [stringForType:]
dup [ CF>string ] when ;
: set-pasteboard-types ( seq id -- )
2006-05-24 19:34:30 -04:00
swap <NSArray> f [declareTypes:owner:] drop ;
: set-pasteboard-string ( str id -- )
2006-05-24 19:34:30 -04:00
NSStringPboardType <NSString>
dup 1array pick set-pasteboard-types
>r swap <NSString> r> [setString:forType:] drop ;