From 049d62b35cd48dffa2a661bf82452f3694ffaaa2 Mon Sep 17 00:00:00 2001 From: michi_cc Date: Sun, 4 Oct 2009 21:08:38 +0000 Subject: (svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X. --- src/os/macosx/macos.mm | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/os/macosx') diff --git a/src/os/macosx/macos.mm b/src/os/macosx/macos.mm index 7f195ed63..35c5cb061 100644 --- a/src/os/macosx/macos.mm +++ b/src/os/macosx/macos.mm @@ -11,6 +11,7 @@ #include "../../core/bitmath_func.hpp" #include "../../rev.h" #include "macos.h" +#include "../../string_func.h" #define Rect OTTDRect #define Point OTTDPoint @@ -118,3 +119,19 @@ const char *GetCurrentLocale(const char *) } +bool GetClipboardContents(char *buffer, size_t buff_len) +{ + NSPasteboard *pb = [ NSPasteboard generalPasteboard ]; + NSArray *types = [ NSArray arrayWithObject:NSStringPboardType ]; + NSString *bestType = [ pb availableTypeFromArray:types ]; + + /* Clipboard has no text data available. */ + if (bestType == nil) return false; + + NSString *string = [ pb stringForType:NSStringPboardType ]; + if (string == nil || [ string length ] == 0) return false; + + ttd_strlcpy(buffer, [ string UTF8String ], buff_len); + + return true; +} -- cgit v1.2.3-54-g00ecf