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. More...
char * | SDL_GetClipboardText (void)
| Get UTF-8 text from the clipboard, which must be freed with SDL_free() More...
SDL_bool | SDL_HasClipboardText (void)
| Returns a flag indicating whether the clipboard exists and contains a text string that is non-empty. More...

## Function Documentation

## SDL_GetClipboardText()

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.

{
SDL_VideoDevice *_this = SDL_GetVideoDevice();
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);
}
}

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

## SDL_HasClipboardText()

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.

{
SDL_VideoDevice *_this = SDL_GetVideoDevice();
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;
}
}
}

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

## SDL_SetClipboardText()

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.

{
SDL_VideoDevice *_this = SDL_GetVideoDevice();
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 {
SDL_free(_this->clipboard_text);
_this->clipboard_text = SDL_strdup(text);
return 0;
}
}

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

SDL_VideoDevice::clipboard_text
char * clipboard_text
Definition: SDL_sysvideo.h:321
SDL_VideoDevice::SetClipboardText
int(* SetClipboardText)(_THIS, const char *text)
Definition: SDL_sysvideo.h:298
SDL_FALSE
@ SDL_FALSE
Definition: SDL_stdinc.h:163
_this
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
SDL_free
#define SDL_free
Definition: SDL_dynapi_overrides.h:377
text
static char text[MAX_TEXT_LENGTH]
Definition: testime.c:47
SDL_VideoDevice
Definition: SDL_sysvideo.h:148
SDL_VideoDevice::GetClipboardText
char *(* GetClipboardText)(_THIS)
Definition: SDL_sysvideo.h:299
SDL_TRUE
@ SDL_TRUE
Definition: SDL_stdinc.h:164
SDL_SetError
#define SDL_SetError
Definition: SDL_dynapi_overrides.h:30
SDL_strdup
#define SDL_strdup
Definition: SDL_dynapi_overrides.h:397
SDL_VideoDevice::HasClipboardText
SDL_bool(* HasClipboardText)(_THIS)
Definition: SDL_sysvideo.h:300
SDL_GetVideoDevice
SDL_VideoDevice * SDL_GetVideoDevice(void)
Definition: SDL_video.c:583