diff --git a/lib/reline/io/ansi.rb b/lib/reline/io/ansi.rb index 82d2ee2371..cf0c1c1b31 100644 --- a/lib/reline/io/ansi.rb +++ b/lib/reline/io/ansi.rb @@ -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]] @@ -123,27 +126,9 @@ def set_default_key_bindings_comprehensive_list(config) [27, 91, 49, 126] => :ed_move_to_beg, # Home [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 [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) diff --git a/test/reline/test_ansi_without_terminfo.rb b/test/reline/test_ansi_without_terminfo.rb index 2db14cf0a0..62b1e7dec0 100644 --- a/test/reline/test_ansi_without_terminfo.rb +++ b/test/reline/test_ansi_without_terminfo.rb @@ -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