diff options
author | David Robillard <d@drobilla.net> | 2021-05-06 17:14:58 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2022-05-22 20:16:26 -0400 |
commit | 7c9d6d5d16fc0c72a27f0118ac753980e518ebcd (patch) | |
tree | dc977252a7d93a4ca5fe840b978568178708e873 /examples/pugl_embed_demo.c | |
parent | fdd6de0d12ea17f713ec3e73e7968198339b7b6d (diff) | |
download | pugl-7c9d6d5d16fc0c72a27f0118ac753980e518ebcd.tar.gz pugl-7c9d6d5d16fc0c72a27f0118ac753980e518ebcd.tar.bz2 pugl-7c9d6d5d16fc0c72a27f0118ac753980e518ebcd.zip |
Factor out pugl_clipboard_demo example program
This is a simpler example than pugl_embed_demo that demonstrates clipboard
functionality without the complexity of embedded views.
Diffstat (limited to 'examples/pugl_embed_demo.c')
-rw-r--r-- | examples/pugl_embed_demo.c | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/examples/pugl_embed_demo.c b/examples/pugl_embed_demo.c index af48a15..f7e4676 100644 --- a/examples/pugl_embed_demo.c +++ b/examples/pugl_embed_demo.c @@ -1,4 +1,4 @@ -// Copyright 2012-2020 David Robillard <d@drobilla.net> +// Copyright 2012-2022 David Robillard <d@drobilla.net> // SPDX-License-Identifier: ISC #include "cube_view.h" @@ -11,8 +11,6 @@ #include <math.h> #include <stdbool.h> #include <stdint.h> -#include <stdio.h> -#include <string.h> static const uint8_t borderWidth = 64u; static const uintptr_t reverseTimerId = 1u; @@ -100,7 +98,7 @@ swapFocus(PuglTestApp* app) } static void -onKeyPress(PuglView* view, const PuglKeyEvent* event, const char* prefix) +onKeyPress(PuglView* view, const PuglKeyEvent* event) { PuglTestApp* app = (PuglTestApp*)puglGetHandle(view); PuglRect frame = puglGetFrame(view); @@ -109,14 +107,6 @@ onKeyPress(PuglView* view, const PuglKeyEvent* event, const char* prefix) swapFocus(app); } else if (event->key == 'q' || event->key == PUGL_KEY_ESCAPE) { app->quit = 1; - } else if (event->state & PUGL_MOD_CTRL && event->key == 'c') { - puglSetClipboard(view, NULL, "Pugl test", strlen("Pugl test") + 1); - fprintf(stderr, "%sCopy \"Pugl test\"\n", prefix); - } else if (event->state & PUGL_MOD_CTRL && event->key == 'v') { - const char* type = NULL; - size_t len = 0; - const char* text = (const char*)puglGetClipboard(view, &type, &len); - fprintf(stderr, "%sPaste \"%s\"\n", prefix, text); } else if (event->state & PUGL_MOD_SHIFT) { if (event->key == PUGL_KEY_UP) { puglSetSize(view, frame.width, frame.height - 10u); @@ -178,7 +168,7 @@ onParentEvent(PuglView* view, const PuglEvent* event) } break; case PUGL_KEY_PRESS: - onKeyPress(view, &event->key, "Parent: "); + onKeyPress(view, &event->key); break; case PUGL_MOTION: break; @@ -215,7 +205,7 @@ onEvent(PuglView* view, const PuglEvent* event) app->quit = 1; break; case PUGL_KEY_PRESS: - onKeyPress(view, &event->key, "Child: "); + onKeyPress(view, &event->key); break; case PUGL_MOTION: app->xAngle -= event->motion.x - app->lastMouseX; |