diff options
author | aycabta <aycabta@gmail.com> | 2019-05-21 17:46:31 +0900 |
---|---|---|
committer | aycabta <aycabta@gmail.com> | 2019-05-21 17:46:41 +0900 |
commit | 6d93baaedd0e9819d4ddb6637b2d3d539f1fa210 (patch) | |
tree | a77b588bf49957a1c8f069740801443e97d20b66 /lib | |
parent | 8c004c71235c5ee8b2d4846672788d3089f3e884 (diff) | |
download | ruby-6d93baaedd0e9819d4ddb6637b2d3d539f1fa210.tar.gz |
Support DEL key
Diffstat (limited to 'lib')
-rw-r--r-- | lib/reline.rb | 6 | ||||
-rw-r--r-- | lib/reline/line_editor.rb | 6 |
2 files changed, 10 insertions, 2 deletions
diff --git a/lib/reline.rb b/lib/reline.rb index a5acc52f03..258edcd457 100644 --- a/lib/reline.rb +++ b/lib/reline.rb @@ -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 diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb index 9df263aba1..fb7e377dcf 100644 --- a/lib/reline/line_editor.rb +++ b/lib/reline/line_editor.rb @@ -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) |