katakata_irb 0.1.2 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/exe/kirb DELETED
@@ -1,11 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require_relative '../lib/katakata_irb'
3
- KatakataIrb.log_output = STDERR if ARGV.delete '--debug-output'
4
- unless ARGV.delete '--without-patch'
5
- require_relative '../lib/katakata_irb/reline_patch'
6
- KatakataIrb::RelinePatch.require_patched_reline
7
- require 'katakata_irb/ruby_lex_patch'
8
- KatakataIrb::RubyLexPatch.patch_to_ruby_lex
9
- end
10
- require 'katakata_irb'
11
- KatakataIrb.repl
@@ -1,43 +0,0 @@
1
- module KatakataIrb; end
2
- module KatakataIrb::RelinePatch
3
- module RelinePatchIseqLoader; end
4
- def self.require_patched_reline
5
- # Apply patches of unmerged pull-request to reline
6
- patches = %w[wholelines escapeseq indent fullwidth raw scrollbar]
7
- patched = {}
8
- require 'reline/version.rb' # result of $LOAD_PATH.resolve_feature_path will change after this require
9
- patches.each do |patch_name|
10
- patch = File.read File.expand_path("reline_patches/#{patch_name}.patch", File.dirname(__FILE__))
11
- current_patched = {}
12
- patch.gsub(/^diff.+\nindex.+$/, '').split(/^--- a(.+)\n\+\+\+ b(.+)\n/).drop(1).each_slice(3) do |file, newfile, diff|
13
- raise if file != newfile
14
- _, path = $LOAD_PATH.resolve_feature_path file.sub(%r{^/lib/}, '')
15
- code = current_patched[path] || patched[path] || File.read(path)
16
- diff.split(/^@@.+\n/).drop(1).map(&:lines).each do |lines|
17
- target = lines.reject { _1[0] == '+' }.map { _1[1..] }.join
18
- replace = lines.reject { _1[0] == '-' }.map { _1[1..] }.join
19
- if code.include? target
20
- code = code.sub target, replace
21
- elsif !code.include?(replace)
22
- raise
23
- end
24
- end
25
- current_patched[path] = code
26
- end
27
- patched.update current_patched
28
- rescue
29
- KatakataIrb.log_puts "Failed to apply katakata_irb/reline_patches/#{patch_name}.patch to reline"
30
- end
31
-
32
- RelinePatchIseqLoader.define_method :load_iseq do |fname|
33
- if patched.key? fname
34
- RubyVM::InstructionSequence.compile patched[fname], fname
35
- else
36
- RubyVM::InstructionSequence.compile_file fname
37
- end
38
- end
39
- RubyVM::InstructionSequence.singleton_class.prepend RelinePatchIseqLoader
40
- require 'reline'
41
- RelinePatchIseqLoader.undef_method :load_iseq
42
- end
43
- end
@@ -1,45 +0,0 @@
1
- diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb
2
- index 1c33a4b..bbf5e6c 100644
3
- --- a/lib/reline/line_editor.rb
4
- +++ b/lib/reline/line_editor.rb
5
- @@ -663,8 +663,10 @@ class Reline::LineEditor
6
- dialog.set_cursor_pos(cursor_column, @first_line_started_from + @started_from)
7
- dialog_render_info = dialog.call(@last_key)
8
- if dialog_render_info.nil? or dialog_render_info.contents.nil? or dialog_render_info.contents.empty?
9
- + lines = whole_lines
10
- dialog.lines_backup = {
11
- - lines: modify_lines(whole_lines),
12
- + unmodified_lines: lines,
13
- + lines: modify_lines(lines),
14
- line_index: @line_index,
15
- first_line_started_from: @first_line_started_from,
16
- started_from: @started_from,
17
- @@ -766,8 +768,10 @@ class Reline::LineEditor
18
- Reline::IOGate.move_cursor_column(cursor_column)
19
- move_cursor_up(dialog.vertical_offset + dialog.contents.size - 1)
20
- Reline::IOGate.show_cursor
21
- + lines = whole_lines
22
- dialog.lines_backup = {
23
- - lines: modify_lines(whole_lines),
24
- + unmodified_lines: lines,
25
- + lines: modify_lines(lines),
26
- line_index: @line_index,
27
- first_line_started_from: @first_line_started_from,
28
- started_from: @started_from,
29
- @@ -777,7 +781,7 @@ class Reline::LineEditor
30
- private def reset_dialog(dialog, old_dialog)
31
- return if dialog.lines_backup.nil? or old_dialog.contents.nil?
32
- - prompt, prompt_width, prompt_list = check_multiline_prompt(dialog.lines_backup[:lines])
33
- + prompt, prompt_width, prompt_list = check_multiline_prompt(dialog.lines_backup[:unmodified_lines])
34
- visual_lines = []
35
- visual_start = nil
36
- dialog.lines_backup[:lines].each_with_index { |l, i|
37
- @@ -888,7 +892,7 @@ class Reline::LineEditor
38
- private def clear_each_dialog(dialog)
39
- dialog.trap_key = nil
40
- return unless dialog.contents
41
- - prompt, prompt_width, prompt_list = check_multiline_prompt(dialog.lines_backup[:lines])
42
- + prompt, prompt_width, prompt_list = check_multiline_prompt(dialog.lines_backup[:unmodified_lines])
43
- visual_lines = []
44
- visual_lines_under_dialog = []
45
- visual_start = nil
@@ -1,200 +0,0 @@
1
- diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb
2
- index c9e613e..6acf969 100644
3
- --- a/lib/reline/line_editor.rb
4
- +++ b/lib/reline/line_editor.rb
5
- @@ -748,3 +741,3 @@ class Reline::LineEditor
6
- end
7
- str_width = dialog.width - (dialog.scrollbar_pos.nil? ? 0 : @block_elem_width)
8
- - str = padding_space_with_escape_sequences(Reline::Unicode.take_range(item, 0, str_width), str_width)
9
- + str, = Reline::Unicode.take_range(item, 0, str_width, padding: true)
10
- @@ -793,85 +786,42 @@ class Reline::LineEditor
11
- end
12
- visual_lines.concat(vl)
13
- }
14
- - old_y = dialog.lines_backup[:first_line_started_from] + dialog.lines_backup[:started_from]
15
- - y = @first_line_started_from + @started_from
16
- - y_diff = y - old_y
17
- - if (old_y + old_dialog.vertical_offset) < (y + dialog.vertical_offset)
18
- - # rerender top
19
- - move_cursor_down(old_dialog.vertical_offset - y_diff)
20
- - start = visual_start + old_dialog.vertical_offset
21
- - line_num = dialog.vertical_offset - old_dialog.vertical_offset
22
- - line_num.times do |i|
23
- - Reline::IOGate.move_cursor_column(old_dialog.column)
24
- - if visual_lines[start + i].nil?
25
- - s = ' ' * old_dialog.width
26
- - else
27
- - s = Reline::Unicode.take_range(visual_lines[start + i], old_dialog.column, old_dialog.width)
28
- - s = padding_space_with_escape_sequences(s, old_dialog.width)
29
- - end
30
- - @output.write "\e[0m#{s}\e[0m"
31
- - move_cursor_down(1) if i < (line_num - 1)
32
- - end
33
- - move_cursor_up(old_dialog.vertical_offset + line_num - 1 - y_diff)
34
- - end
35
- - if (old_y + old_dialog.vertical_offset + old_dialog.contents.size) > (y + dialog.vertical_offset + dialog.contents.size)
36
- - # rerender bottom
37
- - move_cursor_down(dialog.vertical_offset + dialog.contents.size - y_diff)
38
- - start = visual_start + dialog.vertical_offset + dialog.contents.size
39
- - line_num = (old_dialog.vertical_offset + old_dialog.contents.size) - (dialog.vertical_offset + dialog.contents.size)
40
- - line_num.times do |i|
41
- - Reline::IOGate.move_cursor_column(old_dialog.column)
42
- - if visual_lines[start + i].nil?
43
- - s = ' ' * old_dialog.width
44
- - else
45
- - s = Reline::Unicode.take_range(visual_lines[start + i], old_dialog.column, old_dialog.width)
46
- - s = padding_space_with_escape_sequences(s, old_dialog.width)
47
- + old_dialog_y = dialog.lines_backup[:first_line_started_from] + dialog.lines_backup[:started_from]
48
- + dialog_y = @first_line_started_from + @started_from
49
- +
50
- + x_range = dialog.column...dialog.column + dialog.width
51
- + old_x_range = old_dialog.column...old_dialog.column + old_dialog.width
52
- + y_range = dialog_y + dialog.vertical_offset...dialog_y + dialog.vertical_offset + dialog.contents.size
53
- + old_y_range = old_dialog_y + old_dialog.vertical_offset...old_dialog_y + old_dialog.vertical_offset + old_dialog.contents.size
54
- +
55
- + cursor_y = dialog_y
56
- + old_y_range.each do |y|
57
- + rerender_ranges = []
58
- + if y_range.cover?(y) && x_range.any?(old_x_range)
59
- + if old_x_range.begin < x_range.begin
60
- + # rerender left
61
- + rerender_ranges << [old_x_range.begin...[old_x_range.end, x_range.begin].min, true, false]
62
- end
63
- - @output.write "\e[0m#{s}\e[0m"
64
- - move_cursor_down(1) if i < (line_num - 1)
65
- - end
66
- - move_cursor_up(dialog.vertical_offset + dialog.contents.size + line_num - 1 - y_diff)
67
- - end
68
- - if old_dialog.column < dialog.column
69
- - # rerender left
70
- - move_cursor_down(old_dialog.vertical_offset - y_diff)
71
- - width = dialog.column - old_dialog.column
72
- - start = visual_start + old_dialog.vertical_offset
73
- - line_num = old_dialog.contents.size
74
- - line_num.times do |i|
75
- - Reline::IOGate.move_cursor_column(old_dialog.column)
76
- - if visual_lines[start + i].nil?
77
- - s = ' ' * width
78
- - else
79
- - s = Reline::Unicode.take_range(visual_lines[start + i], old_dialog.column, width)
80
- - s = padding_space_with_escape_sequences(s, dialog.width)
81
- + if x_range.end < old_x_range.end
82
- + # rerender right
83
- + rerender_ranges << [[x_range.end, old_x_range.begin].max...old_x_range.end, false, true]
84
- end
85
- + else
86
- + rerender_ranges << [old_x_range, true, true]
87
- + end
88
- +
89
- + rerender_ranges.each do |range, cover_begin, cover_end|
90
- + move_cursor_down(y - cursor_y)
91
- + cursor_y = y
92
- + col = range.begin
93
- + width = range.end - range.begin
94
- + line = visual_lines[y + visual_start - old_dialog_y] || ''
95
- + s, col = Reline::Unicode.take_range(line, col, width, cover_begin: cover_begin, cover_end: cover_end, padding: true)
96
- + Reline::IOGate.move_cursor_column(col)
97
- @output.write "\e[0m#{s}\e[0m"
98
- - move_cursor_down(1) if i < (line_num - 1)
99
- - end
100
- - move_cursor_up(old_dialog.vertical_offset + line_num - 1 - y_diff)
101
- - end
102
- - if (old_dialog.column + old_dialog.width) > (dialog.column + dialog.width)
103
- - # rerender right
104
- - move_cursor_down(old_dialog.vertical_offset + y_diff)
105
- - width = (old_dialog.column + old_dialog.width) - (dialog.column + dialog.width)
106
- - start = visual_start + old_dialog.vertical_offset
107
- - line_num = old_dialog.contents.size
108
- - line_num.times do |i|
109
- - Reline::IOGate.move_cursor_column(old_dialog.column + dialog.width)
110
- - if visual_lines[start + i].nil?
111
- - s = ' ' * width
112
- - else
113
- - s = Reline::Unicode.take_range(visual_lines[start + i], old_dialog.column + dialog.width, width)
114
- - rerender_width = old_dialog.width - dialog.width
115
- - s = padding_space_with_escape_sequences(s, rerender_width)
116
- - end
117
- - Reline::IOGate.move_cursor_column(dialog.column + dialog.width)
118
- - @output.write "\e[0m#{s}\e[0m"
119
- - move_cursor_down(1) if i < (line_num - 1)
120
- end
121
- - move_cursor_up(old_dialog.vertical_offset + line_num - 1 + y_diff)
122
- end
123
- + move_cursor_up(cursor_y - dialog_y)
124
- Reline::IOGate.move_cursor_column((prompt_width + @cursor) % @screen_size.last)
125
- end
126
-
127
- @@ -912,9 +862,8 @@ class Reline::LineEditor
128
- dialog_vertical_size = dialog.contents.size
129
- dialog_vertical_size.times do |i|
130
- if i < visual_lines_under_dialog.size
131
- - Reline::IOGate.move_cursor_column(dialog.column)
132
- - str = Reline::Unicode.take_range(visual_lines_under_dialog[i], dialog.column, dialog.width)
133
- - str = padding_space_with_escape_sequences(str, dialog.width)
134
- + str, start_pos = Reline::Unicode.take_range(visual_lines_under_dialog[i], dialog.column, dialog.width, cover_begin: true, cover_end: true, padding: true)
135
- + Reline::IOGate.move_cursor_column(start_pos)
136
- @output.write "\e[0m#{str}\e[0m"
137
- else
138
- Reline::IOGate.move_cursor_column(dialog.column)
139
- diff --git a/lib/reline/unicode.rb b/lib/reline/unicode.rb
140
- index 6000c9f..03074dd 100644
141
- --- a/lib/reline/unicode.rb
142
- +++ b/lib/reline/unicode.rb
143
- @@ -194,17 +194,21 @@ class Reline::Unicode
144
- end
145
-
146
- # Take a chunk of a String cut by width with escape sequences.
147
- - def self.take_range(str, start_col, max_width, encoding = str.encoding)
148
- + def self.take_range(str, start_col, width, encoding: str.encoding, cover_begin: false, cover_end: false, padding: false)
149
- chunk = String.new(encoding: encoding)
150
- total_width = 0
151
- rest = str.encode(Encoding::UTF_8)
152
- in_zero_width = false
153
- + chunk_start_col = nil
154
- + chunk_end_col = nil
155
- rest.scan(WIDTH_SCANNER) do |gc|
156
- case
157
- when gc[NON_PRINTING_START_INDEX]
158
- in_zero_width = true
159
- + chunk << NON_PRINTING_START
160
- when gc[NON_PRINTING_END_INDEX]
161
- in_zero_width = false
162
- + chunk << NON_PRINTING_END
163
- when gc[CSI_REGEXP_INDEX]
164
- chunk << gc[CSI_REGEXP_INDEX]
165
- when gc[OSC_REGEXP_INDEX]
166
- @@ -215,13 +219,31 @@ class Reline::Unicode
167
- chunk << gc
168
- else
169
- mbchar_width = get_mbchar_width(gc)
170
- + prev_width = total_width
171
- total_width += mbchar_width
172
- - break if (start_col + max_width) < total_width
173
- - chunk << gc if start_col < total_width
174
- + break if !cover_end && total_width > start_col + width
175
- + if cover_begin ? start_col < total_width : start_col <= prev_width
176
- + chunk << gc
177
- + chunk_start_col ||= prev_width
178
- + chunk_end_col = total_width
179
- + end
180
- + break if total_width >= start_col + width
181
- end
182
- end
183
- end
184
- - chunk
185
- + chunk_start_col ||= start_col
186
- + chunk_end_col ||= start_col
187
- + if padding
188
- + if start_col < chunk_start_col
189
- + chunk = ' ' * (chunk_start_col - start_col) + chunk
190
- + chunk_start_col = start_col
191
- + end
192
- + if chunk_end_col < start_col + width
193
- + chunk << ' ' * (start_col + width - chunk_end_col)
194
- + chunk_end_col = start_col + width
195
- + end
196
- + end
197
- + [chunk, chunk_start_col, chunk_end_col - chunk_start_col]
198
- end
199
-
200
- def self.get_next_mbchar_size(line, byte_pointer)
@@ -1,25 +0,0 @@
1
- diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb
2
- index bbf5e6c..c9e613e 100644
3
- --- a/lib/reline/line_editor.rb
4
- +++ b/lib/reline/line_editor.rb
5
- @@ -1707,17 +1707,18 @@ class Reline::LineEditor
6
- end
7
- new_lines = whole_lines
8
- new_indent = @auto_indent_proc.(new_lines, @line_index, @byte_pointer, @check_new_auto_indent)
9
- - new_indent = @cursor_max if new_indent&.> @cursor_max
10
- if new_indent&.>= 0
11
- md = new_lines[@line_index].match(/\A */)
12
- prev_indent = md[0].count(' ')
13
- if @check_new_auto_indent
14
- - @buffer_of_lines[@line_index] = ' ' * new_indent + @buffer_of_lines[@line_index].lstrip
15
- + line = @buffer_of_lines[@line_index] = ' ' * new_indent + @buffer_of_lines[@line_index].lstrip
16
- @cursor = new_indent
17
- + @cursor_max = calculate_width(line)
18
- @byte_pointer = new_indent
19
- else
20
- @line = ' ' * new_indent + @line.lstrip
21
- @cursor += new_indent - prev_indent
22
- + @cursor_max = calculate_width(@line)
23
- @byte_pointer += new_indent - prev_indent
24
- end
25
- end
@@ -1,95 +0,0 @@
1
- diff --git a/lib/reline.rb b/lib/reline.rb
2
- index f22b573..8716a0c 100644
3
- --- a/lib/reline.rb
4
- +++ b/lib/reline.rb
5
- @@ -281,19 +281,21 @@ module Reline
6
- Reline::DEFAULT_DIALOG_CONTEXT = Array.new
7
-
8
- def readmultiline(prompt = '', add_hist = false, &confirm_multiline_termination)
9
- - unless confirm_multiline_termination
10
- - raise ArgumentError.new('#readmultiline needs block to confirm multiline termination')
11
- - end
12
- - inner_readline(prompt, add_hist, true, &confirm_multiline_termination)
13
- + Reline::IOGate.with_raw_input do
14
- + unless confirm_multiline_termination
15
- + raise ArgumentError.new('#readmultiline needs block to confirm multiline termination')
16
- + end
17
- + inner_readline(prompt, add_hist, true, &confirm_multiline_termination)
18
-
19
- - whole_buffer = line_editor.whole_buffer.dup
20
- - whole_buffer.taint if RUBY_VERSION < '2.7'
21
- - if add_hist and whole_buffer and whole_buffer.chomp("\n").size > 0
22
- - Reline::HISTORY << whole_buffer
23
- - end
24
- + whole_buffer = line_editor.whole_buffer.dup
25
- + whole_buffer.taint if RUBY_VERSION < '2.7'
26
- + if add_hist and whole_buffer and whole_buffer.chomp("\n").size > 0
27
- + Reline::HISTORY << whole_buffer
28
- + end
29
-
30
- - line_editor.reset_line if line_editor.whole_buffer.nil?
31
- - whole_buffer
32
- + line_editor.reset_line if line_editor.whole_buffer.nil?
33
- + whole_buffer
34
- + end
35
- end
36
-
37
- def readline(prompt = '', add_hist = false)
38
- diff --git a/lib/reline/ansi.rb b/lib/reline/ansi.rb
39
- index ab147a6..ccebe15 100644
40
- --- a/lib/reline/ansi.rb
41
- +++ b/lib/reline/ansi.rb
42
- @@ -142,6 +142,10 @@ class Reline::ANSI
43
- @@output = val
44
- end
45
-
46
- + def self.with_raw_input
47
- + @@input.raw { yield }
48
- + end
49
- +
50
- @@buf = []
51
- def self.inner_getc
52
- unless @@buf.empty?
53
- diff --git a/lib/reline/general_io.rb b/lib/reline/general_io.rb
54
- index 92c76cb..9929846 100644
55
- --- a/lib/reline/general_io.rb
56
- +++ b/lib/reline/general_io.rb
57
- @@ -31,6 +31,10 @@ class Reline::GeneralIO
58
- @@input = val
59
- end
60
-
61
- + def self.with_raw_input
62
- + yield
63
- + end
64
- +
65
- def self.getc
66
- unless @@buf.empty?
67
- return @@buf.shift
68
- diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb
69
- index 6acf969..e3985a3 100644
70
- --- a/lib/reline/line_editor.rb
71
- +++ b/lib/reline/line_editor.rb
72
- @@ -452,7 +452,7 @@ class Reline::LineEditor
73
- new_lines = whole_lines
74
- prompt, prompt_width, prompt_list = check_multiline_prompt(new_lines)
75
- modify_lines(new_lines).each_with_index do |line, index|
76
- - @output.write "#{prompt_list ? prompt_list[index] : prompt}#{line}\n"
77
- + @output.write "#{prompt_list ? prompt_list[index] : prompt}#{line}\r\n"
78
- Reline::IOGate.erase_after_cursor
79
- end
80
- @output.flush
81
- diff --git a/lib/reline/windows.rb b/lib/reline/windows.rb
82
- index b952329..7ea2a00 100644
83
- --- a/lib/reline/windows.rb
84
- +++ b/lib/reline/windows.rb
85
- @@ -291,6 +291,10 @@ class Reline::Windows
86
- end
87
- end
88
-
89
- + def self.with_raw_input
90
- + yield
91
- + end
92
- +
93
- def self.getc
94
- check_input_event
95
- @@output_buf.shift
@@ -1,43 +0,0 @@
1
- diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb
2
- index e3985a3..8d785db 100644
3
- --- a/lib/reline/line_editor.rb
4
- +++ b/lib/reline/line_editor.rb
5
- @@ -680,6 +680,9 @@ class Reline::LineEditor
6
- end
7
- height = dialog_render_info.height || DIALOG_DEFAULT_HEIGHT
8
- height = dialog.contents.size if dialog.contents.size < height
9
- + if dialog.scroll_top >= dialog.contents.size - height
10
- + dialog.scroll_top = dialog.contents.size - height
11
- + end
12
- if dialog.contents.size > height
13
- if dialog.pointer
14
- if dialog.pointer < 0
15
- @@ -690,17 +693,20 @@ class Reline::LineEditor
16
- dialog.scroll_top = dialog.pointer
17
- end
18
- pointer = dialog.pointer - dialog.scroll_top
19
- + else
20
- + dialog.scroll_top = 0
21
- end
22
- dialog.contents = dialog.contents[dialog.scroll_top, height]
23
- end
24
- - if dialog.contents and dialog.scroll_top >= dialog.contents.size
25
- - dialog.scroll_top = dialog.contents.size - height
26
- + if dialog_render_info.contents and dialog.scroll_top > dialog_render_info.contents.size - height
27
- + dialog.scroll_top = dialog_render_info.contents.size - height
28
- end
29
- if dialog_render_info.scrollbar and dialog_render_info.contents.size > height
30
- bar_max_height = height * 2
31
- moving_distance = (dialog_render_info.contents.size - height) * 2
32
- position_ratio = dialog.scroll_top.zero? ? 0.0 : ((dialog.scroll_top * 2).to_f / moving_distance)
33
- bar_height = (bar_max_height * ((dialog.contents.size * 2).to_f / (dialog_render_info.contents.size * 2))).floor.to_i
34
- + bar_height = 1 if bar_height.zero?
35
- dialog.scrollbar_pos = ((bar_max_height - bar_height) * position_ratio).floor.to_i
36
- else
37
- dialog.scrollbar_pos = nil
38
- @@ -745,4 +751,4 @@ class Reline::LineEditor
39
- - if dialog.scrollbar_pos and (dialog.scrollbar_pos != old_dialog.scrollbar_pos or dialog.column != old_dialog.column)
40
- + if dialog.scrollbar_pos
41
- @output.write "\e[37m"
42
- if dialog.scrollbar_pos <= (i * 2) and (i * 2 + 1) < (dialog.scrollbar_pos + bar_height)
43
- @output.write @full_block
@@ -1,102 +0,0 @@
1
- diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb
2
- index 8153aab..1c33a4b 100644
3
- --- a/lib/reline/line_editor.rb
4
- +++ b/lib/reline/line_editor.rb
5
- @@ -449,12 +449,8 @@ class Reline::LineEditor
6
- Reline::IOGate.move_cursor_up(@first_line_started_from + @started_from - @scroll_partial_screen)
7
- Reline::IOGate.move_cursor_column(0)
8
- @scroll_partial_screen = nil
9
- - prompt, prompt_width, prompt_list = check_multiline_prompt(whole_lines)
10
- - if @previous_line_index
11
- - new_lines = whole_lines(index: @previous_line_index, line: @line)
12
- - else
13
- - new_lines = whole_lines
14
- - end
15
- + new_lines = whole_lines
16
- + prompt, prompt_width, prompt_list = check_multiline_prompt(new_lines)
17
- modify_lines(new_lines).each_with_index do |line, index|
18
- @output.write "#{prompt_list ? prompt_list[index] : prompt}#{line}\n"
19
- Reline::IOGate.erase_after_cursor
20
- @@ -490,11 +486,7 @@ class Reline::LineEditor
21
- if @is_multiline
22
- if finished?
23
- # Always rerender on finish because output_modifier_proc may return a different output.
24
- - if @previous_line_index
25
- - new_lines = whole_lines(index: @previous_line_index, line: @line)
26
- - else
27
- - new_lines = whole_lines
28
- - end
29
- + new_lines = whole_lines
30
- line = modify_lines(new_lines)[@line_index]
31
- clear_dialog
32
- prompt, prompt_width, prompt_list = check_multiline_prompt(new_lines)
33
- @@ -1013,11 +1005,7 @@ class Reline::LineEditor
34
- end
35
-
36
- private def rerender_changed_current_line
37
- - if @previous_line_index
38
- - new_lines = whole_lines(index: @previous_line_index, line: @line)
39
- - else
40
- - new_lines = whole_lines
41
- - end
42
- + new_lines = whole_lines
43
- prompt, prompt_width, prompt_list = check_multiline_prompt(new_lines)
44
- all_height = calculate_height_by_lines(new_lines, prompt_list || prompt)
45
- diff = all_height - @highest_in_all
46
- @@ -1698,7 +1686,7 @@ class Reline::LineEditor
47
- return if not @check_new_auto_indent and @previous_line_index # move cursor up or down
48
- if @check_new_auto_indent and @previous_line_index and @previous_line_index > 0 and @line_index > @previous_line_index
49
- # Fix indent of a line when a newline is inserted to the next
50
- - new_lines = whole_lines(index: @previous_line_index, line: @line)
51
- + new_lines = whole_lines
52
- new_indent = @auto_indent_proc.(new_lines[0..-3].push(''), @line_index - 1, 0, true)
53
- md = @line.match(/\A */)
54
- prev_indent = md[0].count(' ')
55
- @@ -1713,11 +1701,7 @@ class Reline::LineEditor
56
- @line = ' ' * new_indent + @line.lstrip
57
- end
58
- end
59
- - if @previous_line_index
60
- - new_lines = whole_lines(index: @previous_line_index, line: @line)
61
- - else
62
- - new_lines = whole_lines
63
- - end
64
- + new_lines = whole_lines
65
- new_indent = @auto_indent_proc.(new_lines, @line_index, @byte_pointer, @check_new_auto_indent)
66
- new_indent = @cursor_max if new_indent&.> @cursor_max
67
- if new_indent&.>= 0
68
- @@ -1803,11 +1787,7 @@ class Reline::LineEditor
69
- target = before
70
- end
71
- if @is_multiline
72
- - if @previous_line_index
73
- - lines = whole_lines(index: @previous_line_index, line: @line)
74
- - else
75
- - lines = whole_lines
76
- - end
77
- + lines = whole_lines
78
- if @line_index > 0
79
- preposing = lines[0..(@line_index - 1)].join("\n") + "\n" + preposing
80
- end
81
- @@ -1907,7 +1887,7 @@ class Reline::LineEditor
82
- @cursor_max = calculate_width(@line)
83
- end
84
-
85
- - def whole_lines(index: @line_index, line: @line)
86
- + def whole_lines(index: @previous_line_index || @line_index, line: @line)
87
- temp_lines = @buffer_of_lines.dup
88
- temp_lines[index] = line
89
- temp_lines
90
- @@ -1917,11 +1897,7 @@ class Reline::LineEditor
91
- if @buffer_of_lines.size == 1 and @line.nil?
92
- nil
93
- else
94
- - if @previous_line_index
95
- - whole_lines(index: @previous_line_index, line: @line).join("\n")
96
- - else
97
- - whole_lines.join("\n")
98
- - end
99
- + whole_lines.join("\n")
100
- end
101
- end
102
-