-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathclipboard.c.v
111 lines (98 loc) · 3.5 KB
/
clipboard.c.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// Copyright(C) 2021 Lars Pontoppidan. All rights reserved.
// Use of this source code is governed by an MIT license
// that can be found in the LICENSE file.
module sdl
//
// SDL_clipboard.h
//
fn C.SDL_SetClipboardText(text &char) int
// set_clipboard_text puts UTF-8 text into the clipboard.
//
// `text` the text to store in the clipboard
// returns 0 on success or a negative error code on failure; call
// SDL_GetError() for more information.
//
// NOTE This function is available since SDL 2.0.0.
//
// See also: SDL_GetClipboardText
// See also: SDL_HasClipboardText
pub fn set_clipboard_text(text &char) int {
return C.SDL_SetClipboardText(text)
}
fn C.SDL_GetClipboardText() &char
// get_clipboard_text gets UTF-8 text from the clipboard, which must be freed with SDL_free().
//
// This functions returns empty string if there was not enough memory left for
// a copy of the clipboard's content.
//
// returns the clipboard text on success or an empty string on failure; call
// SDL_GetError() for more information. Caller must call SDL_free()
// on the returned pointer when done with it (even if there was an
// error).
//
// NOTE This function is available since SDL 2.0.0.
//
// See also: SDL_HasClipboardText
// See also: SDL_SetClipboardText
pub fn get_clipboard_text() &char {
return C.SDL_GetClipboardText()
}
fn C.SDL_HasClipboardText() bool
// has_clipboard_text queries whether the clipboard exists and contains a non-empty text string.
//
// returns SDL_TRUE if the clipboard has text, or SDL_FALSE if it does not.
//
// NOTE This function is available since SDL 2.0.0.
//
// See also: SDL_GetClipboardText
// See also: SDL_SetClipboardText
pub fn has_clipboard_text() bool {
return C.SDL_HasClipboardText()
}
fn C.SDL_SetPrimarySelectionText(const_text &char) int
// set_primary_selection_text puts UTF-8 text into the primary selection.
//
// `text` the text to store in the primary selection
// returns 0 on success or a negative error code on failure; call
// SDL_GetError() for more information.
//
// NOTE This function is available since SDL 2.26.0.
//
// See also: SDL_GetPrimarySelectionText
// See also: SDL_HasPrimarySelectionText
pub fn set_primary_selection_text(const_text &char) int {
return C.SDL_SetPrimarySelectionText(const_text)
}
fn C.SDL_GetPrimarySelectionText() &char
// get_primary_selection_text gets UTF-8 text from the primary selection, which must be freed with
// SDL_free().
//
// This functions returns empty string if there was not enough memory left for
// a copy of the primary selection's content.
//
// returns the primary selection text on success or an empty string on
// failure; call SDL_GetError() for more information. Caller must
// call SDL_free() on the returned pointer when done with it (even if
// there was an error).
//
// NOTE This function is available since SDL 2.26.0.
//
// See also: SDL_HasPrimarySelectionText
// See also: SDL_SetPrimarySelectionText
pub fn get_primary_selection_text() &char {
return C.SDL_GetPrimarySelectionText()
}
fn C.SDL_HasPrimarySelectionText() bool
// has_primary_selection_text querys whether the primary selection exists and contains a non-empty text
// string.
//
// returns SDL_TRUE if the primary selection has text, or SDL_FALSE if it
// does not.
//
// NOTE This function is available since SDL 2.26.0.
//
// See also: SDL_GetPrimarySelectionText
// See also: SDL_SetPrimarySelectionText
pub fn has_primary_selection_text() bool {
return C.SDL_HasPrimarySelectionText()
}