Stream output of hist
This commit is contained in:
parent
e18bb8bf53
commit
07b6e96883
|
@ -309,14 +309,22 @@ class Pry
|
|||
# @return [String] a formatted representation (based on the configuration of
|
||||
# the object).
|
||||
def to_s
|
||||
@lines.map { |loc|
|
||||
print_to_output("")
|
||||
end
|
||||
|
||||
# Writes a formatted representation (based on the configuration of the
|
||||
# object) to the given output, which must respond to `#<<`.
|
||||
def print_to_output(output)
|
||||
@lines.each do |loc|
|
||||
loc = loc.dup
|
||||
loc.colorize(@code_type) if Pry.color
|
||||
loc.add_line_number(max_lineno_width) if @with_line_numbers
|
||||
loc.add_marker(@marker_lineno) if @with_marker
|
||||
loc.indent(@indentation_num) if @with_indentation
|
||||
loc.line
|
||||
}.join("\n") + "\n"
|
||||
output << loc.line
|
||||
output << "\n"
|
||||
end
|
||||
output
|
||||
end
|
||||
|
||||
# Get the comment that describes the expression on the given line number.
|
||||
|
|
|
@ -30,7 +30,6 @@ class Pry
|
|||
opt.on :save, "Save history to a file", :argument => true, :as => Range
|
||||
opt.on :e, :'exclude-pry', "Exclude Pry commands from the history"
|
||||
opt.on :n, :'no-numbers', "Omit line numbers"
|
||||
opt.on :f, :flood, "Do not use a pager to view text longer than one screen"
|
||||
end
|
||||
|
||||
def process
|
||||
|
@ -79,7 +78,9 @@ class Pry
|
|||
@history = @history.with_line_numbers
|
||||
end
|
||||
|
||||
render_output(@history, opts)
|
||||
Pry::Pager.with_pager(output) do |pager|
|
||||
@history.print_to_output(pager)
|
||||
end
|
||||
end
|
||||
|
||||
def process_save
|
||||
|
|
|
@ -15,14 +15,6 @@ class Pry
|
|||
file.close(true) if file
|
||||
end
|
||||
|
||||
def render_output(str, opts={})
|
||||
if opts[:flood]
|
||||
output.puts str
|
||||
else
|
||||
stagger_output str
|
||||
end
|
||||
end
|
||||
|
||||
def internal_binding?(target)
|
||||
m = target.eval("::Kernel.__method__").to_s
|
||||
# class_eval is here because of http://jira.codehaus.org/browse/JRUBY-6753
|
||||
|
|
Loading…
Reference in New Issue