diff options
author | aycabta <aycabta@gmail.com> | 2019-05-27 06:04:42 +0900 |
---|---|---|
committer | aycabta <aycabta@gmail.com> | 2019-05-27 06:04:42 +0900 |
commit | 2c91c5b329796a0c7f3cda0296d7c6d6cd6aa8c6 (patch) | |
tree | 5d56d321a1f994252776f3dd068b44e40858ca9f | |
parent | 716ba4a12732d94a50fb31bcaca4ce07bc4b6870 (diff) | |
download | ruby-2c91c5b329796a0c7f3cda0296d7c6d6cd6aa8c6.tar.gz |
Move to the other line when press <- at head or -> at tail
-rw-r--r-- | lib/reline/line_editor.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb index 83c0d419c3..99a0b6ce22 100644 --- a/lib/reline/line_editor.rb +++ b/lib/reline/line_editor.rb @@ -874,6 +874,13 @@ class Reline::LineEditor width = Reline::Unicode.get_mbchar_width(mbchar) @cursor += width if width @byte_pointer += byte_size + elsif @is_multiline and @config.editing_mode_is?(:emacs) and @byte_pointer == @line.bytesize and @line_index < @buffer_of_lines.size - 1 + next_line = @buffer_of_lines[@line_index + 1] + @cursor = 0 + @byte_pointer = 0 + @cursor_max = calculate_width(next_line) + @previous_line_index = @line_index + @line_index += 1 end arg -= 1 ed_next_char(key, arg: arg) if arg > 0 @@ -886,6 +893,13 @@ class Reline::LineEditor mbchar = @line.byteslice(@byte_pointer, byte_size) width = Reline::Unicode.get_mbchar_width(mbchar) @cursor -= width + elsif @is_multiline and @config.editing_mode_is?(:emacs) and @byte_pointer == 0 and @line_index > 0 + prev_line = @buffer_of_lines[@line_index - 1] + @cursor = calculate_width(prev_line) + @byte_pointer = prev_line.bytesize + @cursor_max = calculate_width(prev_line) + @previous_line_index = @line_index + @line_index -= 1 end arg -= 1 ed_prev_char(key, arg: arg) if arg > 0 |