diff --git a/Quake/pl_osx.m b/Quake/pl_osx.m index 52629014..a2f1a173 100644 --- a/Quake/pl_osx.m +++ b/Quake/pl_osx.m @@ -37,16 +37,36 @@ void PL_VID_Shutdown (void) { } +#define MAX_CLIPBOARDTXT MAXCMDLINE /* 256 */ char *PL_GetClipboardData (void) { - /* TODO */ - return NULL; + char *data = NULL; + NSPasteboard* pasteboard = [NSPasteboard generalPasteboard]; + NSArray* types = [pasteboard types]; + + if ([types containsObject: NSStringPboardType]) { + NSString* clipboardString = [pasteboard stringForType: NSStringPboardType]; + if (clipboardString != NULL && [clipboardString length] > 0) { + size_t sz = [clipboardString length] + 1; + sz = q_min(MAX_CLIPBOARDTXT, sz); + data = (char *) Z_Malloc(sz); +#if (MAC_OS_X_VERSION_MIN_REQUIRED < 1040) /* for ppc builds targeting 10.3 and older */ + q_strlcpy (data, [clipboardString cString], sz); +#else + q_strlcpy (data, [clipboardString cStringUsingEncoding: NSASCIIStringEncoding], sz); +#endif + } + } + return data; } void PL_ErrorDialog(const char *errorMsg) { - NSRunCriticalAlertPanel(@"Quake Error", - [NSString stringWithUTF8String:errorMsg], - @"OK", nil, nil); +#if (MAC_OS_X_VERSION_MIN_REQUIRED < 1040) /* ppc builds targeting 10.3 and older */ + NSString* msg = [NSString stringWithCString:errorMsg]; +#else + NSString* msg = [NSString stringWithCString:errorMsg encoding:NSASCIIStringEncoding]; +#endif + NSRunCriticalAlertPanel (@"Quake Error", msg, @"OK", nil, nil); } diff --git a/README.html b/README.html index 8820c6e6..b35b545a 100644 --- a/README.html +++ b/README.html @@ -176,7 +176,7 @@ these patched libSDL binaries may help.
  • Made Quake shareware 1.00 and 1.01 versions to be recognized properly.
  • Fixed control-character handling in unicode mode.
  • Made the keypad keys to send separate key events in game mode.
  • -
  • Ctrl-V text pasting support from OS clipboard to console (windows-only for now.)
  • +
  • Text pasting support from OS clipboard to console. (windows and macosx.)
  • Fixed increased (more than 32) dynamic lights.
  • Music playback: Made sure that the file's channels count is supported.
  • Support for Solaris.
  • diff --git a/README.sgml b/README.sgml index d591b014..314c4aee 100644 --- a/README.sgml +++ b/README.sgml @@ -102,7 +102,7 @@ these patched libSDL binaries may help. Made Quake shareware 1.00 and 1.01 versions to be recognized properly. Fixed control-character handling in unicode mode. Made the keypad keys to send separate key events in game mode. - Ctrl-V text pasting support from OS clipboard to console (windows-only for now.) + Text pasting support from OS clipboard to console. (windows and macosx.) Fixed increased (more than 32) dynamic lights. Music playback: Made sure that the file's channels count is supported. Support for Solaris. diff --git a/README.txt b/README.txt index 4d21218c..bc14ad49 100644 --- a/README.txt +++ b/README.txt @@ -165,8 +165,8 @@ o Made the keypad keys to send separate key events in game mode. - o Ctrl-V text pasting support from OS clipboard to console (windows- - only for now.) + o Text pasting support from OS clipboard to console. (windows and + macosx.) o Fixed increased (more than 32) dynamic lights.