Add initial lime.system.Clipboard implementation
This commit is contained in:
24
project/include/system/Clipboard.h
Normal file
24
project/include/system/Clipboard.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#ifndef LIME_SYSTEM_CLIPBOARD_H
|
||||
#define LIME_SYSTEM_CLIPBOARD_H
|
||||
|
||||
|
||||
namespace lime {
|
||||
|
||||
|
||||
class Clipboard {
|
||||
|
||||
|
||||
public:
|
||||
|
||||
static const char* GetText ();
|
||||
static bool HasText ();
|
||||
static void SetText (const char* text);
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <graphics/ImageBuffer.h>
|
||||
#include <graphics/Renderer.h>
|
||||
#include <graphics/RenderEvent.h>
|
||||
#include <system/Clipboard.h>
|
||||
#include <system/JNI.h>
|
||||
#include <system/System.h>
|
||||
#include <text/Font.h>
|
||||
@@ -160,6 +161,29 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
value lime_clipboard_get_text () {
|
||||
|
||||
if (Clipboard::HasText ()) {
|
||||
|
||||
return alloc_string (Clipboard::GetText ());
|
||||
|
||||
} else {
|
||||
|
||||
return alloc_null ();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
value lime_clipboard_set_text (value text) {
|
||||
|
||||
Clipboard::SetText (val_string (text));
|
||||
return alloc_null ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void lime_font_destroy (value handle) {
|
||||
|
||||
Font *font = (Font*)(intptr_t)val_float (handle);
|
||||
@@ -1178,6 +1202,8 @@ namespace lime {
|
||||
DEFINE_PRIM (lime_bytes_from_data_pointer, 2);
|
||||
DEFINE_PRIM (lime_bytes_get_data_pointer, 1);
|
||||
DEFINE_PRIM (lime_bytes_read_file, 1);
|
||||
DEFINE_PRIM (lime_clipboard_get_text, 0);
|
||||
DEFINE_PRIM (lime_clipboard_set_text, 1);
|
||||
DEFINE_PRIM (lime_font_get_ascender, 1);
|
||||
DEFINE_PRIM (lime_font_get_descender, 1);
|
||||
DEFINE_PRIM (lime_font_get_family_name, 1);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <graphics/PixelFormat.h>
|
||||
#include <math/Rectangle.h>
|
||||
#include <system/Clipboard.h>
|
||||
#include <system/JNI.h>
|
||||
#include <system/System.h>
|
||||
|
||||
@@ -47,6 +48,27 @@ namespace lime {
|
||||
static bool init = false;
|
||||
|
||||
|
||||
const char* Clipboard::GetText () {
|
||||
|
||||
return SDL_GetClipboardText ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool Clipboard::HasText () {
|
||||
|
||||
return SDL_HasClipboardText ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void Clipboard::SetText (const char* text) {
|
||||
|
||||
SDL_SetClipboardText (text);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void *JNI::GetEnv () {
|
||||
|
||||
#ifdef ANDROID
|
||||
|
||||
Reference in New Issue
Block a user