From d07f80c0516e98f0b4d0b2527fe11590cb007409 Mon Sep 17 00:00:00 2001
From: Přemysl Janouch
Date: Thu, 16 May 2013 20:46:33 +0200
Subject: Support Ctrl-A/E shortcuts
---
src/sdtui.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
(limited to 'src/sdtui.c')
diff --git a/src/sdtui.c b/src/sdtui.c
index 88dad87..01a2973 100644
--- a/src/sdtui.c
+++ b/src/sdtui.c
@@ -40,10 +40,12 @@
#include "stardict.h"
-#define KEY_ESCAPE 27 /**< Curses doesn't define this. */
+#define KEY_SOH 1 /**< Ctrl-A */
+#define KEY_ENQ 5 /**< Ctrl-E */
#define KEY_VT 11 /**< Ctrl-K */
#define KEY_NAK 21 /**< Ctrl-U */
#define KEY_ETB 23 /**< Ctrl-W */
+#define KEY_ESCAPE 27 /**< Curses doesn't define this. */
#define _(x) x /**< Fake gettext, for now. */
@@ -577,6 +579,14 @@ app_process_curses_event (Application *self, CursesEvent *event)
{
case KEY_ESCAPE:
return FALSE;
+ case KEY_SOH: // Ctrl-A -- move to the start of line
+ self->input_pos = 0;
+ app_redraw_top (self);
+ break;
+ case KEY_ENQ: // Ctrl-E -- move to the end of line
+ self->input_pos = self->input->len;
+ app_redraw_top (self);
+ break;
case KEY_VT: // Ctrl-K -- delete until the end of line
if (self->input_pos < self->input->len)
{
--
cgit v1.2.3-70-g09d2