diff options
author | aycabta <aycabta@gmail.com> | 2020-01-21 09:30:30 +0900 |
---|---|---|
committer | aycabta <aycabta@gmail.com> | 2020-01-21 09:52:32 +0900 |
commit | 2943ebd240bba9c50b1f2a245a9f9186c2255706 (patch) | |
tree | b16bb554fdc040c5d9199973aefb3fe233cad7d7 /lib/reline | |
parent | 93ca212ddac5ac49134f2058c24db3948b6695c6 (diff) |
[ruby/reline] Implement vi_change_meta
https://github.com/ruby/reline/commit/8538e0e10f
Diffstat (limited to 'lib/reline')
-rw-r--r-- | lib/reline/line_editor.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb index 9518a054fd..9ee361ec78 100644 --- a/lib/reline/line_editor.rb +++ b/lib/reline/line_editor.rb @@ -1922,6 +1922,18 @@ class Reline::LineEditor end private def vi_change_meta(key) + @waiting_operator_proc = proc { |cursor_diff, byte_pointer_diff| + if byte_pointer_diff > 0 + @line, cut = byteslice!(@line, @byte_pointer, byte_pointer_diff) + elsif byte_pointer_diff < 0 + @line, cut = byteslice!(@line, @byte_pointer + byte_pointer_diff, -byte_pointer_diff) + end + copy_for_vi(cut) + @cursor += cursor_diff if cursor_diff < 0 + @cursor_max -= cursor_diff.abs + @byte_pointer += byte_pointer_diff if byte_pointer_diff < 0 + @config.editing_mode = :vi_insert + } end private def vi_delete_meta(key) |