diff --git a/lib/pry/cli.rb b/lib/pry/cli.rb index f20c10fac..89b29c038 100644 --- a/lib/pry/cli.rb +++ b/lib/pry/cli.rb @@ -145,6 +145,10 @@ def start(opts) Pry.config.color = false end + on "no-multiline", "Disables multiline (Multiline defaults to true when using Reline)" do + Pry.config.multiline = false + end + on :f, "Suppress loading of pryrc" do Pry.config.should_load_rc = false Pry.config.should_load_local_rc = false diff --git a/lib/pry/config.rb b/lib/pry/config.rb index cb9e79f05..247f9e9fc 100644 --- a/lib/pry/config.rb +++ b/lib/pry/config.rb @@ -65,6 +65,9 @@ class Config # @return [Boolean] attribute :pager + # @return [Boolean] + attribute :multiline + # @return [Boolean] whether the global ~/.pryrc should be loaded attribute :should_load_rc @@ -176,6 +179,7 @@ def initialize hooks: Pry::Hooks.default, pager: true, system: Pry::SystemCommandHandler.method(:default), + multiline: true, color: Pry::Helpers::BaseHelpers.use_ansi_codes?, default_window_size: 5, editor: Pry::Editor.default, diff --git a/lib/pry/repl.rb b/lib/pry/repl.rb index 540e56ec6..568d7de1b 100644 --- a/lib/pry/repl.rb +++ b/lib/pry/repl.rb @@ -180,7 +180,29 @@ def read_line(current_prompt) end if reline_available? - input_reline(current_prompt) + Reline.output_modifier_proc = lambda do |text, _| + if pry.color + SyntaxHighlighter.highlight(text) + else + text + end + end + + if pry.config.auto_indent + Reline.auto_indent_proc = lambda do |lines, line_index, _byte_pointer, _newline| + if line_index == 0 + 0 + else + pry_indentation = Pry::Indent.new + pry_indentation.indent(lines.join("\n")) + pry_indentation.last_indent_level.length + end + end + end + end + + if reline_available? && pry.config.multiline + input_readmultiline(current_prompt) elsif readline_available? set_readline_output input_readline(current_prompt, false) # false since we'll add it manually @@ -194,27 +216,7 @@ def read_line(current_prompt) end end - def input_reline(*args) - Reline.output_modifier_proc = lambda do |text, _| - if pry.color - SyntaxHighlighter.highlight(text) - else - text - end - end - - if pry.config.auto_indent - Reline.auto_indent_proc = lambda do |lines, line_index, _byte_pointer, _newline| - if line_index == 0 - 0 - else - pry_indentation = Pry::Indent.new - pry_indentation.indent(lines.join("\n")) - pry_indentation.last_indent_level.length - end - end - end - + def input_readmultiline(*args) Pry::InputLock.for(:all).interruptible_region do input.readmultiline(*args) do |multiline_input| Pry.commands.find_command(multiline_input) ||