src/video/SDL_clipboard.c
changeset 9349 7674af9a59c8
parent 8149 681eb46b8ac4
child 9619 b94b6d0bff0f
equal deleted inserted replaced
9348:7bda52b051f9 9349:7674af9a59c8
    27 int
    27 int
    28 SDL_SetClipboardText(const char *text)
    28 SDL_SetClipboardText(const char *text)
    29 {
    29 {
    30     SDL_VideoDevice *_this = SDL_GetVideoDevice();
    30     SDL_VideoDevice *_this = SDL_GetVideoDevice();
    31 
    31 
       
    32     if (!_this) {
       
    33         return SDL_SetError("Video subsystem must be initialized to set clipboard text");
       
    34     }
       
    35 
    32     if (!text) {
    36     if (!text) {
    33         text = "";
    37         text = "";
    34     }
    38     }
    35     if (_this->SetClipboardText) {
    39     if (_this->SetClipboardText) {
    36         return _this->SetClipboardText(_this, text);
    40         return _this->SetClipboardText(_this, text);
    44 char *
    48 char *
    45 SDL_GetClipboardText(void)
    49 SDL_GetClipboardText(void)
    46 {
    50 {
    47     SDL_VideoDevice *_this = SDL_GetVideoDevice();
    51     SDL_VideoDevice *_this = SDL_GetVideoDevice();
    48 
    52 
       
    53     if (!_this) {
       
    54         SDL_SetError("Video subsystem must be initialized to get clipboard text");
       
    55         return SDL_strdup("");
       
    56     }
       
    57 
    49     if (_this->GetClipboardText) {
    58     if (_this->GetClipboardText) {
    50         return _this->GetClipboardText(_this);
    59         return _this->GetClipboardText(_this);
    51     } else {
    60     } else {
    52         const char *text = _this->clipboard_text;
    61         const char *text = _this->clipboard_text;
    53         if (!text) {
    62         if (!text) {
    60 SDL_bool
    69 SDL_bool
    61 SDL_HasClipboardText(void)
    70 SDL_HasClipboardText(void)
    62 {
    71 {
    63     SDL_VideoDevice *_this = SDL_GetVideoDevice();
    72     SDL_VideoDevice *_this = SDL_GetVideoDevice();
    64 
    73 
       
    74     if (!_this) {
       
    75         SDL_SetError("Video subsystem must be initialized to check clipboard text");
       
    76         return SDL_FALSE;
       
    77     }
       
    78 
    65     if (_this->HasClipboardText) {
    79     if (_this->HasClipboardText) {
    66         return _this->HasClipboardText(_this);
    80         return _this->HasClipboardText(_this);
    67     } else {
    81     } else {
    68         if (_this->clipboard_text && _this->clipboard_text[0] != '\0') {
    82         if (_this->clipboard_text && _this->clipboard_text[0] != '\0') {
    69             return SDL_TRUE;
    83             return SDL_TRUE;