Skip to contentSkip to conversation

kconfig/[mn]conf: handle backspace (^H) key

PATCH In review Changbin Du 2 participants 4 messages Mar 25, 2019 – Mar 29, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 scripts/kconfig/lxdialog/inputbox.c | 3 ++-
 scripts/kconfig/nconf.c             | 2 +-
 scripts/kconfig/nconf.gui.c         | 3 ++-
 3 files changed, 5 insertions(+), 3 deletions(-)
scripts/kconfig/lxdialog/inputbox.c +2 -1
index 611945611bf8..1dcfb288ee63 100644
@@ -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) {
scripts/kconfig/nconf.c +1 -1
index a4670f4e825a..ac92c0ded6c5 100644
@@ -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
scripts/kconfig/nconf.gui.c +2 -1
index 7be620a1fcdb..77f525a8617c 100644
@@ -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],
Signature · 1 line
2.17.1
#1 lore raw
Quoted 4 lines · Changbin Du

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.

Shall I fix '$?' to '^?'
if it is a typo?

Quoted 54 lines

Let's also handle '^H' for those
terminals.

---
 scripts/kconfig/lxdialog/inputbox.c | 3 ++-
 scripts/kconfig/nconf.c             | 2 +-
 scripts/kconfig/nconf.gui.c         | 3 ++-
 3 files changed, 5 insertions(+), 3 deletions(-)
scripts/kconfig/lxdialog/inputbox.c +2 -1
index 611945611bf8..1dcfb288ee63 100644
@@ -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) {
scripts/kconfig/nconf.c +1 -1
index a4670f4e825a..ac92c0ded6c5 100644
@@ -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
scripts/kconfig/nconf.gui.c +2 -2
index 7be620a1fcdb..77f525a8617c 100644
@@ -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.17.1

Signature · 2 lines
Best Regards
Masahiro Yamada
#2 lore raw
Quoted 11 lines · Masahiro Yamada
Quoted 4 lines · Changbin Du

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.

Shall I fix '$?' to '^?'
if it is a typo?

yes, please. It is a typo, sorry.

Quoted 62 lines
Quoted 57 lines

Let's also handle '^H' for those
terminals.

---
 scripts/kconfig/lxdialog/inputbox.c | 3 ++-
 scripts/kconfig/nconf.c             | 2 +-
 scripts/kconfig/nconf.gui.c         | 3 ++-
 3 files changed, 5 insertions(+), 3 deletions(-)
scripts/kconfig/lxdialog/inputbox.c +2 -1
index 611945611bf8..1dcfb288ee63 100644
@@ -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) {
scripts/kconfig/nconf.c +1 -1
index a4670f4e825a..ac92c0ded6c5 100644
@@ -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
scripts/kconfig/nconf.gui.c +2 -2
index 7be620a1fcdb..77f525a8617c 100644
@@ -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.17.1

Signature · 2 lines
Best Regards
Masahiro Yamada
Signature · 2 lines
Cheers,
Changbin Du
#3 lore raw
Quoted 10 lines · Changbin Du
Quoted 8 lines · Masahiro Yamada
Quoted 4 lines · Changbin Du

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.

Quoted 5 lines
Quoted 3 lines

Shall I fix '$?' to '^?'
if it is a typo?

yes, please. It is a typo, sorry.

Fixed the typo,
and applied to linux-kbuild/fixes. Thanks.

Quoted 66 lines
Quoted 54 lines
Quoted 54 lines

Let's also handle '^H' for those
terminals.

---
 scripts/kconfig/lxdialog/inputbox.c | 3 ++-
 scripts/kconfig/nconf.c             | 2 +-
 scripts/kconfig/nconf.gui.c         | 3 ++-
 3 files changed, 5 insertions(+), 3 deletions(-)
scripts/kconfig/lxdialog/inputbox.c +2 -1
index 611945611bf8..1dcfb288ee63 100644
@@ -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) {
scripts/kconfig/nconf.c +1 -1
index a4670f4e825a..ac92c0ded6c5 100644
@@ -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
scripts/kconfig/nconf.gui.c +2 -1
index 7be620a1fcdb..77f525a8617c 100644
@@ -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],
Quoted 8 lines
Quoted 3 lines

--
2.17.1

--
Best Regards
Masahiro Yamada

--
Cheers,
Changbin Du

Signature · 2 lines
Best Regards
Masahiro Yamada