Skip to content

Commit

Permalink
Add compat note for printstyled (#42547)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcabbott authored Oct 8, 2021
1 parent 55808a5 commit f2080d5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
4 changes: 3 additions & 1 deletion base/strings/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ avoid Julia-specific details.
For example, `show` displays strings with quotes, and `print` displays strings
without quotes.
See also [`println`](@ref), [`string`](@ref).
See also [`println`](@ref), [`string`](@ref), [`printstyled`](@ref).
# Examples
```jldoctest
Expand Down Expand Up @@ -57,6 +57,8 @@ end
Print (using [`print`](@ref)) `xs` to `io` followed by a newline.
If `io` is not supplied, prints to the default output stream [`stdout`](@ref).
See also [`printstyled`](@ref) to add colors etc.
# Examples
```jldoctest
julia> println("Hello, world")
Expand Down
18 changes: 11 additions & 7 deletions base/util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,18 @@ end
Print `xs` in a color specified as a symbol or integer, optionally in bold.
`color` may take any of the values $(Base.available_text_colors_docstring)
Keyword `color` may take any of the values $(Base.available_text_colors_docstring)
or an integer between 0 and 255 inclusive. Note that not all terminals support 256 colors.
If the keyword `bold` is given as `true`, the result will be printed in bold.
If the keyword `underline` is given as `true`, the result will be printed underlined.
If the keyword `blink` is given as `true`, the result will blink.
If the keyword `reverse` is given as `true`, the result will have foreground and background colors inversed.
If the keyword `hidden` is given as `true`, the result will be hidden.
Keywords can be given in any combination.
Keywords `bold=true`, `underline=true`, `blink=true` are self-explanatory.
Keyword `reverse=true` prints with foreground and background colors exchanged,
and `hidden=true` should be invisibe in the terminal but can still be copied.
These properties can be used in any combination.
See also [`print`](@ref), [`println`](@ref), [`show`](@ref).
!!! compat "Julia 1.7"
Keywords except `color` and `bold` were added in Julia 1.7.
"""
printstyled(io::IO, msg...; bold::Bool=false, underline::Bool=false, blink::Bool=false, reverse::Bool=false, hidden::Bool=false, color::Union{Int,Symbol}=:normal) =
with_output_color(print, color, io, msg...; bold=bold, underline=underline, blink=blink, reverse=reverse, hidden=hidden)
Expand Down

0 comments on commit f2080d5

Please sign in to comment.