[ruby/reline] Add cursor keys for application keypad mode to default
key bindings (https://github.com/ruby/reline/pull/719) * Add SS3 arrow sequence to default key bindings * Remove wrong KDE arrow sequence https://github.com/ruby/reline/commit/546a42522e
This commit is contained in:
parent
8f5abcb0c7
commit
0752fff215
@ -75,7 +75,10 @@ class Reline::ANSI < Reline::IO
|
|||||||
|
|
||||||
def set_default_key_bindings_ansi_cursor(config)
|
def set_default_key_bindings_ansi_cursor(config)
|
||||||
ANSI_CURSOR_KEY_BINDINGS.each do |char, (default_func, modifiers)|
|
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]
|
if modifiers[:ctrl]
|
||||||
# CSI + ctrl_key_modifier + char
|
# CSI + ctrl_key_modifier + char
|
||||||
bindings << ["\e[1;5#{char}", modifiers[:ctrl]]
|
bindings << ["\e[1;5#{char}", modifiers[:ctrl]]
|
||||||
@ -123,27 +126,9 @@ class Reline::ANSI < Reline::IO
|
|||||||
[27, 91, 49, 126] => :ed_move_to_beg, # Home
|
[27, 91, 49, 126] => :ed_move_to_beg, # Home
|
||||||
[27, 91, 52, 126] => :ed_move_to_end, # End
|
[27, 91, 52, 126] => :ed_move_to_end, # End
|
||||||
|
|
||||||
# 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
|
# urxvt / exoterm
|
||||||
[27, 91, 55, 126] => :ed_move_to_beg, # Home
|
[27, 91, 55, 126] => :ed_move_to_beg, # Home
|
||||||
[27, 91, 56, 126] => :ed_move_to_end, # End
|
[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|
|
}.each_pair do |key, func|
|
||||||
config.add_default_key_binding_by_keymap(:emacs, key, func)
|
config.add_default_key_binding_by_keymap(:emacs, key, func)
|
||||||
config.add_default_key_binding_by_keymap(:vi_insert, key, func)
|
config.add_default_key_binding_by_keymap(:vi_insert, key, func)
|
||||||
|
@ -32,25 +32,21 @@ class Reline::ANSI::WithoutTerminfoTest < Reline::TestCase
|
|||||||
|
|
||||||
def test_up_arrow
|
def test_up_arrow
|
||||||
assert_key_binding("\e[A", :ed_prev_history) # Console (80x25)
|
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)
|
assert_key_binding("\eOA", :ed_prev_history)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_down_arrow
|
def test_down_arrow
|
||||||
assert_key_binding("\e[B", :ed_next_history) # Console (80x25)
|
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)
|
assert_key_binding("\eOB", :ed_next_history)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_right_arrow
|
def test_right_arrow
|
||||||
assert_key_binding("\e[C", :ed_next_char) # Console (80x25)
|
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)
|
assert_key_binding("\eOC", :ed_next_char)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_left_arrow
|
def test_left_arrow
|
||||||
assert_key_binding("\e[D", :ed_prev_char) # Console (80x25)
|
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)
|
assert_key_binding("\eOD", :ed_prev_char)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user