From 94b1d01bb4e79d2a82cb0e1c0ac2b133bf7c8f29 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Mon, 21 Apr 2014 18:05:11 +0000 Subject: [PATCH] Allowing the codes from Ins and Del keys to be rebound. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4798 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 2 ++ doc/nanorc.sample.in | 8 ++++---- src/global.c | 4 ++-- src/rcfile.c | 6 +++++- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 96d60365..a468480d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -16,6 +16,8 @@ * src/global.c (assign_keyinfo, shortcut_init): Give nicer names to the dedicated keys, for when they show up in the help lines. * src/rcfile.c (parse_binding): K-keys no longer exist. + * src/global.c, src/rcfile.c, doc/nanorc.sample.in: Allow the + codes from the Ins and Del keys to be rebound. 2014-04-16 Benno Schulenberg * src/winio.c (get_mouseinput): Properly find also the zeroeth diff --git a/doc/nanorc.sample.in b/doc/nanorc.sample.in index e6a96ef0..03fa6362 100644 --- a/doc/nanorc.sample.in +++ b/doc/nanorc.sample.in @@ -232,13 +232,13 @@ ## Key bindings -## Please see nanorc(5) for more details on this +## Please see nanorc(5) for more details on this. ## -## Here are some samples to get you going +## Here are some samples to get you going. ## # bind M-W nowrap main # bind M-A casesens search # bind ^S research main -## Set this if your backspace key sends delete most of the time (2.1.3+) -# bind kdel backspace all +## Set this if your backspace key sends Del most of the time. +# bind Del backspace all diff --git a/src/global.c b/src/global.c index 7d0a0ada..2e47d4cb 100644 --- a/src/global.c +++ b/src/global.c @@ -453,7 +453,7 @@ void assign_keyinfo(sc *s) s->seq = KEY_LEFT; else if (!strcasecmp(s->keystr, "Right")) s->seq = KEY_RIGHT; - else if (!strcasecmp(s->keystr, "Insert")) + else if (!strcasecmp(s->keystr, "Ins")) s->seq = KEY_IC; else if (!strcasecmp(s->keystr, "Del")) s->seq = KEY_DC; @@ -1091,7 +1091,7 @@ void shortcut_init(void) #endif add_to_sclist(MMAIN, "^R", do_insertfile_void, 0, TRUE); add_to_sclist(MMAIN, "F5", do_insertfile_void, 0, TRUE); - add_to_sclist(MMAIN, "Insert", do_insertfile_void, 0, TRUE); + add_to_sclist(MMAIN, "Ins", do_insertfile_void, 0, TRUE); add_to_sclist(MMAIN|MBROWSER, "^W", do_search, 0, TRUE); add_to_sclist(MMAIN|MBROWSER, "F6", do_search, 0, TRUE); add_to_sclist(MMAIN|MBROWSER|MHELP|MWHEREISFILE|MLINTER, "^Y", do_page_up, 0, TRUE); diff --git a/src/rcfile.c b/src/rcfile.c index 2b7b0c2d..fccadb63 100644 --- a/src/rcfile.c +++ b/src/rcfile.c @@ -499,7 +499,11 @@ void parse_binding(char *ptr, bool dobind) } } - if (keycopy[0] != '^' && keycopy[0] != 'M' && keycopy[0] != 'F') { + /* Allow the codes for Insert and Delete to be rebound, but apart + * from those two only Control, Meta and Function sequences. */ + if (!strcasecmp(keycopy, "Ins") || !strcasecmp(keycopy, "Del")) + keycopy[1] = tolower(keycopy[1]); + else if (keycopy[0] != '^' && keycopy[0] != 'M' && keycopy[0] != 'F') { rcfile_error(N_("Key name must begin with \"^\", \"M\", or \"F\"")); return; }