Get clipboard data from SDL

This makes pasting in client console and UI edit fields work on X11 and OS X.

Sys_GetClipboardData is only used by client, so returning NULL in dedicated is fine.
This commit is contained in:
Zack Middleton 2014-08-27 04:17:39 -05:00
parent 077f6bd068
commit 137ddb9dc6
3 changed files with 29 additions and 37 deletions

View file

@ -127,6 +127,35 @@ char *Sys_ConsoleInput(void)
return CON_Input( );
}
/*
==================
Sys_GetClipboardData
==================
*/
char *Sys_GetClipboardData(void)
{
#ifdef DEDICATED
return NULL;
#else
char *data = NULL;
char *cliptext;
if ( ( cliptext = SDL_GetClipboardText() ) != NULL ) {
if ( cliptext[0] != '\0' ) {
size_t bufsize = strlen( cliptext ) + 1;
data = Z_Malloc( bufsize );
Q_strncpyz( data, cliptext, bufsize );
// find first listed char and set to '\0'
strtok( data, "\n\r\b" );
}
SDL_free( cliptext );
}
return data;
#endif
}
#ifdef DEDICATED
# define PID_FILENAME PRODUCT_NAME "_server.pid"
#else