[Buildroot] [git commit branch/2024.11.x] support/kconfig: handle backspace (^H) key
Arnout Vandecappelle
arnout at rnout.be
Fri Apr 11 10:42:22 UTC 2025
commit: https://git.buildroot.net/buildroot/commit/?id=fee4b78429c8181b29393cd3fea381723d7b5b01
branch: https://git.buildroot.net/buildroot/commit/?id=refs/heads/2024.11.x
This is in the mainline kernel since v5.1-rc3:
9c38f1f04408 ("kconfig/[mn]conf: handle backspace (^H) key")
Quoting the commit's log:
"
Backspace is not working on some terminal emulators which do not send the
key code defined by terminfo. Terminals either send '^H' (8) or '^?' (127).
But currently only '^?' is handled. Let's also handle '^H' for those
terminals.
"
Signed-off-by: Sébastien Szymanski <sebastien.szymanski at armadeus.com>
Signed-off-by: Julien Olivain <ju.o at free.fr>
(cherry picked from commit d65c10c20add58f17cf1d7b6de8e7903b0aa9ddc)
Signed-off-by: Thomas Perale <thomas.perale at mind.be>
---
support/kconfig/lxdialog/inputbox.c | 3 +-
support/kconfig/nconf.c | 2 +-
support/kconfig/nconf.gui.c | 3 +-
...23-kconfig-mn-conf-handle-backspace-H-key.patch | 62 ++++++++++++++++++++++
support/kconfig/patches/series | 1 +
5 files changed, 68 insertions(+), 3 deletions(-)
diff --git a/support/kconfig/lxdialog/inputbox.c b/support/kconfig/lxdialog/inputbox.c
index d58de1dc53..510049a7bd 100644
--- a/support/kconfig/lxdialog/inputbox.c
+++ b/support/kconfig/lxdialog/inputbox.c
@@ -126,7 +126,8 @@ do_resize:
case KEY_DOWN:
break;
case KEY_BACKSPACE:
- case 127:
+ case 8: /* ^H */
+ case 127: /* ^? */
if (pos) {
wattrset(dialog, dlg.inputbox.atr);
if (input_x == 0) {
diff --git a/support/kconfig/nconf.c b/support/kconfig/nconf.c
index 0031147798..e8e1944fa0 100644
--- a/support/kconfig/nconf.c
+++ b/support/kconfig/nconf.c
@@ -1048,7 +1048,7 @@ static int do_match(int key, struct match_state *state, int *ans)
state->match_direction = FIND_NEXT_MATCH_UP;
*ans = get_mext_match(state->pattern,
state->match_direction);
- } else if (key == KEY_BACKSPACE || key == 127) {
+ } else if (key == KEY_BACKSPACE || key == 8 || key == 127) {
state->pattern[strlen(state->pattern)-1] = '\0';
adj_match_dir(&state->match_direction);
} else
diff --git a/support/kconfig/nconf.gui.c b/support/kconfig/nconf.gui.c
index 88874acfda..820fc92565 100644
--- a/support/kconfig/nconf.gui.c
+++ b/support/kconfig/nconf.gui.c
@@ -440,7 +440,8 @@ int dialog_inputbox(WINDOW *main_window,
case KEY_F(F_EXIT):
case KEY_F(F_BACK):
break;
- case 127:
+ case 8: /* ^H */
+ case 127: /* ^? */
case KEY_BACKSPACE:
if (cursor_position > 0) {
memmove(&result[cursor_position-1],
diff --git a/support/kconfig/patches/23-kconfig-mn-conf-handle-backspace-H-key.patch b/support/kconfig/patches/23-kconfig-mn-conf-handle-backspace-H-key.patch
new file mode 100644
index 0000000000..6e32115f70
--- /dev/null
+++ b/support/kconfig/patches/23-kconfig-mn-conf-handle-backspace-H-key.patch
@@ -0,0 +1,62 @@
+From 9c38f1f044080392603c497ecca4d7d09876ff99 Mon Sep 17 00:00:00 2001
+From: Changbin Du <changbin.du at gmail.com>
+Date: Mon, 25 Mar 2019 15:16:47 +0000
+Subject: [PATCH 23/23] kconfig/[mn]conf: handle backspace (^H) key
+
+Backspace is not working on some terminal emulators which do not send the
+key code defined by terminfo. Terminals either send '^H' (8) or '^?' (127).
+But currently only '^?' is handled. Let's also handle '^H' for those
+terminals.
+
+Signed-off-by: Changbin Du <changbin.du at gmail.com>
+Signed-off-by: Masahiro Yamada <yamada.masahiro at socionext.com>
+---
+ kconfig/lxdialog/inputbox.c | 3 ++-
+ kconfig/nconf.c | 2 +-
+ kconfig/nconf.gui.c | 3 ++-
+ 3 files changed, 5 insertions(+), 3 deletions(-)
+
+diff --git a/kconfig/lxdialog/inputbox.c b/kconfig/lxdialog/inputbox.c
+index 611945611bf8..1dcfb288ee63 100644
+--- a/kconfig/lxdialog/inputbox.c
++++ b/kconfig/lxdialog/inputbox.c
+@@ -113,7 +113,8 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width
+ case KEY_DOWN:
+ break;
+ case KEY_BACKSPACE:
+- case 127:
++ case 8: /* ^H */
++ case 127: /* ^? */
+ if (pos) {
+ wattrset(dialog, dlg.inputbox.atr);
+ if (input_x == 0) {
+diff --git a/kconfig/nconf.c b/kconfig/nconf.c
+index a4670f4e825a..ac92c0ded6c5 100644
+--- a/kconfig/nconf.c
++++ b/kconfig/nconf.c
+@@ -1048,7 +1048,7 @@ static int do_match(int key, struct match_state *state, int *ans)
+ state->match_direction = FIND_NEXT_MATCH_UP;
+ *ans = get_mext_match(state->pattern,
+ state->match_direction);
+- } else if (key == KEY_BACKSPACE || key == 127) {
++ } else if (key == KEY_BACKSPACE || key == 8 || key == 127) {
+ state->pattern[strlen(state->pattern)-1] = '\0';
+ adj_match_dir(&state->match_direction);
+ } else
+diff --git a/kconfig/nconf.gui.c b/kconfig/nconf.gui.c
+index 7be620a1fcdb..77f525a8617c 100644
+--- a/kconfig/nconf.gui.c
++++ b/kconfig/nconf.gui.c
+@@ -439,7 +439,8 @@ int dialog_inputbox(WINDOW *main_window,
+ case KEY_F(F_EXIT):
+ case KEY_F(F_BACK):
+ break;
+- case 127:
++ case 8: /* ^H */
++ case 127: /* ^? */
+ case KEY_BACKSPACE:
+ if (cursor_position > 0) {
+ memmove(&result[cursor_position-1],
+--
+2.48.1
+
diff --git a/support/kconfig/patches/series b/support/kconfig/patches/series
index f120e323b7..cc176035be 100644
--- a/support/kconfig/patches/series
+++ b/support/kconfig/patches/series
@@ -11,3 +11,4 @@
20-merge_config.sh-Allow-to-define-config-prefix.patch
21-Avoid-false-positive-matches-from-comment-lines.patch
22-kconfig-lxdialog-fix-check-with-GCC14.patch
+23-kconfig-mn-conf-handle-backspace-H-key.patch
More information about the buildroot
mailing list