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