summaryrefslogtreecommitdiffstats
path: root/sys/ddb/db_input.c
diff options
context:
space:
mode:
authorjoerg <joerg@FreeBSD.org>1997-04-12 17:35:02 +0000
committerjoerg <joerg@FreeBSD.org>1997-04-12 17:35:02 +0000
commit66e9a34c96338c92ab132bee483fcae440990c8b (patch)
treee96040acafc08be0ec07eaaf9166567efabaf26f /sys/ddb/db_input.c
parent6ba61d9bc200d748ab83678734bcb16d236ca1ac (diff)
downloadFreeBSD-src-66e9a34c96338c92ab132bee483fcae440990c8b.zip
FreeBSD-src-66e9a34c96338c92ab132bee483fcae440990c8b.tar.gz
Everyone's favorite, i think: make DDB understand the arrow keys for the
basic cursor movements. Assumes ANSI/DEC tty, but you can still resort to plain emacs ^p/^n etc anyway.
Diffstat (limited to 'sys/ddb/db_input.c')
-rw-r--r--sys/ddb/db_input.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/sys/ddb/db_input.c b/sys/ddb/db_input.c
index 4c42a13..3d67c8c 100644
--- a/sys/ddb/db_input.c
+++ b/sys/ddb/db_input.c
@@ -23,7 +23,7 @@
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*
- * $Id$
+ * $Id: db_input.c,v 1.17 1997/02/22 09:28:23 peter Exp $
*/
/*
@@ -120,7 +120,44 @@ int
db_inputchar(c)
int c;
{
+ static int escstate;
+
+ if (escstate == 1) {
+ /* ESC seen, look for [ or O */
+ if (c == '[' || c == 'O')
+ escstate++;
+ else
+ escstate = 0; /* re-init state machine */
+ return (0);
+ } else if (escstate == 2) {
+ escstate = 0;
+ /*
+ * If a valid cursor key has been found, translate
+ * into an emacs-style control key, and fall through.
+ * Otherwise, drop off.
+ */
+ switch (c) {
+ case 'A': /* up */
+ c = CTRL('p');
+ break;
+ case 'B': /* down */
+ c = CTRL('n');
+ break;
+ case 'C': /* right */
+ c = CTRL('f');
+ break;
+ case 'D': /* left */
+ c = CTRL('b');
+ break;
+ default:
+ return (0);
+ }
+ }
+
switch (c) {
+ case CTRL('['):
+ escstate = 1;
+ break;
case CTRL('b'):
/* back up one character */
if (db_lc > db_lbuf_start) {
OpenPOWER on IntegriCloud