@@ -1750,11 +1750,21 @@ ends_with_semicolon(code::AbstractString) = ends_with_semicolon(String(code))
17501750ends_with_semicolon (code:: Union{String,SubString{String}} ) =
17511751 contains (_rm_strings_and_comments (code), r" ;\s *$" )
17521752
1753- function banner (io:: IO = stdout ; short = false )
1754- if Base. GIT_VERSION_INFO. tagged_commit
1755- commit_string = Base. TAGGED_RELEASE_BANNER
1753+ """
1754+ banner(io::IO = stdout, preferred::Symbol = :full)
1755+
1756+ Print the "Julia" informative banner to `io`, using the `preferred` variant
1757+ if reasonable and known.
1758+
1759+ !!! warning
1760+ The particular banner selected by `preferred` is liable to being changed
1761+ without warning. The current variants are: `:tiny`, `:short`, `:narrow`, and `:full`.
1762+ """
1763+ function banner (io:: IO = stdout , preferred:: Symbol = :full )
1764+ commit_string = if Base. GIT_VERSION_INFO. tagged_commit
1765+ Base. AnnotatedString (TAGGED_RELEASE_BANNER, :face => :shadow )
17561766 elseif isempty (Base. GIT_VERSION_INFO. commit)
1757- commit_string = " "
1767+ styled ""
17581768 else
17591769 days = Int (floor ((ccall (:jl_clock_now , Float64, ()) - Base. GIT_VERSION_INFO. fork_master_timestamp) / (60 * 60 * 24 )))
17601770 days = max (0 , days)
@@ -1763,60 +1773,65 @@ function banner(io::IO = stdout; short = false)
17631773 commit = Base. GIT_VERSION_INFO. commit_short
17641774
17651775 if distance == 0
1766- commit_string = " Commit $(commit) ($(days) $(unit) old master)"
1776+ styled """ Commit {grey:$commit} \
1777+ ({warning:⌛ {italic:$days $unit}} old master)"""
17671778 else
17681779 branch = Base. GIT_VERSION_INFO. branch
1769- commit_string = " $(branch) /$(commit) (fork: $(distance) commits, $(days) $(unit) )"
1780+ styled """ {emphasis:$branch}/{grey:$commit} \
1781+ ({italic:{success:{bold,(slant=normal):↑} $distance commits}, \
1782+ {warning:{(slant=normal):⌛} $days $unit}})"""
17701783 end
17711784 end
17721785
1773- commit_date = isempty (Base. GIT_VERSION_INFO. date_string) ? " " : " ($(split (Base. GIT_VERSION_INFO. date_string)[1 ]) )"
1774-
1775- if get (io, :color , false ):: Bool
1776- c = Base. text_colors
1777- tx = c[:normal ] # text
1778- jl = c[:normal ] # julia
1779- d1 = c[:bold ] * c[:blue ] # first dot
1780- d2 = c[:bold ] * c[:red ] # second dot
1781- d3 = c[:bold ] * c[:green ] # third dot
1782- d4 = c[:bold ] * c[:magenta ] # fourth dot
1783-
1784- if short
1785- print (io,"""
1786- $(d3) o$(tx) | Version $(VERSION )$(commit_date)
1787- $(d2) o$(tx) $(d4) o$(tx) | $(commit_string)
1788- """ )
1789- else
1790- print (io,""" $(d3) _$(tx)
1791- $(d1) _$(tx) $(jl) _$(tx) $(d2) _$(d3) (_)$(d4) _$(tx) | Documentation: https://docs.julialang.org
1792- $(d1) (_)$(jl) | $(d2) (_)$(tx) $(d4) (_)$(tx) |
1793- $(jl) _ _ _| |_ __ _$(tx) | Type \" ?\" for help, \" ]?\" for Pkg help.
1794- $(jl) | | | | | | |/ _` |$(tx) |
1795- $(jl) | | |_| | | | (_| |$(tx) | Version $(VERSION )$(commit_date)
1796- $(jl) _/ |\\ __'_|_|_|\\ __'_|$(tx) | $(commit_string)
1797- $(jl) |__/$(tx) |
1798-
1799- """ )
1800- end
1801- else
1802- if short
1803- print (io,"""
1804- o | Version $(VERSION )$(commit_date)
1805- o o | $(commit_string)
1806- """ )
1807- else
1808- print (io,"""
1809- _
1810- _ _ _(_)_ | Documentation: https://docs.julialang.org
1811- (_) | (_) (_) |
1812- _ _ _| |_ __ _ | Type \" ?\" for help, \" ]?\" for Pkg help.
1813- | | | | | | |/ _` | |
1814- | | |_| | | | (_| | | Version $(VERSION )$(commit_date)
1815- _/ |\\ __'_|_|_|\\ __'_| | $(commit_string)
1816- |__/ |
1817-
1818- """ )
1819- end
1786+ commit_date = isempty (Base. GIT_VERSION_INFO. date_string) ? " " : styled " {light:($(split(Base.GIT_VERSION_INFO.date_string)[1]))}"
1787+ doclink = styled " {bold:Documentation:} {(underline=grey),link={https://docs.julialang.org}:https://docs.julialang.org}"
1788+ help = styled " Type {repl_prompt_help:?} for help, {repl_prompt_pkg:]?} for {(underline=grey),link={https://pkgdocs.julialang.org/}:Pkg} help."
1789+
1790+ sizenames = (:tiny , :short , :narrow , :full )
1791+ maxsize = something (findfirst (== (preferred), sizenames), length (sizenames))
1792+ size = min (if all (displaysize (io) .>= (8 , 70 )); 4 # Full size
1793+ elseif all (displaysize (io) .>= (8 , 45 )); 3 # Narrower
1794+ elseif all (displaysize (io) .>= (3 , 50 )); 2 # Tiny
1795+ else 1 end ,
1796+ max (0 , maxsize))
1797+
1798+ if size == 4 # Full size
1799+ print (io, styled """
1800+ {bold,green:_}
1801+ {bold,blue:_} _ {bold:{red:_}{green:(_)}{magenta:_}} {shadow:│} $doclink
1802+ {bold,blue:(_)} | {bold:{red:(_)} {magenta:(_)}} {shadow:│}
1803+ _ _ _| |_ __ _ {shadow:│} $help
1804+ | | | | | | |/ _` | {shadow:│}
1805+ | | |_| | | | (_| | {shadow:│} Version {bold:$VERSION}$commit_date
1806+ _/ |\\ __'_|_|_|\\ __'_| {shadow:│} $commit_string
1807+ |__/ {shadow:│}
1808+ \n """ )
1809+ elseif size == 3 # Rotated
1810+ print (io, styled """
1811+ {bold,green:_}
1812+ {bold,blue:_} _ {bold:{red:_}{green:(_)}{magenta:_}}
1813+ {bold,blue:(_)} | {bold:{red:(_)} {magenta:(_)}}
1814+ _ _ _| |_ __ _
1815+ | | | | | | |/ _` |
1816+ | | |_| | | | (_| |
1817+ _/ |\\ __'_|_|_|\\ __'_|
1818+ |__/
1819+
1820+ $doclink
1821+ $help
1822+
1823+ Version {bold:$VERSION}$commit_date
1824+ $commit_string
1825+ \n """ )
1826+ elseif size == 2 # Tiny
1827+ print (io, styled """
1828+ {bold,green:o} {shadow:│} Version {bold:$VERSION}$commit_date
1829+ {bold:{red:o} {magenta:o}} {shadow:│} $commit_string
1830+ """ , ifelse (displaysize (io) > (12 , 0 ), " \n " , " " ))
1831+ elseif size == 1 && Base. GIT_VERSION_INFO. tagged_commit # Text only
1832+ print (io, styled """ {bold:{blue:∴} {magenta:Julia} $VERSION}$commit_date\n """ )
1833+ elseif size == 1 # Text only
1834+ print (io, styled """ {bold:{blue:∴} {magenta:Julia} $VERSION}$commit_date $commit_string\n """ )
18201835 end
18211836end
18221837
0 commit comments