@@ -74,59 +74,6 @@ def set_input(&block)
74
74
@input = block
75
75
end
76
76
77
- def configure_io ( io )
78
- @io = io
79
- if @io . respond_to? ( :check_termination )
80
- @io . check_termination do |code |
81
- if Reline ::IOGate . in_pasting?
82
- rest = check_termination_in_prev_line ( code )
83
- if rest
84
- Reline . delete_text
85
- rest . bytes . reverse_each do |c |
86
- Reline . ungetc ( c )
87
- end
88
- true
89
- else
90
- false
91
- end
92
- else
93
- # Accept any single-line input for symbol aliases or commands that transform args
94
- next true if single_line_command? ( code )
95
-
96
- _tokens , _opens , terminated = check_code_state ( code )
97
- terminated
98
- end
99
- end
100
- end
101
- if @io . respond_to? ( :dynamic_prompt )
102
- @io . dynamic_prompt do |lines |
103
- lines << '' if lines . empty?
104
- tokens = self . class . ripper_lex_without_warning ( lines . map { |l | l + "\n " } . join , context : @context )
105
- line_results = IRB ::NestingParser . parse_by_line ( tokens )
106
- tokens_until_line = [ ]
107
- line_results . map . with_index do |( line_tokens , _prev_opens , next_opens , _min_depth ) , line_num_offset |
108
- line_tokens . each do |token , _s |
109
- # Avoid appending duplicated token. Tokens that include "\n" like multiline tstring_content can exist in multiple lines.
110
- tokens_until_line << token if token != tokens_until_line . last
111
- end
112
- continue = should_continue? ( tokens_until_line )
113
- prompt ( next_opens , continue , line_num_offset )
114
- end
115
- end
116
- end
117
-
118
- if @io . respond_to? ( :auto_indent ) and @context . auto_indent_mode
119
- @io . auto_indent do |lines , line_index , byte_pointer , is_newline |
120
- next nil if lines == [ nil ] # Workaround for exit IRB with CTRL+d
121
- next nil if !is_newline && lines [ line_index ] &.byteslice ( 0 , byte_pointer ) &.match? ( /\A \s *\z / )
122
-
123
- code = lines [ 0 ..line_index ] . map { |l | "#{ l } \n " } . join
124
- tokens = self . class . ripper_lex_without_warning ( code , context : @context )
125
- process_indent_level ( tokens , lines , line_index , is_newline )
126
- end
127
- end
128
- end
129
-
130
77
def set_prompt ( &block )
131
78
@prompt = block
132
79
end
@@ -240,7 +187,7 @@ def readmultiline
240
187
save_prompt_to_context_io ( [ ] , false , 0 )
241
188
242
189
# multiline
243
- return @input . call if @io . respond_to? ( :check_termination )
190
+ return @input . call if @context . io . respond_to? ( :check_termination )
244
191
245
192
# nomultiline
246
193
code = ''
@@ -270,7 +217,7 @@ def each_top_level_statement
270
217
break unless code
271
218
272
219
if code != "\n "
273
- code . force_encoding ( @io . encoding )
220
+ code . force_encoding ( @context . io . encoding )
274
221
yield code , @line_no , assignment_expression? ( code )
275
222
end
276
223
@line_no += code . count ( "\n " )
0 commit comments