src/video/SDL_clipboard.c
author Sam Lantinga <slouken@libsdl.org>
Fri, 11 Feb 2011 22:37:15 -0800
changeset 5262 b530ef003506
parent 4506 b577f47379f3
child 5535 96594ac5fd1a
permissions -rw-r--r--
Happy 2011! :)
     1 /*
     2     SDL - Simple DirectMedia Layer
     3     Copyright (C) 1997-2011 Sam Lantinga
     4 
     5     This library is free software; you can redistribute it and/or
     6     modify it under the terms of the GNU Lesser General Public
     7     License as published by the Free Software Foundation; either
     8     version 2.1 of the License, or (at your option) any later version.
     9 
    10     This library is distributed in the hope that it will be useful,
    11     but WITHOUT ANY WARRANTY; without even the implied warranty of
    12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    13     Lesser General Public License for more details.
    14 
    15     You should have received a copy of the GNU Lesser General Public
    16     License along with this library; if not, write to the Free Software
    17     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    18 
    19     Sam Lantinga
    20     slouken@libsdl.org
    21 */
    22 #include "SDL_config.h"
    23 
    24 #include "SDL_clipboard.h"
    25 #include "SDL_sysvideo.h"
    26 
    27 
    28 int
    29 SDL_SetClipboardText(const char *text)
    30 {
    31     SDL_VideoDevice *_this = SDL_GetVideoDevice();
    32 
    33     if (!text) {
    34         text = "";
    35     }
    36     if (_this->SetClipboardText) {
    37         return _this->SetClipboardText(_this, text);
    38     } else {
    39         _this->clipboard_text = SDL_strdup(text);
    40         return 0;
    41     }
    42 }
    43 
    44 char *
    45 SDL_GetClipboardText(void)
    46 {
    47     SDL_VideoDevice *_this = SDL_GetVideoDevice();
    48 
    49     if (_this->GetClipboardText) {
    50         return _this->GetClipboardText(_this);
    51     } else {
    52         const char *text = _this->clipboard_text;
    53         if (!text) {
    54             text = "";
    55         }
    56         return SDL_strdup(text);
    57     }
    58 }
    59 
    60 SDL_bool
    61 SDL_HasClipboardText(void)
    62 {
    63     SDL_VideoDevice *_this = SDL_GetVideoDevice();
    64 
    65     if (_this->HasClipboardText) {
    66         return _this->HasClipboardText(_this);
    67     } else {
    68         if (_this->clipboard_text) {
    69             return SDL_TRUE;
    70         } else {
    71             return SDL_FALSE;
    72         }
    73     }
    74 }
    75 
    76 /* vi: set ts=4 sw=4 expandtab: */