Skip to content

Commit 0752fff

Browse files
tompngmatzbot
authored andcommitted
[ruby/reline] Add cursor keys for application keypad mode to default
key bindings (ruby/reline#719) * Add SS3 arrow sequence to default key bindings * Remove wrong KDE arrow sequence ruby/reline@546a42522e
1 parent 8f5abcb commit 0752fff

File tree

2 files changed

+4
-23
lines changed

2 files changed

+4
-23
lines changed

lib/reline/io/ansi.rb

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,10 @@ def set_bracketed_paste_key_bindings(config)
7575

7676
def set_default_key_bindings_ansi_cursor(config)
7777
ANSI_CURSOR_KEY_BINDINGS.each do |char, (default_func, modifiers)|
78-
bindings = [["\e[#{char}", default_func]] # CSI + char
78+
bindings = [
79+
["\e[#{char}", default_func], # CSI + char
80+
["\eO#{char}", default_func] # SS3 + char, application cursor key mode
81+
]
7982
if modifiers[:ctrl]
8083
# CSI + ctrl_key_modifier + char
8184
bindings << ["\e[1;5#{char}", modifiers[:ctrl]]
@@ -123,27 +126,9 @@ def set_default_key_bindings_comprehensive_list(config)
123126
[27, 91, 49, 126] => :ed_move_to_beg, # Home
124127
[27, 91, 52, 126] => :ed_move_to_end, # End
125128

126-
# KDE
127-
# Del is 0x08
128-
[27, 71, 65] => :ed_prev_history, # ↑
129-
[27, 71, 66] => :ed_next_history, # ↓
130-
[27, 71, 67] => :ed_next_char, # →
131-
[27, 71, 68] => :ed_prev_char, # ←
132-
133129
# urxvt / exoterm
134130
[27, 91, 55, 126] => :ed_move_to_beg, # Home
135131
[27, 91, 56, 126] => :ed_move_to_end, # End
136-
137-
# GNOME
138-
[27, 79, 72] => :ed_move_to_beg, # Home
139-
[27, 79, 70] => :ed_move_to_end, # End
140-
# Del is 0x08
141-
# Arrow keys are the same of KDE
142-
143-
[27, 79, 65] => :ed_prev_history, # ↑
144-
[27, 79, 66] => :ed_next_history, # ↓
145-
[27, 79, 67] => :ed_next_char, # →
146-
[27, 79, 68] => :ed_prev_char, # ←
147132
}.each_pair do |key, func|
148133
config.add_default_key_binding_by_keymap(:emacs, key, func)
149134
config.add_default_key_binding_by_keymap(:vi_insert, key, func)

test/reline/test_ansi_without_terminfo.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,21 @@ def test_delete
3232

3333
def test_up_arrow
3434
assert_key_binding("\e[A", :ed_prev_history) # Console (80x25)
35-
assert_key_binding("\eGA", :ed_prev_history) # KDE
3635
assert_key_binding("\eOA", :ed_prev_history)
3736
end
3837

3938
def test_down_arrow
4039
assert_key_binding("\e[B", :ed_next_history) # Console (80x25)
41-
assert_key_binding("\eGB", :ed_next_history) # KDE
4240
assert_key_binding("\eOB", :ed_next_history)
4341
end
4442

4543
def test_right_arrow
4644
assert_key_binding("\e[C", :ed_next_char) # Console (80x25)
47-
assert_key_binding("\eGC", :ed_next_char) # KDE
4845
assert_key_binding("\eOC", :ed_next_char)
4946
end
5047

5148
def test_left_arrow
5249
assert_key_binding("\e[D", :ed_prev_char) # Console (80x25)
53-
assert_key_binding("\eGD", :ed_prev_char) # KDE
5450
assert_key_binding("\eOD", :ed_prev_char)
5551
end
5652

0 commit comments

Comments
 (0)