diff --git a/Quake/pl_linux.c b/Quake/pl_linux.c index ebcec63b..00797927 100644 --- a/Quake/pl_linux.c +++ b/Quake/pl_linux.c @@ -55,6 +55,11 @@ void PL_VID_Shutdown (void) { } +char *PL_GetClipboardData (void) +{ + return NULL; +} + void PL_ErrorDialog (const char *errorMsg) { } diff --git a/Quake/pl_osx.m b/Quake/pl_osx.m index 9b67e08b..52629014 100644 --- a/Quake/pl_osx.m +++ b/Quake/pl_osx.m @@ -30,13 +30,19 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. void PL_SetWindowIcon (void) { - // nothing to do on OS X +/* nothing to do on OS X */ } void PL_VID_Shutdown (void) { } +char *PL_GetClipboardData (void) +{ + /* TODO */ + return NULL; +} + void PL_ErrorDialog(const char *errorMsg) { NSRunCriticalAlertPanel(@"Quake Error", diff --git a/Quake/pl_win.c b/Quake/pl_win.c index d8d15e11..1d142650 100644 --- a/Quake/pl_win.c +++ b/Quake/pl_win.c @@ -62,6 +62,37 @@ void PL_VID_Shutdown (void) DestroyIcon(icon); } +#define MAX_CLIPBOARDTXT MAXCMDLINE /* 256 */ +char *PL_GetClipboardData (void) +{ + char *data = NULL; + char *cliptext; + + if (OpenClipboard(NULL) != 0) + { + HANDLE hClipboardData; + + if ((hClipboardData = GetClipboardData(CF_TEXT)) != NULL) + { + cliptext = (char *) GlobalLock(hClipboardData); + if (cliptext != NULL) + { + size_t size = GlobalSize(hClipboardData) + 1; + /* this is intended for simple small text copies + * such as an ip address, etc: do chop the size + * here, otherwise we may experience Z_Malloc() + * failures and all other not-oh-so-fun stuff. */ + size = q_min(MAX_CLIPBOARDTXT, size); + data = (char *) Z_Malloc(size); + q_strlcpy (data, cliptext, size); + GlobalUnlock (hClipboardData); + } + } + CloseClipboard (); + } + return data; +} + void PL_ErrorDialog(const char *errorMsg) { MessageBox (NULL, errorMsg, "Quake Error", diff --git a/Quake/platform.h b/Quake/platform.h index cd84a574..fdc92327 100644 --- a/Quake/platform.h +++ b/Quake/platform.h @@ -23,13 +23,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef _QUAKE_PLATFORM_H #define _QUAKE_PLATFORM_H -// platform dependent way to set the window icon +/* platform dependent way to set the window icon */ void PL_SetWindowIcon(void); -// platform dependent cleanup +/* platform dependent cleanup */ void PL_VID_Shutdown (void); -// show an error dialog +/* retrieve text from the clipboard (returns Z_Malloc()'ed data) */ +char *PL_GetClipboardData (void); + +/* show an error dialog */ void PL_ErrorDialog(const char *text); #endif /* _QUAKE_PLATFORM_H */