aboutsummaryrefslogtreecommitdiff
path: root/midend.c
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2008-09-13 18:26:53 +0000
committerSimon Tatham <anakin@pobox.com>2008-09-13 18:26:53 +0000
commit5ead207060a3e1f74ad6200fdf02934457394bc2 (patch)
tree453b3ebe7556d1a1222c0a1e23f190d6eb119893 /midend.c
parentfe1b91ac49cc2f4cd07801535dc19103a8ebeb70 (diff)
downloadpuzzles-5ead207060a3e1f74ad6200fdf02934457394bc2.zip
puzzles-5ead207060a3e1f74ad6200fdf02934457394bc2.tar.gz
puzzles-5ead207060a3e1f74ad6200fdf02934457394bc2.tar.bz2
puzzles-5ead207060a3e1f74ad6200fdf02934457394bc2.tar.xz
Patch from James H to centralise some generally useful cursor-
handling functionality into misc.c. [originally from svn r8176]
Diffstat (limited to 'midend.c')
-rw-r--r--midend.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/midend.c b/midend.c
index 215482d..a316bcd 100644
--- a/midend.c
+++ b/midend.c
@@ -683,6 +683,14 @@ int midend_process_key(midend *me, int x, int y, int button)
* like a left click for the benefit of users of other
* implementations. So the last of the above points is modified
* in the presence of an (optional) button priority order.
+ *
+ * A further addition: we translate certain keyboard presses to
+ * cursor key 'select' buttons, so that a) frontends don't have
+ * to translate these themselves (like they do for CURSOR_UP etc),
+ * and b) individual games don't have to hard-code button presses
+ * of '\n' etc for keyboard-based cursors. The choice of buttons
+ * here could eventually be controlled by a runtime configuration
+ * option.
*/
if (IS_MOUSE_DRAG(button) || IS_MOUSE_RELEASE(button)) {
if (me->pressed_mouse_button) {
@@ -713,6 +721,14 @@ int midend_process_key(midend *me, int x, int y, int button)
}
/*
+ * Translate keyboard presses to cursor selection.
+ */
+ if (button == '\n' || button == '\r')
+ button = CURSOR_SELECT;
+ if (button == ' ')
+ button = CURSOR_SELECT2;
+
+ /*
* Now send on the event we originally received.
*/
ret = ret && midend_really_process_key(me, x, y, button);