diff options
author | joerg <joerg@FreeBSD.org> | 1997-04-12 17:35:02 +0000 |
---|---|---|
committer | joerg <joerg@FreeBSD.org> | 1997-04-12 17:35:02 +0000 |
commit | 66e9a34c96338c92ab132bee483fcae440990c8b (patch) | |
tree | e96040acafc08be0ec07eaaf9166567efabaf26f /sys/ddb | |
parent | 6ba61d9bc200d748ab83678734bcb16d236ca1ac (diff) | |
download | FreeBSD-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')
-rw-r--r-- | sys/ddb/db_input.c | 39 |
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) { |