From a17eeb847e66824c4d389751cc90415d3fc1c5a3 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 25 Oct 2009 23:50:56 +0100 Subject: lineedit: handle Ctrl-arrows function old new delta read_line_input 4629 4824 +195 BB_isalnum - 39 +39 BB_ispunct - 35 +35 BB_isspace - 31 +31 static.esccmds 69 93 +24 vi_word_motion 165 162 -3 vi_back_motion 204 198 -6 vi_end_motion 172 163 -9 bb_iswspace 28 - -28 bb_iswpunct 32 - -32 bb_iswalnum 37 - -37 ------------------------------------------------------------------------------ (add/remove: 3/3 grow/shrink: 5/8 up/down: 334/-129) Total: 205 bytes Signed-off-by: Denys Vlasenko --- libbb/read_key.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'libbb/read_key.c') diff --git a/libbb/read_key.c b/libbb/read_key.c index d3832fa6c..410a99995 100644 --- a/libbb/read_key.c +++ b/libbb/read_key.c @@ -22,7 +22,6 @@ int64_t FAST_FUNC read_key(int fd, char *buffer) 'O','B' |0x80,KEYCODE_DOWN , 'O','C' |0x80,KEYCODE_RIGHT , 'O','D' |0x80,KEYCODE_LEFT , - /* Ctrl-: ESC [ 1 ; 5 x, where x = A/B/C/D */ 'O','H' |0x80,KEYCODE_HOME , 'O','F' |0x80,KEYCODE_END , #if 0 @@ -37,15 +36,26 @@ int64_t FAST_FUNC read_key(int fd, char *buffer) '[','B' |0x80,KEYCODE_DOWN , '[','C' |0x80,KEYCODE_RIGHT , '[','D' |0x80,KEYCODE_LEFT , + /* ESC [ 1 ; 2 x, where x = A/B/C/D: Shift- */ + /* ESC [ 1 ; 3 x, where x = A/B/C/D: Alt- */ + /* ESC [ 1 ; 4 x, where x = A/B/C/D: Alt-Shift- */ + /* ESC [ 1 ; 5 x, where x = A/B/C/D: Ctrl- - implemented below */ + /* ESC [ 1 ; 6 x, where x = A/B/C/D: Ctrl-Shift- */ '[','H' |0x80,KEYCODE_HOME , /* xterm */ /* [ESC] ESC [ [2] H - [Alt-][Shift-]Home */ '[','F' |0x80,KEYCODE_END , /* xterm */ '[','1','~' |0x80,KEYCODE_HOME , /* vt100? linux vt? or what? */ '[','2','~' |0x80,KEYCODE_INSERT , + /* ESC [ 2 ; 3 ~ - Alt-Insert */ '[','3','~' |0x80,KEYCODE_DELETE , /* [ESC] ESC [ 3 [;2] ~ - [Alt-][Shift-]Delete */ + /* ESC [ 3 ; 3 ~ - Alt-Delete */ + /* ESC [ 3 ; 5 ~ - Ctrl-Delete */ '[','4','~' |0x80,KEYCODE_END , /* vt100? linux vt? or what? */ '[','5','~' |0x80,KEYCODE_PAGEUP , + /* ESC [ 5 ; 3 ~ - Alt-PgUp */ + /* ESC [ 5 ; 5 ~ - Ctrl-PgUp */ + /* ESC [ 5 ; 7 ~ - Ctrl-Alt-PgUp */ '[','6','~' |0x80,KEYCODE_PAGEDOWN, '[','7','~' |0x80,KEYCODE_HOME , /* vt100? linux vt? or what? */ '[','8','~' |0x80,KEYCODE_END , /* vt100? linux vt? or what? */ @@ -64,6 +74,10 @@ int64_t FAST_FUNC read_key(int fd, char *buffer) '[','2','3','~'|0x80,KEYCODE_FUN11 , '[','2','4','~'|0x80,KEYCODE_FUN12 , #endif + '[','1',';','5','A' |0x80,KEYCODE_CTRL_UP , + '[','1',';','5','B' |0x80,KEYCODE_CTRL_DOWN , + '[','1',';','5','C' |0x80,KEYCODE_CTRL_RIGHT, + '[','1',';','5','D' |0x80,KEYCODE_CTRL_LEFT , 0 }; -- cgit v1.2.3