Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

printstyled specialisation for AnnotatedIOBuffer #12

Merged
merged 1 commit into from
Feb 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/legacy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

module Legacy

using ..StyledStrings: SimpleColor, Face, loadface!
using ..StyledStrings: SimpleColor, Face, loadface!, face!

"""
A mapping from 256-color codes indicies to 8-bit colours.
Expand Down Expand Up @@ -112,4 +112,18 @@ function load_env_colors!()
end
end

function Base.printstyled(io::Base.AnnotatedIOBuffer, msg...;
bold::Bool=false, italic::Bool=false, underline::Bool=false,
blink::Bool=false, reverse::Bool=false, hidden::Bool=false,
color::Union{Symbol, Int}=:normal)
str = Base.annotatedstring(msg...)
bold && face!(str, :bold)
italic && face!(str, :italic)
underline && face!(str, :underline)
reverse && face!(str, Face(inverse=true))
color !== :normal && face!(str, Face(foreground=legacy_color(color)))
write(io, str)
nothing
end

end
Loading