| 168 | } |
| 169 | |
| 170 | void executeRubyRepl(ScriptEngineInstance& rubyEngine) { |
| 171 | |
| 172 | rubyEngine->exec("ARGV.clear"); |
| 173 | |
| 174 | const std::string cmd = R"ruby( |
| 175 | require 'irb' |
| 176 | require 'irb/lc/error' |
| 177 | |
| 178 | # ENV["IRB_LANG"] = "C" |
| 179 | # puts "Reline encoding_system_needs: #{Reline.encoding_system_needs.name}" |
| 180 | # puts "Reline::IOGate.encoding: #{Reline::IOGate.encoding}" |
| 181 | |
| 182 | # Workaround issue in line_editor.rb where it fails to read a full block |
| 183 | # unicode character. Probably because of the way we embbed it in C++ |
| 184 | # The full block is \xe2\x96\x88 |
| 185 | ENV['RELINE_ALT_SCROLLBAR'] = "1" |
| 186 | |
| 187 | class Reline::LineEditor |
| 188 | def reset(prompt = '', encoding:) |
| 189 | @rest_height = (Reline::IOGate.get_screen_size.first - 1) - Reline::IOGate.cursor_pos.y |
| 190 | @screen_size = Reline::IOGate.get_screen_size |
| 191 | @screen_height = @screen_size.first |
| 192 | reset_variables(prompt, encoding: encoding) |
| 193 | Reline::IOGate.set_winch_handler do |
| 194 | @resized = true |
| 195 | end |
| 196 | if ENV.key?('RELINE_ALT_SCROLLBAR') |
| 197 | @full_block = '::' |
| 198 | @upper_half_block = "''" |
| 199 | @lower_half_block = '..' |
| 200 | @block_elem_width = 2 |
| 201 | elsif Reline::IOGate.win? |
| 202 | @full_block = '█' |
| 203 | @upper_half_block = '▀' |
| 204 | @lower_half_block = '▄' |
| 205 | @block_elem_width = 1 |
| 206 | elsif @encoding == Encoding::UTF_8 |
| 207 | @full_block = '█' |
| 208 | @upper_half_block = '▀' |
| 209 | @lower_half_block = '▄' |
| 210 | @block_elem_width = Reline::Unicode.calculate_width('█') |
| 211 | else |
| 212 | @full_block = '::' |
| 213 | @upper_half_block = "''" |
| 214 | @lower_half_block = '..' |
| 215 | @block_elem_width = 2 |
| 216 | end |
| 217 | end |
| 218 | end |
| 219 | |
| 220 | module IRB # :nodoc: |
| 221 | class Locale |
| 222 | |
| 223 | alias :original_load :load |
| 224 | alias :original_require :require |
| 225 | |
| 226 | def require(file, priv = nil) |
| 227 | # puts "require: #{file}" |