Skip to content

Commit

Permalink
more color resets + move input color append out ouf irb ext
Browse files Browse the repository at this point in the history
  • Loading branch information
janlelis committed Mar 17, 2015
1 parent d51f8e1 commit 120700f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
13 changes: 11 additions & 2 deletions lib/fancy_irb/implementation.rb
Expand Up @@ -93,6 +93,15 @@ def colorize(string, color)
Paint[string, *Array(color)]
end

# Note: No reset, relies on next one
def append_input_color(string)
if input_color = @options[:colorize][:input]
string + Paint.color(*Array(input_color))
else
string
end
end

# get_result and pass it into every format_output_proc
def get_output_from_irb_context(irb_context)
Array(@options[:output_procs]).inject(
Expand Down Expand Up @@ -136,7 +145,7 @@ def register_skipped_rockets(object_class, methods_)
def patch_stream(object, stream_name)
object.define_singleton_method :write do |data|
FancyIrb.track_height data
super FancyIrb.colorize(data, FancyIrb[:colorize, stream_name])
super Paint::NOTHING + FancyIrb.colorize(data, FancyIrb[:colorize, stream_name])
end
end

Expand All @@ -147,7 +156,7 @@ def register_error_capturer!
def present_and_clear_captured_error!
if @error_capturer
@error_capturer.restore_original_stdout
$stderr.puts colorize(
$stderr.puts Paint::NOTHING + colorize(
@error_capturer.error_string.chomp,
@options[:colorize][:irb_errors],
)
Expand Down
6 changes: 1 addition & 5 deletions lib/fancy_irb/irb_ext.rb
Expand Up @@ -39,11 +39,7 @@ def prompt(*args, &block)
colorized_prompt =
Paint::NOTHING + FancyIrb.colorize(prompt, FancyIrb[:colorize, :input_prompt])

if input_color = FancyIrb[:colorize, :input]
colorized_prompt + Paint.color(*Array(input_color)) # FIXME: No reset, relies on next one
else
colorized_prompt
end
FancyIrb.append_input_color(colorized_prompt)
end

# reset line and capture IRB errors (part 2)
Expand Down

0 comments on commit 120700f

Please sign in to comment.