aboutsummaryrefslogtreecommitdiff
path: root/nk_pugl/nk_pugl.h
diff options
context:
space:
mode:
authorHanspeter Portner <dev@open-music-kontrollers.ch>2016-12-05 23:56:33 +0100
committerHanspeter Portner <dev@open-music-kontrollers.ch>2016-12-05 23:56:33 +0100
commitd232f7962466fa5ef5509894055535e14907f164 (patch)
tree234ec2eb84ff1309208b57f55c244808326f3bb6 /nk_pugl/nk_pugl.h
parent79f962be4ba311a77e8817d5a551e1d948a7adb0 (diff)
parent5f2b08f8f8ddd01b7f55bf0784c0ed6a3270f56b (diff)
downloadmidi_matrix.lv2-d232f7962466fa5ef5509894055535e14907f164.tar.xz
Merge commit '5f2b08f8f8ddd01b7f55bf0784c0ed6a3270f56b'
Diffstat (limited to 'nk_pugl/nk_pugl.h')
-rw-r--r--nk_pugl/nk_pugl.h59
1 files changed, 39 insertions, 20 deletions
diff --git a/nk_pugl/nk_pugl.h b/nk_pugl/nk_pugl.h
index abaf0b5..2b81662 100644
--- a/nk_pugl/nk_pugl.h
+++ b/nk_pugl/nk_pugl.h
@@ -19,6 +19,7 @@
#define _NK_PUGL_H
#include <stdatomic.h>
+#include <ctype.h> // isprint
#ifdef __cplusplus
extern C {
@@ -440,13 +441,27 @@ _nk_pugl_special_key(struct nk_context *ctx, const PuglEventKey *ev, int down)
} break;
case PUGL_KEY_HOME:
{
- nk_input_key(ctx, NK_KEY_TEXT_START, down);
- nk_input_key(ctx, NK_KEY_SCROLL_START, down);
+ if(control)
+ {
+ nk_input_key(ctx, NK_KEY_TEXT_START, down);
+ nk_input_key(ctx, NK_KEY_SCROLL_START, down);
+ }
+ else
+ {
+ nk_input_key(ctx, NK_KEY_TEXT_LINE_START, down);
+ }
} break;
case PUGL_KEY_END:
{
- nk_input_key(ctx, NK_KEY_TEXT_END, down);
- nk_input_key(ctx, NK_KEY_SCROLL_END, down);
+ if(control)
+ {
+ nk_input_key(ctx, NK_KEY_TEXT_END, down);
+ nk_input_key(ctx, NK_KEY_SCROLL_END, down);
+ }
+ else
+ {
+ nk_input_key(ctx, NK_KEY_TEXT_LINE_END, down);
+ }
} break;
case PUGL_KEY_SHIFT:
{
@@ -478,7 +493,8 @@ _nk_pugl_other_key(struct nk_context *ctx, const PuglEventKey *ev, int down)
if(control)
{
- switch(ev->character + 96) //FIXME why +96?
+ const uint32_t character = ev->character + 96; //FIXME why +96?
+ switch(character)
{
case 'c':
{
@@ -500,19 +516,11 @@ _nk_pugl_other_key(struct nk_context *ctx, const PuglEventKey *ev, int down)
{
nk_input_key(ctx, NK_KEY_TEXT_REDO, down);
} break;
- case 'b':
- {
- nk_input_key(ctx, NK_KEY_TEXT_LINE_START, down);
- } break;
- case 'e':
- {
- nk_input_key(ctx, NK_KEY_TEXT_LINE_END, down);
- } break;
default:
{
if(down)
- nk_input_char(ctx, ev->character + 96);
+ nk_input_char(ctx, character);
} break;
}
}
@@ -528,21 +536,32 @@ _nk_pugl_other_key(struct nk_context *ctx, const PuglEventKey *ev, int down)
{
nk_input_key(ctx, NK_KEY_TAB, down);
} break;
- case 127: // Delete
+ case PUGL_CHAR_DELETE:
{
nk_input_key(ctx, NK_KEY_DEL, down);
} break;
- case '\b':
+ case PUGL_CHAR_BACKSPACE:
{
nk_input_key(ctx, NK_KEY_BACKSPACE, down);
} break;
+ case PUGL_CHAR_ESCAPE:
+ {
+ nk_input_key(ctx, NK_KEY_TEXT_RESET_MODE, down);
+ } break;
default:
{
- if(ev->character == 'i')
- nk_input_key(ctx, NK_KEY_TEXT_INSERT_MODE, down);
- else if(ev->character == 'r')
- nk_input_key(ctx, NK_KEY_TEXT_REPLACE_MODE, down);
+ switch(ev->character)
+ {
+ case 'i':
+ {
+ nk_input_key(ctx, NK_KEY_TEXT_INSERT_MODE, down);
+ } break;
+ case 'r':
+ {
+ nk_input_key(ctx, NK_KEY_TEXT_REPLACE_MODE, down);
+ } break;
+ }
if(down)
nk_input_glyph(ctx, (const char *)ev->utf8);