From fa7618e4c1b382cb5863161017ef89116af3e24f Mon Sep 17 00:00:00 2001 From: aycabta Date: Fri, 15 Nov 2019 16:50:11 +0900 Subject: Implement em_set_mark and em_exchange_mark --- lib/reline/line_editor.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'lib/reline/line_editor.rb') 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 -- cgit v1.2.3