src/video/SDL_clipboard.c
author Sam Lantinga <slouken@libsdl.org>
Sat, 02 Mar 2013 20:44:16 -0800
changeset 6950 1ddb72193079
parent 6885 700f1b25f77f
child 7719 31b5f9ff36ca
permissions -rw-r--r--
Added a mouse ID to the mouse events, which set to the special value SDL_TOUCH_MOUSEID for mouse events simulated by touch input.
slouken@4493
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@6885
     3
  Copyright (C) 1997-2013 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 {
aschiffler@6036
    38
        if (_this->clipboard_text) {
aschiffler@6036
    39
            SDL_free(_this->clipboard_text);
aschiffler@6036
    40
        }
slouken@4495
    41
        _this->clipboard_text = SDL_strdup(text);
slouken@4495
    42
        return 0;
slouken@4495
    43
    }
slouken@4493
    44
}
slouken@4493
    45
slouken@4493
    46
char *
slouken@4506
    47
SDL_GetClipboardText(void)
slouken@4493
    48
{
slouken@4495
    49
    SDL_VideoDevice *_this = SDL_GetVideoDevice();
slouken@4493
    50
slouken@4495
    51
    if (_this->GetClipboardText) {
slouken@4495
    52
        return _this->GetClipboardText(_this);
slouken@4493
    53
    } else {
slouken@4495
    54
        const char *text = _this->clipboard_text;
slouken@4495
    55
        if (!text) {
slouken@4495
    56
            text = "";
slouken@4495
    57
        }
slouken@4495
    58
        return SDL_strdup(text);
slouken@4493
    59
    }
slouken@4493
    60
}
slouken@4493
    61
slouken@4493
    62
SDL_bool
slouken@4506
    63
SDL_HasClipboardText(void)
slouken@4493
    64
{
slouken@4495
    65
    SDL_VideoDevice *_this = SDL_GetVideoDevice();
slouken@4493
    66
slouken@4495
    67
    if (_this->HasClipboardText) {
slouken@4495
    68
        return _this->HasClipboardText(_this);
slouken@4495
    69
    } else {
aschiffler@6036
    70
        if ((_this->clipboard_text) && (SDL_strlen(_this->clipboard_text)>0)) {
slouken@4495
    71
            return SDL_TRUE;
slouken@4495
    72
        } else {
slouken@4495
    73
            return SDL_FALSE;
slouken@4495
    74
        }
slouken@4495
    75
    }
slouken@4493
    76
}
slouken@4493
    77
slouken@4493
    78
/* vi: set ts=4 sw=4 expandtab: */