comparison src/video/SDL_clipboard.c @ 4661:03dcb795c583

Merged changes from the main SDL codebase
author Sam Lantinga <slouken@libsdl.org>
date Mon, 12 Jul 2010 21:09:23 -0700
parents b577f47379f3
children b530ef003506
comparison
equal deleted inserted replaced
4660:b15e7017409b 4661:03dcb795c583
1 /*
2 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997-2010 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: */