added PL_GetClipboardData()

git-svn-id: http://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@741 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
sezero 2012-09-27 12:58:37 +00:00
parent 0b8245c767
commit 81da5959a6
4 changed files with 49 additions and 4 deletions

View file

@ -55,6 +55,11 @@ void PL_VID_Shutdown (void)
{ {
} }
char *PL_GetClipboardData (void)
{
return NULL;
}
void PL_ErrorDialog (const char *errorMsg) void PL_ErrorDialog (const char *errorMsg)
{ {
} }

View file

@ -30,13 +30,19 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
void PL_SetWindowIcon (void) void PL_SetWindowIcon (void)
{ {
// nothing to do on OS X /* nothing to do on OS X */
} }
void PL_VID_Shutdown (void) void PL_VID_Shutdown (void)
{ {
} }
char *PL_GetClipboardData (void)
{
/* TODO */
return NULL;
}
void PL_ErrorDialog(const char *errorMsg) void PL_ErrorDialog(const char *errorMsg)
{ {
NSRunCriticalAlertPanel(@"Quake Error", NSRunCriticalAlertPanel(@"Quake Error",

View file

@ -62,6 +62,37 @@ void PL_VID_Shutdown (void)
DestroyIcon(icon); 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) void PL_ErrorDialog(const char *errorMsg)
{ {
MessageBox (NULL, errorMsg, "Quake Error", MessageBox (NULL, errorMsg, "Quake Error",

View file

@ -23,13 +23,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef _QUAKE_PLATFORM_H #ifndef _QUAKE_PLATFORM_H
#define _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); void PL_SetWindowIcon(void);
// platform dependent cleanup /* platform dependent cleanup */
void PL_VID_Shutdown (void); 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); void PL_ErrorDialog(const char *text);
#endif /* _QUAKE_PLATFORM_H */ #endif /* _QUAKE_PLATFORM_H */