diff options
author | aycabta <aycabta@gmail.com> | 2019-11-15 16:50:11 +0900 |
---|---|---|
committer | aycabta <aycabta@gmail.com> | 2019-11-15 16:50:40 +0900 |
commit | fa7618e4c1b382cb5863161017ef89116af3e24f (patch) | |
tree | 5aa327533c1cd5a6b78152ba09c92cc1d6416dac /lib/reline/line_editor.rb | |
parent | 6744593b8cd836967b40a4d76a9ac301b9e0f973 (diff) |
Implement em_set_mark and em_exchange_mark
Diffstat (limited to 'lib/reline/line_editor.rb')
-rw-r--r-- | lib/reline/line_editor.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb index ddb9e0ae2a..8071080ccf 100644 --- a/lib/reline/line_editor.rb +++ b/lib/reline/line_editor.rb @@ -138,6 +138,7 @@ class Reline::LineEditor def reset_variables(prompt = '', encoding = Encoding.default_external) @prompt = prompt + @mark_pointer = nil @encoding = encoding @is_multiline = false @finished = false @@ -1941,4 +1942,20 @@ class Reline::LineEditor arg -= 1 vi_join_lines(key, arg: arg) if arg > 0 end + + private def em_set_mark(key) + @mark_pointer = [@byte_pointer, @line_index] + end + alias_method :set_mark, :em_set_mark + + private def em_exchange_mark(key) + new_pointer = [@byte_pointer, @line_index] + @previous_line_index = @line_index + @byte_pointer, @line_index = @mark_pointer + @byte_pointer, @line_index = @mark_pointer + @cursor = calculate_width(@line.byteslice(0, @byte_pointer)) + @cursor_max = calculate_width(@line) + @mark_pointer = new_pointer + end + alias_method :exchange_point_and_mark, :em_exchange_mark end |