@@ -1688,11 +1688,21 @@ ends_with_semicolon(code::AbstractString) = ends_with_semicolon(String(code))
16881688ends_with_semicolon (code:: Union{String,SubString{String}} ) =
16891689 contains (_rm_strings_and_comments (code), r" ;\s *$" )
16901690
1691- function banner (io:: IO = stdout ; short = false )
1692- if Base. GIT_VERSION_INFO. tagged_commit
1693- commit_string = Base. TAGGED_RELEASE_BANNER
1691+ """
1692+ banner(io::IO = stdout, preferred::Symbol = :full)
1693+
1694+ Print the "Julia" informative banner to `io`, using the `preferred` variant
1695+ if reasonable and known.
1696+
1697+ !!! warning
1698+ The particular banner selected by `preferred` is liable to being changed
1699+ without warning. The current variants are: `:tiny`, `:short`, `:narrow`, and `:full`.
1700+ """
1701+ function banner (io:: IO = stdout , preferred:: Symbol = :full )
1702+ commit_string = if Base. GIT_VERSION_INFO. tagged_commit
1703+ Base. AnnotatedString (TAGGED_RELEASE_BANNER, :face => :shadow )
16941704 elseif isempty (Base. GIT_VERSION_INFO. commit)
1695- commit_string = " "
1705+ styled ""
16961706 else
16971707 days = Int (floor ((ccall (:jl_clock_now , Float64, ()) - Base. GIT_VERSION_INFO. fork_master_timestamp) / (60 * 60 * 24 )))
16981708 days = max (0 , days)
@@ -1701,60 +1711,65 @@ function banner(io::IO = stdout; short = false)
17011711 commit = Base. GIT_VERSION_INFO. commit_short
17021712
17031713 if distance == 0
1704- commit_string = " Commit $(commit) ($(days) $(unit) old master)"
1714+ styled """ Commit {grey:$commit} \
1715+ ({warning:⌛ {italic:$days $unit}} old master)"""
17051716 else
17061717 branch = Base. GIT_VERSION_INFO. branch
1707- commit_string = " $(branch) /$(commit) (fork: $(distance) commits, $(days) $(unit) )"
1718+ styled """ {emphasis:$branch}/{grey:$commit} \
1719+ ({italic:{success:{bold,(slant=normal):↑} $distance commits}, \
1720+ {warning:{(slant=normal):⌛} $days $unit}})"""
17081721 end
17091722 end
17101723
1711- commit_date = isempty (Base. GIT_VERSION_INFO. date_string) ? " " : " ($(split (Base. GIT_VERSION_INFO. date_string)[1 ]) )"
1712-
1713- if get (io, :color , false ):: Bool
1714- c = Base. text_colors
1715- tx = c[:normal ] # text
1716- jl = c[:normal ] # julia
1717- d1 = c[:bold ] * c[:blue ] # first dot
1718- d2 = c[:bold ] * c[:red ] # second dot
1719- d3 = c[:bold ] * c[:green ] # third dot
1720- d4 = c[:bold ] * c[:magenta ] # fourth dot
1721-
1722- if short
1723- print (io,"""
1724- $(d3) o$(tx) | Version $(VERSION )$(commit_date)
1725- $(d2) o$(tx) $(d4) o$(tx) | $(commit_string)
1726- """ )
1727- else
1728- print (io,""" $(d3) _$(tx)
1729- $(d1) _$(tx) $(jl) _$(tx) $(d2) _$(d3) (_)$(d4) _$(tx) | Documentation: https://docs.julialang.org
1730- $(d1) (_)$(jl) | $(d2) (_)$(tx) $(d4) (_)$(tx) |
1731- $(jl) _ _ _| |_ __ _$(tx) | Type \" ?\" for help, \" ]?\" for Pkg help.
1732- $(jl) | | | | | | |/ _` |$(tx) |
1733- $(jl) | | |_| | | | (_| |$(tx) | Version $(VERSION )$(commit_date)
1734- $(jl) _/ |\\ __'_|_|_|\\ __'_|$(tx) | $(commit_string)
1735- $(jl) |__/$(tx) |
1736-
1737- """ )
1738- end
1739- else
1740- if short
1741- print (io,"""
1742- o | Version $(VERSION )$(commit_date)
1743- o o | $(commit_string)
1744- """ )
1745- else
1746- print (io,"""
1747- _
1748- _ _ _(_)_ | Documentation: https://docs.julialang.org
1749- (_) | (_) (_) |
1750- _ _ _| |_ __ _ | Type \" ?\" for help, \" ]?\" for Pkg help.
1751- | | | | | | |/ _` | |
1752- | | |_| | | | (_| | | Version $(VERSION )$(commit_date)
1753- _/ |\\ __'_|_|_|\\ __'_| | $(commit_string)
1754- |__/ |
1755-
1756- """ )
1757- end
1724+ commit_date = isempty (Base. GIT_VERSION_INFO. date_string) ? " " : styled " {light:($(split(Base.GIT_VERSION_INFO.date_string)[1]))}"
1725+ doclink = styled " {bold:Documentation:} {(underline=grey),link={https://docs.julialang.org}:https://docs.julialang.org}"
1726+ help = styled " Type {repl_prompt_help:?} for help, {repl_prompt_pkg:]?} for {(underline=grey),link={https://pkgdocs.julialang.org/}:Pkg} help."
1727+
1728+ sizenames = (:tiny , :short , :narrow , :full )
1729+ maxsize = something (findfirst (== (preferred), sizenames), length (sizenames))
1730+ size = min (if all (displaysize (io) .>= (8 , 70 )); 4 # Full size
1731+ elseif all (displaysize (io) .>= (8 , 45 )); 3 # Narrower
1732+ elseif all (displaysize (io) .>= (3 , 50 )); 2 # Tiny
1733+ else 1 end ,
1734+ max (0 , maxsize))
1735+
1736+ if size == 4 # Full size
1737+ print (io, styled """
1738+ {bold,green:_}
1739+ {bold,blue:_} _ {bold:{red:_}{green:(_)}{magenta:_}} {shadow:│} $doclink
1740+ {bold,blue:(_)} | {bold:{red:(_)} {magenta:(_)}} {shadow:│}
1741+ _ _ _| |_ __ _ {shadow:│} $help
1742+ | | | | | | |/ _` | {shadow:│}
1743+ | | |_| | | | (_| | {shadow:│} Version {bold:$VERSION}$commit_date
1744+ _/ |\\ __'_|_|_|\\ __'_| {shadow:│} $commit_string
1745+ |__/ {shadow:│}
1746+ \n """ )
1747+ elseif size == 3 # Rotated
1748+ print (io, styled """
1749+ {bold,green:_}
1750+ {bold,blue:_} _ {bold:{red:_}{green:(_)}{magenta:_}}
1751+ {bold,blue:(_)} | {bold:{red:(_)} {magenta:(_)}}
1752+ _ _ _| |_ __ _
1753+ | | | | | | |/ _` |
1754+ | | |_| | | | (_| |
1755+ _/ |\\ __'_|_|_|\\ __'_|
1756+ |__/
1757+
1758+ $doclink
1759+ $help
1760+
1761+ Version {bold:$VERSION}$commit_date
1762+ $commit_string
1763+ \n """ )
1764+ elseif size == 2 # Tiny
1765+ print (io, styled """
1766+ {bold,green:o} {shadow:│} Version {bold:$VERSION}$commit_date
1767+ {bold:{red:o} {magenta:o}} {shadow:│} $commit_string
1768+ """ , ifelse (displaysize (io) > (12 , 0 ), " \n " , " " ))
1769+ elseif size == 1 && Base. GIT_VERSION_INFO. tagged_commit # Text only
1770+ print (io, styled """ {bold:{blue:∴} {magenta:Julia} $VERSION}$commit_date\n """ )
1771+ elseif size == 1 # Text only
1772+ print (io, styled """ {bold:{blue:∴} {magenta:Julia} $VERSION}$commit_date $commit_string\n """ )
17581773 end
17591774end
17601775
0 commit comments