-
-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Description
All of this stuff:
Lines 252 to 297 in 6901610
write(io::IO, s::Union{<:AnnotatedString, SubString{<:AnnotatedString}}) = | |
_ansi_writer(io, s, write)::Int | |
print(io::IO, s::Union{<:AnnotatedString, SubString{<:AnnotatedString}}) = | |
(write(io, s); nothing) | |
escape_string(io::IO, s::Union{<:AnnotatedString, SubString{<:AnnotatedString}}, | |
esc = ""; keep = ()) = | |
(_ansi_writer(io, s, (io, s) -> escape_string(io, s, esc; keep)); nothing) | |
function write(io::IO, c::AnnotatedChar) | |
if get(io, :color, false) == true | |
termstyle(io, getface(c), getface()) | |
bytes = write(io, c.char) | |
termstyle(io, getface(), getface(c)) | |
bytes | |
else | |
write(io, c.char) | |
end | |
end | |
print(io::IO, c::AnnotatedChar) = (write(io, c); nothing) | |
function show(io::IO, c::AnnotatedChar) | |
if get(io, :color, false) == true | |
out = IOBuffer() | |
show(out, c.char) | |
print(io, ''', AnnotatedString(String(take!(out)[2:end-1]), map(a -> (1:ncodeunits(c), a), c.annotations)), ''') | |
else | |
show(io, c.char) | |
end | |
end | |
function write(io::IO, aio::Base.AnnotatedIOBuffer) | |
if get(io, :color, false) == true | |
# This does introduce an overhead that technically | |
# could be avoided, but I'm not sure that it's currently | |
# worth the effort to implement an efficient version of | |
# writing from a AnnotatedIOBuffer with style. | |
# In the meantime, by converting to an `AnnotatedString` we can just | |
# reuse all the work done to make that work. | |
write(io, read(aio, AnnotatedString)) | |
else | |
write(io, aio.io) | |
end | |
end |
looks to be a pretty bad type piracy and should probably be moved to Base.
Metadata
Metadata
Assignees
Labels
No labels
Activity