Module: SDL2::Clipboard
- Defined in:
- ext/sdl2_ext/clipboard.c,
ext/sdl2_ext/clipboard.c
Overview
This module has clipboard manipulating functions.
Class Method Summary collapse
-
.has_text? ⇒ Boolean
Return true if the clipboard has any text.
-
.text ⇒ String?
Get the text from the clipboard.
-
.text=(text) ⇒ String
Set the text in the clipboard.
Class Method Details
.has_text? ⇒ Boolean
Return true if the clipboard has any text.
49 50 51 52 |
# File 'ext/sdl2_ext/clipboard.c', line 49
static VALUE Clipboard_s_has_text_p(VALUE self)
{
return INT2BOOL(SDL_HasClipboardText());
}
|
.text ⇒ String?
Get the text from the clipboard.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'ext/sdl2_ext/clipboard.c', line 17
static VALUE Clipboard_s_text(VALUE self)
{
if (SDL_HasClipboardText()) {
char* text = SDL_GetClipboardText();
VALUE str;
if (!text)
SDL_ERROR();
str = utf8str_new_cstr(text);
SDL_free(text);
return str;
} else {
return Qnil;
}
}
|
.text=(text) ⇒ String
39 40 41 42 43 |
# File 'ext/sdl2_ext/clipboard.c', line 39
static VALUE Clipboard_s_set_text(VALUE self, VALUE text)
{
HANDLE_ERROR(SDL_SetClipboardText(StringValueCStr(text)));
return text;
}
|