Revision 9655c212522176a0df6f2d87d8ae44620ed32ce3 authored by Lyndon White on 20 May 2020, 01:37:16 UTC, committed by GitHub on 20 May 2020, 01:37:16 UTC
* make taking views of string indexing give substrings

* add news

* Remove excess whitespace

* handle single character string views correctly

* test values of views

* make substring etc work on AbstractUnitRanges

* Fix missing space
1 parent 9d70d45
Raw File
ttyhascolor.jl
if Sys.iswindows()
    ttyhascolor(term_type = nothing) = true
else
    function ttyhascolor(term_type = get(ENV, "TERM", ""))
        startswith(term_type, "xterm") && return true
        try
            @static if Sys.KERNEL === :FreeBSD
                return success(`tput AF 0`)
            else
                return success(`tput setaf 0`)
            end
        catch e
            return false
        end
    end
end
function get_have_color()
    global have_color
    have_color === nothing && (have_color = ttyhascolor())
    return have_color::Bool
end
in(key_value::Pair{Symbol,Bool}, ::TTY) = key_value.first === :color && key_value.second === get_have_color()
haskey(::TTY, key::Symbol) = key === :color
getindex(::TTY, key::Symbol) = key === :color ? get_have_color() : throw(KeyError(key))
get(::TTY, key::Symbol, default) = key === :color ? get_have_color() : default
back to top