diff options
author | David Robillard <d@drobilla.net> | 2019-08-17 20:50:20 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2019-09-07 09:51:48 +0200 |
commit | 7162fa4f5656ad7dfe2d6fea02f9f33c5aa1b1cf (patch) | |
tree | 0f885354b2d75875003401379d5aaf9aadda226f /pugl/detail/implementation.c | |
parent | 27e43183d89aad98f6000ee187b05547776ae4c2 (diff) | |
download | pugl-7162fa4f5656ad7dfe2d6fea02f9f33c5aa1b1cf.tar.gz pugl-7162fa4f5656ad7dfe2d6fea02f9f33c5aa1b1cf.tar.bz2 pugl-7162fa4f5656ad7dfe2d6fea02f9f33c5aa1b1cf.zip |
Add clipboard support
Diffstat (limited to 'pugl/detail/implementation.c')
-rw-r--r-- | pugl/detail/implementation.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/pugl/detail/implementation.c b/pugl/detail/implementation.c index 6ff71e2..f1fd57a 100644 --- a/pugl/detail/implementation.c +++ b/pugl/detail/implementation.c @@ -34,6 +34,20 @@ puglSetString(char** dest, const char* string) strncpy(*dest, string, len + 1); } +void +puglSetBlob(PuglBlob* const dest, const void* const data, const size_t len) +{ + if (data) { + dest->len = len; + dest->data = realloc(dest->data, len + 1); + memcpy(dest->data, data, len); + ((char*)dest->data)[len] = 0; + } else { + dest->len = 0; + dest->data = NULL; + } +} + static void puglSetDefaultHints(PuglHints hints) { @@ -126,6 +140,7 @@ puglFreeView(PuglView* view) } } + free(view->clipboard.data); puglFreeViewInternals(view); free(view); } @@ -267,3 +282,34 @@ puglDispatchEvent(PuglView* view, const PuglEvent* event) view->eventFunc(view, event); } } + +const void* +puglGetInternalClipboard(const PuglView* const view, + const char** const type, + size_t* const len) +{ + if (len) { + *len = view->clipboard.len; + } + + if (type) { + *type = "text/plain"; + } + + return view->clipboard.data; +} + +PuglStatus +puglSetInternalClipboard(PuglView* const view, + const char* const type, + const void* const data, + const size_t len) +{ + if (type && strcmp(type, "text/plain")) { + return PUGL_ERR_UNSUPPORTED_TYPE; + } + + puglSetBlob(&view->clipboard, data, len); + return PUGL_SUCCESS; +} + |