Skip to content

Commit

Permalink
correctly overload show instead of print
Browse files Browse the repository at this point in the history
  • Loading branch information
KristofferC committed Sep 14, 2020
1 parent 4e673f7 commit ac51ef0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/crayon.jl
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ function Base.print(io::IO, x::Crayon)
end
end

function Base.show(io::IO, x::Crayon)
function Base.show(io::IO, ::MIME"text/plain", x::Crayon)
if anyactive(x)
print(io, x)
print(io, ESCAPED_CSI)
Expand Down
8 changes: 4 additions & 4 deletions src/crayon_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ function (c::Crayon)(args::Union{CrayonWrapper,AbstractString}...)
CrayonWrapper(c, typefix.(collect(args)))
end

Base.show(io::IO, cw::CrayonWrapper) = _show(io, cw, CrayonStack(incremental = true))
Base.print(io::IO, cw::CrayonWrapper) = _print(io, cw, CrayonStack(incremental = true))

_show(io::IO, str::String, stack::CrayonStack) = print(io, str)
_print(io::IO, str::String, stack::CrayonStack) = print(io, str)

function _show(io::IO, cw::CrayonWrapper, stack::CrayonStack)
function _print(io::IO, cw::CrayonWrapper, stack::CrayonStack)
print(io, push!(stack, cw.c))
for obj in cw.v
_show(io, obj, stack)
_print(io, obj, stack)
end
length(stack.crayons) > 1 && print(io, pop!(stack))
return
Expand Down

0 comments on commit ac51ef0

Please sign in to comment.