The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
clipboard.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2016 by David White <[email protected]>
3  Part of the Battle for Wesnoth Project http://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 /** @file */
16 
17 #include "global.hpp"
18 
19 #include "desktop/clipboard.hpp"
21 #include <algorithm>
22 
23 #include <SDL_events.h>
24 #include <SDL_version.h>
25 
26 
27 #include <SDL_clipboard.h>
28 
29 #define CLIPBOARD_FUNCS_DEFINED
30 
31 /*
32  * Note SDL 2.0 has its own clipboard routines, but they don't support
33  * different clipboards (yet).
34  */
35 
36 namespace desktop {
37 
38 namespace clipboard {
39 
40 void copy_to_clipboard(const std::string& text, const bool)
41 {
42  SDL_SetClipboardText(text.c_str());
43 }
44 
46 {
47  char* clipboard = SDL_GetClipboardText();
48  if(!clipboard) {
49  return std::string();
50  }
51 
52  const std::string result(clipboard);
53  SDL_free(clipboard);
54  return result;
55 }
56 
57 void handle_system_event(const SDL_Event& /*event*/)
58 {
59 }
60 
61 bool available()
62 {
63  return true;
64 }
65 
66 } // end namespace clipboard
67 
68 } // end namespace desktop
69 
bool available()
Whether wesnoth was compiled with support for a clipboard.
Definition: clipboard.cpp:61
std::string copy_from_clipboard(const bool)
Copies text from the clipboard.
Definition: clipboard.cpp:45
GLuint64EXT * result
Definition: glew.h:10727
void handle_system_event(const SDL_Event &)
Definition: clipboard.cpp:57
void copy_to_clipboard(const std::string &text, const bool)
Copies text to the clipboard.
Definition: clipboard.cpp:40
GLsizei const GLcharARB ** string
Definition: glew.h:4503