Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 4 additions & 19 deletions lib/reline/io/ansi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ def set_bracketed_paste_key_bindings(config)

def set_default_key_bindings_ansi_cursor(config)
ANSI_CURSOR_KEY_BINDINGS.each do |char, (default_func, modifiers)|
bindings = [["\e[#{char}", default_func]] # CSI + char
bindings = [
["\e[#{char}", default_func], # CSI + char
["\eO#{char}", default_func] # SS3 + char, application cursor key mode
]
if modifiers[:ctrl]
# CSI + ctrl_key_modifier + char
bindings << ["\e[1;5#{char}", modifiers[:ctrl]]
Expand Down Expand Up @@ -119,27 +122,9 @@ def set_default_key_bindings_comprehensive_list(config)
[27, 91, 52, 126] => :ed_move_to_end, # End
[27, 91, 51, 126] => :key_delete, # Del

# KDE
# Del is 0x08
[27, 71, 65] => :ed_prev_history, # ↑
[27, 71, 66] => :ed_next_history, # ↓
[27, 71, 67] => :ed_next_char, # →
[27, 71, 68] => :ed_prev_char, # ←

# urxvt / exoterm
[27, 91, 55, 126] => :ed_move_to_beg, # Home
[27, 91, 56, 126] => :ed_move_to_end, # End

# GNOME
[27, 79, 72] => :ed_move_to_beg, # Home
[27, 79, 70] => :ed_move_to_end, # End
# Del is 0x08
# Arrow keys are the same of KDE

[27, 79, 65] => :ed_prev_history, # ↑
[27, 79, 66] => :ed_next_history, # ↓
[27, 79, 67] => :ed_next_char, # →
[27, 79, 68] => :ed_prev_char, # ←
}.each_pair do |key, func|
config.add_default_key_binding_by_keymap(:emacs, key, func)
config.add_default_key_binding_by_keymap(:vi_insert, key, func)
Expand Down
4 changes: 0 additions & 4 deletions test/reline/test_ansi_without_terminfo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,21 @@ def test_delete

def test_up_arrow
assert_key_binding("\e[A", :ed_prev_history) # Console (80x25)
assert_key_binding("\eGA", :ed_prev_history) # KDE
assert_key_binding("\eOA", :ed_prev_history)
end

def test_down_arrow
assert_key_binding("\e[B", :ed_next_history) # Console (80x25)
assert_key_binding("\eGB", :ed_next_history) # KDE
assert_key_binding("\eOB", :ed_next_history)
end

def test_right_arrow
assert_key_binding("\e[C", :ed_next_char) # Console (80x25)
assert_key_binding("\eGC", :ed_next_char) # KDE
assert_key_binding("\eOC", :ed_next_char)
end

def test_left_arrow
assert_key_binding("\e[D", :ed_prev_char) # Console (80x25)
assert_key_binding("\eGD", :ed_prev_char) # KDE
assert_key_binding("\eOD", :ed_prev_char)
end

Expand Down