diff --git a/src/os/macosx/macos.mm b/src/os/macosx/macos.mm --- a/src/os/macosx/macos.mm +++ b/src/os/macosx/macos.mm @@ -183,25 +183,21 @@ const char *GetCurrentLocale(const char /** * Return the contents of the clipboard (COCOA). * - * @param buffer Clipboard content. - * @param last The pointer to the last element of the destination buffer - * @return Whether clipboard is empty or not. + * @return The (optional) clipboard contents. */ -bool GetClipboardContents(char *buffer, const char *last) +std::optional GetClipboardContents() { NSPasteboard *pb = [ NSPasteboard generalPasteboard ]; NSArray *types = [ NSArray arrayWithObject:NSPasteboardTypeString ]; NSString *bestType = [ pb availableTypeFromArray:types ]; /* Clipboard has no text data available. */ - if (bestType == nil) return false; + if (bestType == nil) return std::nullopt; NSString *string = [ pb stringForType:NSPasteboardTypeString ]; - if (string == nil || [ string length ] == 0) return false; + if (string == nil || [ string length ] == 0) return std::nullopt; - strecpy(buffer, [ string UTF8String ], last); - - return true; + return [ string UTF8String ]; } /** Set the application's bundle directory.