Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,8 @@ Currently, the `@compat` macro supports the following syntaxes:
* `codeunits(s)` returns an array-like view of the `UInt8` code units of
a string and `ncodeunits(s)` returns the number of code units ([#25241]).

* `printstyled` prints to a given stream optionally in color and/or bolded ([#25522]).

* `Dates.Period` rounding (e.g., `round(Dates.Hour(36), Dates.Day, RoundNearestTiesUp) == Dates.Day(2)` ([#24182]).


Expand Down Expand Up @@ -513,6 +515,7 @@ includes this fix. Find the minimum version from there.
[#25458]: https://github.com/JuliaLang/julia/issues/25458
[#25459]: https://github.com/JuliaLang/julia/issues/25459
[#25496]: https://github.com/JuliaLang/julia/issues/25496
[#25522]: https://github.com/JuliaLang/julia/issues/25522
[#25544]: https://github.com/JuliaLang/julia/issues/25544
[#25545]: https://github.com/JuliaLang/julia/issues/25545
[#25571]: https://github.com/JuliaLang/julia/issues/25571
Expand Down
9 changes: 9 additions & 0 deletions src/Compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1509,6 +1509,15 @@ end
export lastindex
end

# 0.7.0-DEV.3585
@static if !isdefined(Base, :printstyled)
printstyled(io::IO, msg...; bold=false, color=:normal) =
Base.print_with_color(color, io, msg...; bold=bold)
printstyled(msg...; bold=false, color=:normal) =
Base.print_with_color(color, STDOUT, msg...; bold=bold)
export printstyled
end

include("deprecated.jl")

end # module Compat
13 changes: 13 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1305,4 +1305,17 @@ end
@test lastindex(zeros(4)) == 4
@test lastindex(zeros(4,4)) == 16

# 0.7.0-DEV.3585
let buf = IOBuffer()
if VERSION < v"0.7.0-DEV.3077"
col = Base.have_color
eval(Base, :(have_color = true))
printstyled(buf, "foo", color=:red)
eval(Base, :(have_color = $col))
else
printstyled(IOContext(buf, :color=>true), "foo", color=:red)
end
@test startswith(String(take!(buf)), Base.text_colors[:red])
end

nothing