Skip to content

Commit 41deb1a

Browse files
committed
Organize special keys escape sequences
1 parent 24811d3 commit 41deb1a

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

lib/reline/ansi.rb

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,40 @@ def self.win?
1010
end
1111

1212
RAW_KEYSTROKE_CONFIG = {
13+
# Console (80x25)
14+
[27, 91, 49, 126] => :ed_move_to_beg, # Home
15+
[27, 91, 52, 126] => :ed_move_to_end, # End
16+
[27, 91, 51, 126] => :key_delete, # Del
1317
[27, 91, 65] => :ed_prev_history, # ↑
1418
[27, 91, 66] => :ed_next_history, # ↓
1519
[27, 91, 67] => :ed_next_char, # →
1620
[27, 91, 68] => :ed_prev_char, # ←
17-
[27, 91, 51, 126] => :key_delete, # Del
18-
[27, 91, 49, 126] => :ed_move_to_beg, # Home
19-
[27, 91, 52, 126] => :ed_move_to_end, # End
21+
22+
# KDE
2023
[27, 91, 72] => :ed_move_to_beg, # Home
2124
[27, 91, 70] => :ed_move_to_end, # End
25+
# Del is 0x08
26+
[27, 71, 65] => :ed_prev_history, # ↑
27+
[27, 71, 66] => :ed_next_history, # ↓
28+
[27, 71, 67] => :ed_next_char, # →
29+
[27, 71, 68] => :ed_prev_char, # ←
30+
31+
# GNOME
2232
[27, 79, 72] => :ed_move_to_beg, # Home
2333
[27, 79, 70] => :ed_move_to_end, # End
34+
# Del is 0x08
35+
# Arrow keys are the same of KDE
36+
37+
# others
2438
[27, 32] => :em_set_mark, # M-<space>
2539
[24, 24] => :em_exchange_mark, # C-x C-x TODO also add Windows
2640
[27, 91, 49, 59, 53, 67] => :em_next_word, # Ctrl+→
2741
[27, 91, 49, 59, 53, 68] => :ed_prev_word, # Ctrl+←
42+
43+
[27, 79, 65] => :ed_prev_history, # ↑
44+
[27, 79, 66] => :ed_next_history, # ↓
45+
[27, 79, 67] => :ed_next_char, # →
46+
[27, 79, 68] => :ed_prev_char, # ←
2847
}
2948

3049
@@input = STDIN

0 commit comments

Comments
 (0)