| 203 | |
| 204 | #ifndef WITH_COCOA |
| 205 | std::optional<std::string> GetClipboardContents() |
| 206 | { |
| 207 | #ifdef WITH_SDL2 |
| 208 | if (SDL_HasClipboardText() == SDL_FALSE) return std::nullopt; |
| 209 | |
| 210 | char *clip = SDL_GetClipboardText(); |
| 211 | if (clip != nullptr) { |
| 212 | std::string result = clip; |
| 213 | SDL_free(clip); |
| 214 | return result; |
| 215 | } |
| 216 | #endif |
| 217 | |
| 218 | return std::nullopt; |
| 219 | } |
| 220 | #endif |
| 221 | |
| 222 |