From 948d940d46240ff518ec9b1037503bebdb47196a Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 24 Aug 2013 23:56:02 +0300 Subject: add clipboard support in SDL2. --- src/utils/copynpaste.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/utils/copynpaste.cpp') diff --git a/src/utils/copynpaste.cpp b/src/utils/copynpaste.cpp index 86b5a668c..9684ebf7a 100644 --- a/src/utils/copynpaste.cpp +++ b/src/utils/copynpaste.cpp @@ -43,6 +43,27 @@ #include "debug.h" +#ifdef USE_SDL2 +bool retrieveBuffer(std::string& text, size_t& pos) +{ + char *buf = SDL_GetClipboardText(); + if (buf) + { + text.insert(pos, buf); + pos += strlen(buf); + SDL_free(buf); + return true; + } + return false; +} + +bool sendBuffer(std::string& text) +{ + return !SDL_SetClipboardText(text.c_str()); +} + +#else + #ifdef WIN32 bool retrieveBuffer(std::string& text, size_t& pos) { @@ -455,3 +476,4 @@ bool sendBuffer(std::string& text A_UNUSED) return false; } #endif +#endif // USE_SDL2 -- cgit v1.2.3-60-g2f50