mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Use IRB.conf[:AUTO_INDENT] setting in multiline mode
This commit is contained in:
parent
c972932986
commit
d009e321a0
3 changed files with 23 additions and 18 deletions
|
@ -491,6 +491,8 @@ module IRB
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@scanner.set_auto_indent(@context) if @context.auto_indent_mode
|
||||||
|
|
||||||
@scanner.each_top_level_statement do |line, line_no|
|
@scanner.each_top_level_statement do |line, line_no|
|
||||||
signal_status(:IN_EVAL) do
|
signal_status(:IN_EVAL) do
|
||||||
begin
|
begin
|
||||||
|
|
|
@ -255,7 +255,7 @@ module IRB
|
||||||
Reline.input = @stdin
|
Reline.input = @stdin
|
||||||
Reline.output = @stdout
|
Reline.output = @stdout
|
||||||
Reline.prompt_proc = @prompt_proc
|
Reline.prompt_proc = @prompt_proc
|
||||||
Reline.auto_indent_proc = @auto_indent_proc
|
Reline.auto_indent_proc = @auto_indent_proc if @auto_indent_proc
|
||||||
if l = readmultiline(@prompt, false, &@check_termination_proc)
|
if l = readmultiline(@prompt, false, &@check_termination_proc)
|
||||||
HISTORY.push(l) if !l.empty?
|
HISTORY.push(l) if !l.empty?
|
||||||
@line[@line_no += 1] = l + "\n"
|
@line[@line_no += 1] = l + "\n"
|
||||||
|
|
|
@ -53,7 +53,26 @@ class RubyLex
|
||||||
result
|
result
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if @io.respond_to?(:auto_indent)
|
if p.respond_to?(:call)
|
||||||
|
@input = p
|
||||||
|
elsif block_given?
|
||||||
|
@input = block
|
||||||
|
else
|
||||||
|
@input = Proc.new{@io.gets}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def set_prompt(p = nil, &block)
|
||||||
|
p = block if block_given?
|
||||||
|
if p.respond_to?(:call)
|
||||||
|
@prompt = p
|
||||||
|
else
|
||||||
|
@prompt = Proc.new{print p}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def set_auto_indent(context)
|
||||||
|
if @io.respond_to?(:auto_indent) and context.auto_indent_mode
|
||||||
@io.auto_indent do |lines, line_index, byte_pointer, is_newline|
|
@io.auto_indent do |lines, line_index, byte_pointer, is_newline|
|
||||||
if is_newline
|
if is_newline
|
||||||
md = lines[line_index - 1].match(/(\A +)/)
|
md = lines[line_index - 1].match(/(\A +)/)
|
||||||
|
@ -82,22 +101,6 @@ class RubyLex
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if p.respond_to?(:call)
|
|
||||||
@input = p
|
|
||||||
elsif block_given?
|
|
||||||
@input = block
|
|
||||||
else
|
|
||||||
@input = Proc.new{@io.gets}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def set_prompt(p = nil, &block)
|
|
||||||
p = block if block_given?
|
|
||||||
if p.respond_to?(:call)
|
|
||||||
@prompt = p
|
|
||||||
else
|
|
||||||
@prompt = Proc.new{print p}
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_state(code)
|
def check_state(code)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue