2010-07-07 23:24:04 -07:00
|
|
|
/*
|
2011-04-08 13:03:26 -07:00
|
|
|
Simple DirectMedia Layer
|
2013-02-15 08:47:44 -08:00
|
|
|
Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
|
2010-07-07 23:24:04 -07:00
|
|
|
|
2011-04-08 13:03:26 -07:00
|
|
|
This software is provided 'as-is', without any express or implied
|
|
|
|
warranty. In no event will the authors be held liable for any damages
|
|
|
|
arising from the use of this software.
|
2010-07-07 23:24:04 -07:00
|
|
|
|
2011-04-08 13:03:26 -07:00
|
|
|
Permission is granted to anyone to use this software for any purpose,
|
|
|
|
including commercial applications, and to alter it and redistribute it
|
|
|
|
freely, subject to the following restrictions:
|
2010-07-07 23:24:04 -07:00
|
|
|
|
2011-04-08 13:03:26 -07:00
|
|
|
1. The origin of this software must not be misrepresented; you must not
|
|
|
|
claim that you wrote the original software. If you use this software
|
|
|
|
in a product, an acknowledgment in the product documentation would be
|
|
|
|
appreciated but is not required.
|
|
|
|
2. Altered source versions must be plainly marked as such, and must not be
|
|
|
|
misrepresented as being the original software.
|
|
|
|
3. This notice may not be removed or altered from any source distribution.
|
2010-07-07 23:24:04 -07:00
|
|
|
*/
|
2013-11-24 23:56:17 -05:00
|
|
|
#include "../SDL_internal.h"
|
2010-07-07 23:24:04 -07:00
|
|
|
|
|
|
|
#include "SDL_clipboard.h"
|
|
|
|
#include "SDL_sysvideo.h"
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
SDL_SetClipboardText(const char *text)
|
|
|
|
{
|
2010-07-07 23:54:03 -07:00
|
|
|
SDL_VideoDevice *_this = SDL_GetVideoDevice();
|
|
|
|
|
2010-07-08 05:43:34 -07:00
|
|
|
if (!text) {
|
|
|
|
text = "";
|
|
|
|
}
|
2010-07-07 23:54:03 -07:00
|
|
|
if (_this->SetClipboardText) {
|
|
|
|
return _this->SetClipboardText(_this, text);
|
|
|
|
} else {
|
2013-08-29 08:29:21 -07:00
|
|
|
SDL_free(_this->clipboard_text);
|
2010-07-07 23:54:03 -07:00
|
|
|
_this->clipboard_text = SDL_strdup(text);
|
|
|
|
return 0;
|
|
|
|
}
|
2010-07-07 23:24:04 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
char *
|
2010-07-12 00:35:14 -07:00
|
|
|
SDL_GetClipboardText(void)
|
2010-07-07 23:24:04 -07:00
|
|
|
{
|
2010-07-07 23:54:03 -07:00
|
|
|
SDL_VideoDevice *_this = SDL_GetVideoDevice();
|
2010-07-07 23:24:04 -07:00
|
|
|
|
2010-07-07 23:54:03 -07:00
|
|
|
if (_this->GetClipboardText) {
|
|
|
|
return _this->GetClipboardText(_this);
|
2010-07-07 23:24:04 -07:00
|
|
|
} else {
|
2010-07-07 23:54:03 -07:00
|
|
|
const char *text = _this->clipboard_text;
|
|
|
|
if (!text) {
|
|
|
|
text = "";
|
|
|
|
}
|
|
|
|
return SDL_strdup(text);
|
2010-07-07 23:24:04 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SDL_bool
|
2010-07-12 00:35:14 -07:00
|
|
|
SDL_HasClipboardText(void)
|
2010-07-07 23:24:04 -07:00
|
|
|
{
|
2010-07-07 23:54:03 -07:00
|
|
|
SDL_VideoDevice *_this = SDL_GetVideoDevice();
|
2010-07-07 23:24:04 -07:00
|
|
|
|
2010-07-07 23:54:03 -07:00
|
|
|
if (_this->HasClipboardText) {
|
|
|
|
return _this->HasClipboardText(_this);
|
|
|
|
} else {
|
2013-08-29 08:30:21 -07:00
|
|
|
if (_this->clipboard_text && _this->clipboard_text[0] != '\0') {
|
2010-07-07 23:54:03 -07:00
|
|
|
return SDL_TRUE;
|
|
|
|
} else {
|
|
|
|
return SDL_FALSE;
|
|
|
|
}
|
|
|
|
}
|
2010-07-07 23:24:04 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* vi: set ts=4 sw=4 expandtab: */
|