aboutsummaryrefslogtreecommitdiff
path: root/nk_pugl
diff options
context:
space:
mode:
authorHanspeter Portner <dev@open-music-kontrollers.ch>2017-03-07 19:53:28 +0100
committerHanspeter Portner <dev@open-music-kontrollers.ch>2017-03-07 19:53:28 +0100
commit12bcc8c7bbf100473dc7a840b2b9da6b2eda21b3 (patch)
treed48a8ca5bb4a5107a5b7cb8f52f9aef05dfe5245 /nk_pugl
parentecfd53ac67abdb74639681bd13bbd8e67df5a71d (diff)
parent5656cbf0412412b5e52ec438401a62d00e192390 (diff)
downloadsynthpod-12bcc8c7bbf100473dc7a840b2b9da6b2eda21b3.tar.xz
Merge commit '5656cbf0412412b5e52ec438401a62d00e192390' into nk
Diffstat (limited to 'nk_pugl')
-rw-r--r--nk_pugl/nk_pugl.h36
1 files changed, 29 insertions, 7 deletions
diff --git a/nk_pugl/nk_pugl.h b/nk_pugl/nk_pugl.h
index b1f5de60..9d78c447 100644
--- a/nk_pugl/nk_pugl.h
+++ b/nk_pugl/nk_pugl.h
@@ -153,6 +153,12 @@ nk_pugl_icon_unload(nk_pugl_window_t *win, struct nk_image img);
static bool
nk_pugl_is_shortcut_pressed(struct nk_input *in, char letter, bool clear);
+static void
+nk_pugl_copy_to_clipboard(nk_pugl_window_t *win, const char *selection, size_t len);
+
+static const char *
+nk_pugl_paste_from_clipboard(nk_pugl_window_t *win, size_t *len);
+
#ifdef __cplusplus
}
#endif
@@ -574,7 +580,12 @@ static bool
_nk_pugl_other_key_down(nk_pugl_window_t *win, const PuglEventKey *ev)
{
struct nk_context *ctx = &win->ctx;
- const bool control = ev->state & PUGL_MOD_CTRL;
+#if defined(__APPLE__)
+ const bool modifier = ev->state & PUGL_MOD_SUPER;
+#else
+ const bool modifier = ev->state & PUGL_MOD_CTRL;
+#endif
+ const bool shift = ev->state & PUGL_MOD_SHIFT;
// automatically enter insert mode upon non-special key press
_nk_pugl_key_press(ctx, NK_KEY_TEXT_INSERT_MODE);
@@ -613,7 +624,7 @@ _nk_pugl_other_key_down(nk_pugl_window_t *win, const PuglEventKey *ev)
default:
{
- if(control)
+ if(modifier)
{
// unescape ASCII control chars + Control
const uint32_t character = ev->character | 0x60;
@@ -634,11 +645,10 @@ _nk_pugl_other_key_down(nk_pugl_window_t *win, const PuglEventKey *ev)
} break;
case 'z':
{
- _nk_pugl_key_press(ctx, NK_KEY_TEXT_UNDO);
- } break;
- case 'r':
- {
- _nk_pugl_key_press(ctx, NK_KEY_TEXT_REDO);
+ if(shift)
+ _nk_pugl_key_press(ctx, NK_KEY_TEXT_REDO);
+ else
+ _nk_pugl_key_press(ctx, NK_KEY_TEXT_UNDO);
} break;
default:
@@ -1150,6 +1160,18 @@ nk_pugl_is_shortcut_pressed(struct nk_input *in, char letter, bool clear)
return false;
}
+static void
+nk_pugl_copy_to_clipboard(nk_pugl_window_t *win, const char *selection, size_t len)
+{
+ puglCopyToClipboard(win->view, selection, len);
+}
+
+static const char *
+nk_pugl_paste_from_clipboard(nk_pugl_window_t *win, size_t *len)
+{
+ return puglPasteFromClipboard(win->view, len);
+}
+
#ifdef __cplusplus
}
#endif