summaryrefslogtreecommitdiff
path: root/src/os/macosx
diff options
context:
space:
mode:
authormichi_cc <michi_cc@openttd.org>2009-10-04 21:08:38 +0000
committermichi_cc <michi_cc@openttd.org>2009-10-04 21:08:38 +0000
commit049d62b35cd48dffa2a661bf82452f3694ffaaa2 (patch)
treebdf2863b4473660e3c4da9a5c44c0c621f23a1b1 /src/os/macosx
parenta831143f4541926ac0eaec8289e442cba60cc75f (diff)
downloadopenttd-049d62b35cd48dffa2a661bf82452f3694ffaaa2.tar.xz
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
Diffstat (limited to 'src/os/macosx')
-rw-r--r--src/os/macosx/macos.mm17
1 files changed, 17 insertions, 0 deletions
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;
+}