зеркало из https://github.com/github/ruby.git
Support DEL key
This commit is contained in:
Родитель
8c004c7123
Коммит
6d93baaedd
|
@ -299,7 +299,8 @@ module Reline
|
|||
[224, 72] => :ed_prev_history, # ↑
|
||||
[224, 80] => :ed_next_history, # ↓
|
||||
[224, 77] => :ed_next_char, # →
|
||||
[224, 75] => :ed_prev_char # ←
|
||||
[224, 75] => :ed_prev_char, # ←
|
||||
[224, 83] => :key_delete # Del
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -308,7 +309,8 @@ module Reline
|
|||
[27, 91, 65] => :ed_prev_history, # ↑
|
||||
[27, 91, 66] => :ed_next_history, # ↓
|
||||
[27, 91, 67] => :ed_next_char, # →
|
||||
[27, 91, 68] => :ed_prev_char # ←
|
||||
[27, 91, 68] => :ed_prev_char, # ←
|
||||
[27, 91, 51, 126] => :key_delete # Del
|
||||
}
|
||||
}
|
||||
end
|
||||
|
|
|
@ -761,6 +761,12 @@ class Reline::LineEditor
|
|||
}
|
||||
end
|
||||
|
||||
private def key_delete(key)
|
||||
if @config.editing_mode_is?(:vi_insert, :emacs)
|
||||
ed_delete_next_char(key)
|
||||
end
|
||||
end
|
||||
|
||||
private def ed_insert(key)
|
||||
if key.instance_of?(String)
|
||||
width = Reline::Unicode.get_mbchar_width(key)
|
||||
|
|
|
@ -1180,4 +1180,29 @@ class Reline::KeyActor::Emacs::Test < Reline::TestCase
|
|||
assert_cursor(0)
|
||||
assert_cursor_max(3)
|
||||
end
|
||||
|
||||
=begin # TODO: move KeyStroke instance from Reline to LineEditor
|
||||
def test_key_delete
|
||||
input_keys('ab')
|
||||
assert_byte_pointer_size('ab')
|
||||
assert_cursor(2)
|
||||
assert_cursor_max(2)
|
||||
assert_line('ab')
|
||||
[27, 91, 51, 126].each do |key|
|
||||
@line_editor.input_key(key)
|
||||
end
|
||||
assert_byte_pointer_size('ab')
|
||||
assert_cursor(2)
|
||||
assert_cursor_max(2)
|
||||
assert_line('ab')
|
||||
input_keys("\C-b")
|
||||
[27, 91, 51, 126].each do |key|
|
||||
@line_editor.input_key(key)
|
||||
end
|
||||
assert_byte_pointer_size('a')
|
||||
assert_cursor(1)
|
||||
assert_cursor_max(1)
|
||||
assert_line('a')
|
||||
end
|
||||
=end
|
||||
end
|
||||
|
|
Загрузка…
Ссылка в новой задаче