Implemented the OSX clipboard using the AppKit API
The X11 dependency is no longer needed on OSX, and has been removedmaster
parent
f30592bf56
commit
7bb12511d9
|
@ -256,12 +256,8 @@ include("${colobot_SOURCE_DIR}/cmake/msys.cmake")
|
|||
##
|
||||
# Clipboard support needs X11 libraries
|
||||
##
|
||||
if(PLATFORM_GNU OR PLATFORM_MACOSX)
|
||||
if(PLATFORM_GNU)
|
||||
find_package(X11 REQUIRED)
|
||||
if(PLATFORM_MACOSX)
|
||||
# Add the includes for X11
|
||||
include_directories("/opt/X11/include")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
|
|
|
@ -7,6 +7,9 @@ add_definitions(-DLIB_COMPILE=1)
|
|||
|
||||
if(PLATFORM_WINDOWS)
|
||||
set(CLIPBOARD_SRC src/clipboardWin32.c)
|
||||
elseif(PLATFORM_MACOSX)
|
||||
set(CMAKE_CXX_FLAGS "-fobjc-arc")
|
||||
set(CLIPBOARD_SRC src/clipboardOSX.m)
|
||||
else()
|
||||
set(CLIPBOARD_SRC src/clipboardX11.c)
|
||||
endif()
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <AppKit/AppKit.h>
|
||||
|
||||
char *widgetGetClipboardText()
|
||||
{
|
||||
NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
|
||||
NSString *myString = [pasteboard stringForType:NSPasteboardTypeString];
|
||||
|
||||
if (myString == nil || [myString length] == 0) return NULL;
|
||||
|
||||
return strdup([myString UTF8String]);
|
||||
}
|
||||
|
||||
bool widgetSetClipboardText(const char *text)
|
||||
{
|
||||
NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
|
||||
[pasteboard clearContents];
|
||||
|
||||
NSString *stringFromUTFString = [[NSString alloc] initWithUTF8String:text];
|
||||
return [pasteboard setString:stringFromUTFString forType:NSStringPboardType];
|
||||
}
|
|
@ -35,7 +35,7 @@ elseif(PLATFORM_LINUX)
|
|||
set(PLATFORM_LIBS "-lrt -lX11")
|
||||
elseif(PLATFORM_MACOSX)
|
||||
find_library(LIBINTL_LIBRARY NAMES intl libintl )
|
||||
set(PLATFORM_LIBS ${LIBINTL_LIBRARY} ${X11_X11_LIB})
|
||||
set(PLATFORM_LIBS ${LIBINTL_LIBRARY})
|
||||
endif()
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue