summaryrefslogtreecommitdiff
path: root/platform/gl/gl-input.c
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2015-09-03 11:39:04 +0200
committerTor Andersson <tor.andersson@artifex.com>2015-10-06 11:21:23 +0200
commit32d57390d9de2f9d9bdf55823038fea7fde4bc3f (patch)
tree1cb0dad27696fbf1e781147dd7e2faa1407c7b22 /platform/gl/gl-input.c
parentcaa075f47cadd4182d9005edea1019e9419908de (diff)
downloadmupdf-32d57390d9de2f9d9bdf55823038fea7fde4bc3f.tar.xz
gl: Use upper control characters for special keys.
Diffstat (limited to 'platform/gl/gl-input.c')
-rw-r--r--platform/gl/gl-input.c53
1 files changed, 24 insertions, 29 deletions
diff --git a/platform/gl/gl-input.c b/platform/gl/gl-input.c
index d0fbcc8f..870db9c7 100644
--- a/platform/gl/gl-input.c
+++ b/platform/gl/gl-input.c
@@ -1,7 +1,5 @@
#include "gl-app.h"
-#define CONTROL(c) (c - 64)
-
static void draw_string_part(float x, float y, const int *s, const int *e)
{
ui_begin_text(ctx);
@@ -66,9 +64,9 @@ static void ui_input_delete_selection(struct input *input)
static int ui_input_key(struct input *input)
{
- switch (ui.special)
+ switch (ui.key)
{
- case GLFW_KEY_LEFT:
+ case KEY_LEFT:
if (ui.mod == GLFW_MOD_CONTROL + GLFW_MOD_SHIFT)
{
input->q = skip_word_left(input->q, input->text);
@@ -93,7 +91,7 @@ static int ui_input_key(struct input *input)
input->p = input->q = --(input->q);
}
break;
- case GLFW_KEY_RIGHT:
+ case KEY_RIGHT:
if (ui.mod == GLFW_MOD_CONTROL + GLFW_MOD_SHIFT)
{
input->q = skip_word_right(input->q, input->end);
@@ -118,8 +116,8 @@ static int ui_input_key(struct input *input)
input->p = input->q = ++(input->q);
}
break;
- case GLFW_KEY_UP:
- case GLFW_KEY_HOME:
+ case KEY_UP:
+ case KEY_HOME:
if (ui.mod == GLFW_MOD_CONTROL + GLFW_MOD_SHIFT)
{
input->q = input->text;
@@ -137,8 +135,8 @@ static int ui_input_key(struct input *input)
input->p = input->q = input->text;
}
break;
- case GLFW_KEY_DOWN:
- case GLFW_KEY_END:
+ case KEY_DOWN:
+ case KEY_END:
if (ui.mod == GLFW_MOD_CONTROL + GLFW_MOD_SHIFT)
{
input->q = input->end;
@@ -156,7 +154,7 @@ static int ui_input_key(struct input *input)
input->p = input->q = input->end;
}
break;
- case GLFW_KEY_DELETE:
+ case KEY_DELETE:
if (input->p != input->q)
ui_input_delete_selection(input);
else if (input->p < input->end)
@@ -166,20 +164,27 @@ static int ui_input_key(struct input *input)
--(input->end);
}
break;
- }
- switch (ui.key)
- {
- case '\e':
+ case KEY_ESCAPE:
return -1;
- case '\r':
+ case KEY_ENTER:
return 1;
- case CONTROL('A'):
+ case KEY_BACKSPACE:
+ if (input->p != input->q)
+ ui_input_delete_selection(input);
+ else if (input->p > input->text && input->end > input->text)
+ {
+ memmove(input->p - 1, input->p, (input->end - input->p) * sizeof (*input->p));
+ input->q = --(input->p);
+ --(input->end);
+ }
+ break;
+ case KEY_CTL_A:
input->p = input->q = input->text;
break;
- case CONTROL('E'):
+ case KEY_CTL_E:
input->p = input->q = input->end;
break;
- case CONTROL('W'):
+ case KEY_CTL_W:
if (input->p != input->q)
ui_input_delete_selection(input);
else
@@ -188,19 +193,9 @@ static int ui_input_key(struct input *input)
ui_input_delete_selection(input);
}
break;
- case CONTROL('U'):
+ case KEY_CTL_U:
input->p = input->q = input->end = input->text;
break;
- case '\b':
- if (input->p != input->q)
- ui_input_delete_selection(input);
- else if (input->p > input->text && input->end > input->text)
- {
- memmove(input->p - 1, input->p, (input->end - input->p) * sizeof (*input->p));
- input->q = --(input->p);
- --(input->end);
- }
- break;
default:
if (ui.key >= 32)
{