2006-05-24 19:34:30 -04:00
|
|
|
! Copyright (C) 2006 Slava Pestov.
|
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
2006-05-24 18:40:54 -04:00
|
|
|
IN: cocoa
|
2006-06-03 02:55:57 -04:00
|
|
|
USING: arrays gadgets kernel namespaces objc objc-classes
|
|
|
|
sequences ;
|
2006-05-24 18:40:54 -04:00
|
|
|
|
2006-05-24 19:34:30 -04:00
|
|
|
: NSStringPboardType "NSStringPboardType" ;
|
2006-05-24 18:40:54 -04:00
|
|
|
|
2006-05-24 19:34:30 -04:00
|
|
|
: pasteboard-string? ( type id -- seq )
|
2006-05-29 05:19:51 -04:00
|
|
|
NSStringPboardType swap -> types CF>string-array member? ;
|
2006-05-24 18:40:54 -04:00
|
|
|
|
|
|
|
: pasteboard-string ( id -- str )
|
2006-05-29 05:19:51 -04:00
|
|
|
NSStringPboardType <NSString> -> stringForType:
|
2006-05-24 19:34:30 -04:00
|
|
|
dup [ CF>string ] when ;
|
2006-05-24 18:40:54 -04:00
|
|
|
|
|
|
|
: set-pasteboard-types ( seq id -- )
|
2006-05-29 05:19:51 -04:00
|
|
|
swap <NSArray> f -> declareTypes:owner: drop ;
|
2006-05-24 18:40:54 -04:00
|
|
|
|
|
|
|
: set-pasteboard-string ( str id -- )
|
2006-05-24 19:34:30 -04:00
|
|
|
NSStringPboardType <NSString>
|
|
|
|
dup 1array pick set-pasteboard-types
|
2006-05-29 05:19:51 -04:00
|
|
|
>r swap <NSString> r> -> setString:forType: drop ;
|
2006-06-03 02:41:28 -04:00
|
|
|
|
|
|
|
TUPLE: pasteboard handle ;
|
|
|
|
|
2006-08-15 03:01:24 -04:00
|
|
|
M: pasteboard clipboard-contents
|
2006-06-03 02:41:28 -04:00
|
|
|
pasteboard-handle pasteboard-string ;
|
|
|
|
|
2006-08-15 03:01:24 -04:00
|
|
|
M: pasteboard set-clipboard-contents
|
2006-06-03 02:41:28 -04:00
|
|
|
pasteboard-handle set-pasteboard-string ;
|
2006-06-03 02:55:57 -04:00
|
|
|
|
|
|
|
: init-clipboard ( -- )
|
|
|
|
NSPasteboard -> generalPasteboard <pasteboard>
|
|
|
|
clipboard set-global ;
|