Adding Sys_GetClipboardData to the SDL driver.
authorblack <black@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 6 Sep 2004 08:06:40 +0000 (08:06 +0000)
committerblack <black@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 6 Sep 2004 08:06:40 +0000 (08:06 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@4439 d7cf8633-e32d-0410-b094-e92efae38249

sys_sdl.c

index 715d094..3bdbc7e 100644 (file)
--- a/sys_sdl.c
+++ b/sys_sdl.c
@@ -182,6 +182,33 @@ void Sys_Sleep(int milliseconds)
        SDL_Delay(milliseconds);
 }
 
+char *Sys_GetClipboardData (void)
+{
+#ifdef WIN32
+       char *data = NULL;
+       char *cliptext;
+
+       if (OpenClipboard (NULL) != 0)
+       {
+               HANDLE hClipboardData;
+
+               if ((hClipboardData = GetClipboardData (CF_TEXT)) != 0)
+               {
+                       if ((cliptext = GlobalLock (hClipboardData)) != 0) 
+                       {
+                               data = malloc (GlobalSize(hClipboardData)+1);
+                               strcpy (data, cliptext);
+                               GlobalUnlock (hClipboardData);
+                       }
+               }
+               CloseClipboard ();
+       }
+       return data;
+#else
+       return NULL;
+#endif
+}
+
 int SDL_main (int argc, char *argv[])
 {
        double frameoldtime, framenewtime;