From 40a6f67c7fc621ac5a0e531856e11a1ca8c40a96 Mon Sep 17 00:00:00 2001 From: tomaz Date: Mon, 2 Aug 2004 18:00:26 +0000 Subject: [PATCH] Added CTRL+V paste into the console for win32 users. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@4296 d7cf8633-e32d-0410-b094-e92efae38249 --- sys.h | 2 ++ sys_linux.c | 5 +++++ sys_win.c | 24 +++++++++++++++++++++++- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/sys.h b/sys.h index 608e53c3..2644d074 100644 --- a/sys.h +++ b/sys.h @@ -83,5 +83,7 @@ void Sys_Sleep(int milliseconds); void Sys_SendKeyEvents (void); // Perform Key_Event () callbacks until the input que is empty +char *Sys_GetClipboardData (void); + #endif diff --git a/sys_linux.c b/sys_linux.c index ef11c6be..499aaada 100644 --- a/sys_linux.c +++ b/sys_linux.c @@ -202,6 +202,11 @@ void Sys_Sleep(int milliseconds) #endif } +char *Sys_GetClipboardData (void) +{ + return NULL; +} + int main (int argc, const char **argv) { double frameoldtime, framenewtime; diff --git a/sys_win.c b/sys_win.c index e7ec1630..8e3c628f 100644 --- a/sys_win.c +++ b/sys_win.c @@ -277,6 +277,29 @@ void Sys_Sleep(int milliseconds) Sleep(milliseconds); } +char *Sys_GetClipboardData (void) +{ + 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; +} + /* ============================================================================== @@ -439,4 +462,3 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin /* return success of application */ return true; } - -- 2.39.2