aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2022-09-09 22:59:06 +0200
committerdec05eba <dec05eba@protonmail.com>2022-09-09 23:01:03 +0200
commitbe7e74fe9b51123dec29f9ed9c0441dc8725dd1a (patch)
tree5eb7c73910e2526cc4b009bc677e76d2b66f7ec4 /tests
parente6167bc9300d497b1f2edf3a307164081e24f2bd (diff)
Support png,jpg and gif clipboard. Use callback for clipboard
Diffstat (limited to 'tests')
-rw-r--r--tests/main.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/tests/main.c b/tests/main.c
index df68dd5..7d94461 100644
--- a/tests/main.c
+++ b/tests/main.c
@@ -215,6 +215,11 @@ static void test_utf8() {
require_equals(mgl_utf8_get_start_of_codepoint("abö", 3, 4), 2);
}
+static bool clipboard_callback(const unsigned char *data, size_t size, mgl_clipboard_type clipboard_type, void *userdata) {
+ fprintf(stderr, "clipboard type: %d, size: %zu, data: %s\n", clipboard_type, size, data);
+ return true;
+}
+
int main(int argc, char **argv) {
test_hash_map();
test_utf8();
@@ -287,11 +292,10 @@ int main(int argc, char **argv) {
mgl_window_set_clipboard(&window, str, strlen(str));
fprintf(stderr, "Copied '%s' to the clipboard\n", str);
} else if(event.key.code == MGL_KEY_V) {
- char *str;
- size_t size;
- if(mgl_window_get_clipboard(&window, &str, &size)) {
- fprintf(stderr, "Copied '%s' from the clipboard\n", str);
- free(str);
+ if(mgl_window_get_clipboard(&window, clipboard_callback, NULL)) {
+ fprintf(stderr, "Successfully copied clipboard!\n");
+ } else {
+ fprintf(stderr, "Failed to copy clipboard!\n");
}
}
fprintf(stderr, "key press event, code: %u\n", event.key.code);