SDL  2.0
SDL_clipboard.c File Reference
#include "../SDL_internal.h"
#include "SDL_clipboard.h"
#include "SDL_sysvideo.h"
+ Include dependency graph for SDL_clipboard.c:

Go to the source code of this file.

Functions

int SDL_SetClipboardText (const char *text)
 Put UTF-8 text into the clipboard.
char * SDL_GetClipboardText (void)
 Get UTF-8 text from the clipboard, which must be freed with SDL_free()
SDL_bool SDL_HasClipboardText (void)
 Returns a flag indicating whether the clipboard exists and contains a text string that is non-empty.

Function Documentation

char* SDL_GetClipboardText ( void  )

Get UTF-8 text from the clipboard, which must be freed with SDL_free()

See Also
SDL_SetClipboardText()

Definition at line 49 of file SDL_clipboard.c.

References _this, SDL_VideoDevice::clipboard_text, SDL_VideoDevice::GetClipboardText, SDL_GetVideoDevice(), SDL_SetError, SDL_strdup, and text.

{
if (!_this) {
SDL_SetError("Video subsystem must be initialized to get clipboard text");
return SDL_strdup("");
}
if (_this->GetClipboardText) {
return _this->GetClipboardText(_this);
} else {
const char *text = _this->clipboard_text;
if (!text) {
text = "";
}
return SDL_strdup(text);
}
}
SDL_bool SDL_HasClipboardText ( void  )

Returns a flag indicating whether the clipboard exists and contains a text string that is non-empty.

See Also
SDL_GetClipboardText()

Definition at line 70 of file SDL_clipboard.c.

References _this, SDL_VideoDevice::clipboard_text, SDL_VideoDevice::HasClipboardText, SDL_FALSE, SDL_GetVideoDevice(), SDL_SetError, and SDL_TRUE.

{
if (!_this) {
SDL_SetError("Video subsystem must be initialized to check clipboard text");
return SDL_FALSE;
}
if (_this->HasClipboardText) {
return _this->HasClipboardText(_this);
} else {
if (_this->clipboard_text && _this->clipboard_text[0] != '\0') {
return SDL_TRUE;
} else {
return SDL_FALSE;
}
}
}
int SDL_SetClipboardText ( const char *  text)

Put UTF-8 text into the clipboard.

See Also
SDL_GetClipboardText()

Definition at line 28 of file SDL_clipboard.c.

References _this, SDL_VideoDevice::clipboard_text, SDL_free, SDL_GetVideoDevice(), SDL_SetError, SDL_strdup, and SDL_VideoDevice::SetClipboardText.

{
if (!_this) {
return SDL_SetError("Video subsystem must be initialized to set clipboard text");
}
if (!text) {
text = "";
}
if (_this->SetClipboardText) {
return _this->SetClipboardText(_this, text);
} else {
return 0;
}
}