From 01145a48ddc1a7609153917ac9ca82e87b66c81a Mon Sep 17 00:00:00 2001 From: Johnothan King Date: Wed, 15 Jul 2020 15:38:44 -0700 Subject: [PATCH] Handle the escape sequence for the End key (#75) Many terminals (xterm being one example) give the Home and End keys the escape sequences '^[[H' and '^[[F'. The first sequence is handled in both editing modes by moving the cursor to start of line, but ksh ignored the second sequence. src/cmd/ksh93/edit/emacs.c, src/cmd/ksh93/edit/vi.c: - Add case labels for '^[[F' so that in both editing modes the End key moves the cursor to the end of the line. --- NEWS | 4 ++++ src/cmd/ksh93/edit/emacs.c | 1 + src/cmd/ksh93/edit/vi.c | 1 + 3 files changed, 6 insertions(+) diff --git a/NEWS b/NEWS index 6ffeb9b04..423f52447 100644 --- a/NEWS +++ b/NEWS @@ -10,6 +10,10 @@ Any uppercase BUG_* names are modernish shell bug IDs. that 'unalias -a' does not remove them. Shell functions can now use these names, which improves compatibility with POSIX shell scripts. +- The End key escape sequence '^[[F' is now handled in the emacs and vi editing + modes. The End key moves the cursor to the end of the line (in contrast to + the Home key doing the opposite). + 2020-07-14: - Fixed a bug that caused 'set -b' to have no effect. diff --git a/src/cmd/ksh93/edit/emacs.c b/src/cmd/ksh93/edit/emacs.c index 87def4a57..56e3fb058 100644 --- a/src/cmd/ksh93/edit/emacs.c +++ b/src/cmd/ksh93/edit/emacs.c @@ -1105,6 +1105,7 @@ static int escape(register Emacs_t* ep,register genchar *out,int count) case 'H': ed_ungetchar(ep->ed,cntl('A')); return(-1); + case 'F': case 'Y': ed_ungetchar(ep->ed,cntl('E')); return(-1); diff --git a/src/cmd/ksh93/edit/vi.c b/src/cmd/ksh93/edit/vi.c index f2ac65604..f4b15466a 100644 --- a/src/cmd/ksh93/edit/vi.c +++ b/src/cmd/ksh93/edit/vi.c @@ -1669,6 +1669,7 @@ static int mvcursor(register Vi_t* vp,register int motion) case 'H': tcur_virt = 0; break; + case 'F': case 'Y': tcur_virt = last_virt; break;