bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] readline: bind kH (home down) and sanitize cursor key comments


From: Xose Vazquez Perez
Subject: [PATCH] readline: bind kH (home down) and sanitize cursor key comments
Date: Tue, 9 Jun 2026 23:42:50 +0200

The 'kH' (home down) capability is defined in termcap as the
"lower-left" key. In many terminal emulators, this sequence is
sent by the 'End' key, serving as the counterpart to 'kh' (Home).

While readline was already fetching 'kH' from the termcap 
description, it was not bound to any function. This patch:

- Binds 'kH' to rl_end_of_line, mirroring the '@7' behavior.
- Updates the comment for 'kH' in tc_strings to match the official 
  GNU termcap documentation ("lower-left key").
- Standardizes capitalization for Page Up, Page Down, and Delete 
  comments.
- Clarifies that bind_termcap_arrow_keys handles "cursor keys" 
  rather than just arrows.

Cc: bug bash <bug-bash@gnu.org>
Cc: bug readline <bug-readline@gnu.org>
Cc: bash maintainers <bash-maintainers@gnu.org>
Cc: Chet Ramey <chet.ramey@case.edu>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
---
https://man7.org/linux/man-pages/man5/terminfo.5.html
https://www.gnu.org/software/termutils/manual/termcap-1.3/html_chapter/termcap_5.html
https://www.gnu.org/software/termutils/manual/termcap-1.3/html_chapter/termcap_4.html
---
 terminal.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/terminal.c b/terminal.c
index 50fb904..31c34a7 100644
--- a/terminal.c
+++ b/terminal.c
@@ -181,7 +181,7 @@ static char *_rl_term_kD;
 /* Insert key */
 static char *_rl_term_kI;
 
-/* Page up and page down keys */
+/* Page Up and Page Down keys */
 static char *_rl_term_kP;
 static char *_rl_term_kN;
 
@@ -451,7 +451,7 @@ struct _tc_string {
    search algorithm to something smarter. */
 static const struct _tc_string tc_strings[] =
 {
-  { "@7", &_rl_term_at7 },
+  { "@7", &_rl_term_at7 },     /* end */
   { "BD", &_rl_term_BD },
   { "BE", &_rl_term_BE },
   { "DC", &_rl_term_DC },
@@ -468,7 +468,7 @@ static const struct _tc_string tc_strings[] =
   { "ic", &_rl_term_ic },
   { "im", &_rl_term_im },
   { "kD", &_rl_term_kD },      /* delete */
-  { "kH", &_rl_term_kH },      /* home down ?? */
+  { "kH", &_rl_term_kH },      /* lower-left key (home down) */
   { "kI", &_rl_term_kI },      /* insert */
   { "kN", &_rl_term_kN },      /* page down */
   { "kP", &_rl_term_kP },      /* page up */
@@ -751,7 +751,7 @@ _rl_init_terminal_io (const char *terminal_name)
   return 0;
 }
 
-/* Bind the arrow key sequences from the termcap description in MAP. */
+/* Bind the cursor key sequences from the termcap description in MAP. */
 static void
 bind_termcap_arrow_keys (Keymap map)
 {
@@ -767,8 +767,9 @@ bind_termcap_arrow_keys (Keymap map)
 
   rl_bind_keyseq_if_unbound (_rl_term_kh, rl_beg_of_line);     /* Home */
   rl_bind_keyseq_if_unbound (_rl_term_at7, rl_end_of_line);    /* End */
+  rl_bind_keyseq_if_unbound (_rl_term_kH, rl_end_of_line);     /* Lower-left 
key (home down) */
 
-  rl_bind_keyseq_if_unbound (_rl_term_kD, rl_delete);
+  rl_bind_keyseq_if_unbound (_rl_term_kD, rl_delete);          /* Delete */
   rl_bind_keyseq_if_unbound (_rl_term_kI, rl_overwrite_mode);  /* Insert */
 
   rl_bind_keyseq_if_unbound (_rl_term_kN, rl_history_search_forward);  /* Page 
Down */
-- 
2.53.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]