From: David Lawrence Ramsey Date: Fri, 28 Apr 2006 18:26:07 +0000 (+0000) Subject: various fixes for get_control_kbinput() X-Git-Tag: v1.3.12~230 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=4d9ef69f8e2794936d4c39fd7a1aad3856b5233f;p=nano.git various fixes for get_control_kbinput() git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3450 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- diff --git a/ChangeLog b/ChangeLog index f9799a41..b446d1d2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -167,6 +167,11 @@ CVS code - (DLR) - Change all rcfile error messages to refer to commands instead of directives, for consistency with nanorc.5. (DLR) +- winio.c: + get_control_kbinput() + - Add Ctrl-/ as an alias for Ctrl-_. (DLR, found by Benno + Schulenberg) + - Simplify the if blocks wherever possible. (DLR) - configure.ac: - Remove old warnings about color support. (DLR) - doc/nano.1, doc/nanorc.5, doc/rnano.1, doc/nano.texi: diff --git a/src/winio.c b/src/winio.c index e4e85db2..fe1b63f5 100644 --- a/src/winio.c +++ b/src/winio.c @@ -1406,21 +1406,26 @@ int get_control_kbinput(int kbinput) { int retval; - /* Ctrl-2 (Ctrl-Space, Ctrl-@, Ctrl-`) */ - if (kbinput == '2' || kbinput == ' ' || kbinput == '@' || - kbinput == '`') - retval = NANO_CONTROL_SPACE; - /* Ctrl-3 (Ctrl-[, Esc) to Ctrl-7 (Ctrl-_) */ + /* Ctrl-Space (Ctrl-2, Ctrl-@, Ctrl-`) */ + if (kbinput == ' ') + retval = kbinput - 32; + /* Ctrl-/ (Ctrl-7, Ctrl-_) */ + else if (kbinput == '/') + retval = kbinput - 16; + /* Ctrl-2 (Ctrl-Space, Ctrl-@, Ctrl-`) */ + else if (kbinput == '2') + retval = kbinput - 50; + /* Ctrl-3 (Ctrl-[, Esc) to Ctrl-7 (Ctrl-/, Ctrl-_) */ else if ('3' <= kbinput && kbinput <= '7') retval = kbinput - 24; /* Ctrl-8 (Ctrl-?) */ - else if (kbinput == '8' || kbinput == '?') - retval = NANO_CONTROL_8; - /* Ctrl-A to Ctrl-_ */ - else if ('A' <= kbinput && kbinput <= '_') + else if (kbinput == '8') + retval = kbinput + 71; + /* Ctrl-? (Ctrl-8) to Ctrl-_ (Ctrl-/, Ctrl-7) */ + else if ('?' <= kbinput && kbinput <= '_') retval = kbinput - 64; - /* Ctrl-a to Ctrl-~ */ - else if ('a' <= kbinput && kbinput <= '~') + /* Ctrl-` (Ctrl-2, Ctrl-Space, Ctrl-@) to Ctrl-~ (Ctrl-6, Ctrl-^) */ + else if ('`' <= kbinput && kbinput <= '~') retval = kbinput - 96; else retval = kbinput;