src/video/SDL_clipboard.c
author Sam Lantinga <slouken@libsdl.org>
Fri, 08 Apr 2011 13:03:26 -0700
changeset 5535 96594ac5fd1a
parent 5262 b530ef003506
child 6036 f2a89f2a6157
permissions -rw-r--r--
SDL 1.3 is now under the zlib license.
slouken@4493
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@5535
     3
  Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
slouken@4493
     4
slouken@5535
     5
  This software is provided 'as-is', without any express or implied
slouken@5535
     6
  warranty.  In no event will the authors be held liable for any damages
slouken@5535
     7
  arising from the use of this software.
slouken@4493
     8
slouken@5535
     9
  Permission is granted to anyone to use this software for any purpose,
slouken@5535
    10
  including commercial applications, and to alter it and redistribute it
slouken@5535
    11
  freely, subject to the following restrictions:
slouken@4493
    12
slouken@5535
    13
  1. The origin of this software must not be misrepresented; you must not
slouken@5535
    14
     claim that you wrote the original software. If you use this software
slouken@5535
    15
     in a product, an acknowledgment in the product documentation would be
slouken@5535
    16
     appreciated but is not required.
slouken@5535
    17
  2. Altered source versions must be plainly marked as such, and must not be
slouken@5535
    18
     misrepresented as being the original software.
slouken@5535
    19
  3. This notice may not be removed or altered from any source distribution.
slouken@4493
    20
*/
slouken@4493
    21
#include "SDL_config.h"
slouken@4493
    22
slouken@4493
    23
#include "SDL_clipboard.h"
slouken@4493
    24
#include "SDL_sysvideo.h"
slouken@4493
    25
slouken@4493
    26
slouken@4493
    27
int
slouken@4493
    28
SDL_SetClipboardText(const char *text)
slouken@4493
    29
{
slouken@4495
    30
    SDL_VideoDevice *_this = SDL_GetVideoDevice();
slouken@4495
    31
slouken@4500
    32
    if (!text) {
slouken@4500
    33
        text = "";
slouken@4500
    34
    }
slouken@4495
    35
    if (_this->SetClipboardText) {
slouken@4495
    36
        return _this->SetClipboardText(_this, text);
slouken@4495
    37
    } else {
slouken@4495
    38
        _this->clipboard_text = SDL_strdup(text);
slouken@4495
    39
        return 0;
slouken@4495
    40
    }
slouken@4493
    41
}
slouken@4493
    42
slouken@4493
    43
char *
slouken@4506
    44
SDL_GetClipboardText(void)
slouken@4493
    45
{
slouken@4495
    46
    SDL_VideoDevice *_this = SDL_GetVideoDevice();
slouken@4493
    47
slouken@4495
    48
    if (_this->GetClipboardText) {
slouken@4495
    49
        return _this->GetClipboardText(_this);
slouken@4493
    50
    } else {
slouken@4495
    51
        const char *text = _this->clipboard_text;
slouken@4495
    52
        if (!text) {
slouken@4495
    53
            text = "";
slouken@4495
    54
        }
slouken@4495
    55
        return SDL_strdup(text);
slouken@4493
    56
    }
slouken@4493
    57
}
slouken@4493
    58
slouken@4493
    59
SDL_bool
slouken@4506
    60
SDL_HasClipboardText(void)
slouken@4493
    61
{
slouken@4495
    62
    SDL_VideoDevice *_this = SDL_GetVideoDevice();
slouken@4493
    63
slouken@4495
    64
    if (_this->HasClipboardText) {
slouken@4495
    65
        return _this->HasClipboardText(_this);
slouken@4495
    66
    } else {
slouken@4495
    67
        if (_this->clipboard_text) {
slouken@4495
    68
            return SDL_TRUE;
slouken@4495
    69
        } else {
slouken@4495
    70
            return SDL_FALSE;
slouken@4495
    71
        }
slouken@4495
    72
    }
slouken@4493
    73
}
slouken@4493
    74
slouken@4493
    75
/* vi: set ts=4 sw=4 expandtab: */