diff options
author | Rostislav Skudnov <rostislav@tuxera.com> | 2016-11-24 15:04:00 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2016-11-24 15:04:00 +0100 |
commit | 2e4ef38743c3d4aef109b5cc04429ec1f0e2f6c8 (patch) | |
tree | 4224ad31b96cf2b03874083b80da7c4d38995817 /libbb/read_key.c | |
parent | cb810c48c036f50c19b08df7e161cdb0550a2abd (diff) | |
download | busybox-w32-2e4ef38743c3d4aef109b5cc04429ec1f0e2f6c8.tar.gz busybox-w32-2e4ef38743c3d4aef109b5cc04429ec1f0e2f6c8.tar.bz2 busybox-w32-2e4ef38743c3d4aef109b5cc04429ec1f0e2f6c8.zip |
lineedit: fix handling of repeating Alt-b, Alt-f, Alt-d, Alt-Backspace
These key combinations should repeat correctly when the keys are
pressed and held.
Before this change, they do this erratically - many repeats are "eaten"
because they are treated as unrecognized ESC seqs:
ESC 0x7f is treated by Alt+baskspace, but ESC 0x7f ESC 0x7f ESC 0x7f
is unrecognized.
Escape sequences corresponding to these key combinations are moved from
read_line_input to lineedit_read_key.
Also, these key sequences are now enabled regardless of whether
FEATURE_EDITING_VI is set, since Vim does not actually support these key
combinations, but they are present in readline library.
function old new delta
static.esccmds 93 103 +10
read_line_input 3737 3687 -50
Signed-off-by: Rostislav Skudnov <rostislav@tuxera.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb/read_key.c')
-rw-r--r-- | libbb/read_key.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/libbb/read_key.c b/libbb/read_key.c index ace23defb..951786869 100644 --- a/libbb/read_key.c +++ b/libbb/read_key.c | |||
@@ -18,8 +18,20 @@ int64_t FAST_FUNC read_key(int fd, char *buffer, int timeout) | |||
18 | /* Known escape sequences for cursor and function keys. | 18 | /* Known escape sequences for cursor and function keys. |
19 | * See "Xterm Control Sequences" | 19 | * See "Xterm Control Sequences" |
20 | * http://invisible-island.net/xterm/ctlseqs/ctlseqs.html | 20 | * http://invisible-island.net/xterm/ctlseqs/ctlseqs.html |
21 | * Array should be sorted from shortest to longest. | ||
21 | */ | 22 | */ |
22 | static const char esccmds[] ALIGN1 = { | 23 | static const char esccmds[] ALIGN1 = { |
24 | '\x7f' |0x80,KEYCODE_ALT_BACKSPACE, | ||
25 | '\b' |0x80,KEYCODE_ALT_BACKSPACE, | ||
26 | 'd' |0x80,KEYCODE_ALT_D , | ||
27 | /* lineedit mimics bash: Alt-f and Alt-b are forward/backward | ||
28 | * word jumps. We cheat here and make them return ALT_LEFT/RIGHT | ||
29 | * keycodes. This way, lineedit need no special code to handle them. | ||
30 | * If we'll need to distinguish them, introduce new ALT_F/B keycodes, | ||
31 | * and update lineedit to react to them. | ||
32 | */ | ||
33 | 'f' |0x80,KEYCODE_ALT_RIGHT, | ||
34 | 'b' |0x80,KEYCODE_ALT_LEFT, | ||
23 | 'O','A' |0x80,KEYCODE_UP , | 35 | 'O','A' |0x80,KEYCODE_UP , |
24 | 'O','B' |0x80,KEYCODE_DOWN , | 36 | 'O','B' |0x80,KEYCODE_DOWN , |
25 | 'O','C' |0x80,KEYCODE_RIGHT , | 37 | 'O','C' |0x80,KEYCODE_RIGHT , |