(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.

This commit is contained in:
michi_cc
2009-10-04 21:08:38 +00:00
parent 434bd81ef0
commit d6da4f24ad
6 changed files with 91 additions and 74 deletions

View File

@@ -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;
}