3434Base. Experimental. @optlevel 1
3535Base. Experimental. @max_methods 1
3636
37- using Base. Meta, Sockets
37+ using Base. Meta, Sockets, StyledStrings
3838import InteractiveUtils
3939
4040export
@@ -1422,11 +1422,17 @@ ends_with_semicolon(code::AbstractString) = ends_with_semicolon(String(code))
14221422ends_with_semicolon (code:: Union{String,SubString{String}} ) =
14231423 contains (_rm_strings_and_comments (code), r" ;\s *$" )
14241424
1425- function banner (io:: IO = stdout ; short = false )
1426- if Base. GIT_VERSION_INFO. tagged_commit
1427- commit_string = Base. TAGGED_RELEASE_BANNER
1425+ """
1426+ banner(io::IO = stdout, maxsize:Int = 10)
1427+
1428+ Print the "Julia" informative banner to `io`, using a size variant no larger
1429+ than `maxsize`.
1430+ """
1431+ function banner (io:: IO = stdout , maxsize:: Int = 10 )
1432+ commit_string = if Base. GIT_VERSION_INFO. tagged_commit
1433+ Base. AnnotatedString (TAGGED_RELEASE_BANNER, :face => :shadow )
14281434 elseif isempty (Base. GIT_VERSION_INFO. commit)
1429- commit_string = " "
1435+ styled ""
14301436 else
14311437 days = Int (floor ((ccall (:jl_clock_now , Float64, ()) - Base. GIT_VERSION_INFO. fork_master_timestamp) / (60 * 60 * 24 )))
14321438 days = max (0 , days)
@@ -1435,60 +1441,61 @@ function banner(io::IO = stdout; short = false)
14351441 commit = Base. GIT_VERSION_INFO. commit_short
14361442
14371443 if distance == 0
1438- commit_string = " Commit $(commit) ($(days) $(unit) old master)"
1444+ styled """ Commit {grey:$commit} \
1445+ ({warning:⌛ {italic:$days $unit}} old master)"""
14391446 else
14401447 branch = Base. GIT_VERSION_INFO. branch
1441- commit_string = " $(branch) /$(commit) (fork: $(distance) commits, $(days) $(unit) )"
1448+ styled """ {emphasis:$branch}/{grey:$commit} \
1449+ ({italic:{success:{bold,(slant=normal):↑} $distance commits}, \
1450+ {warning:{(slant=normal):⌛} $days $unit}})"""
14421451 end
14431452 end
14441453
1445- commit_date = isempty (Base. GIT_VERSION_INFO. date_string) ? " " : " ($(split (Base. GIT_VERSION_INFO. date_string)[1 ]) )"
1446-
1447- if get (io, :color , false ):: Bool
1448- c = Base. text_colors
1449- tx = c[:normal ] # text
1450- jl = c[:normal ] # julia
1451- d1 = c[:bold ] * c[:blue ] # first dot
1452- d2 = c[:bold ] * c[:red ] # second dot
1453- d3 = c[:bold ] * c[:green ] # third dot
1454- d4 = c[:bold ] * c[:magenta ] # fourth dot
1455-
1456- if short
1457- print (io,"""
1458- $(d3) o$(tx) | Version $(VERSION )$(commit_date)
1459- $(d2) o$(tx) $(d4) o$(tx) | $(commit_string)
1460- """ )
1461- else
1462- print (io,""" $(d3) _$(tx)
1463- $(d1) _$(tx) $(jl) _$(tx) $(d2) _$(d3) (_)$(d4) _$(tx) | Documentation: https://docs.julialang.org
1464- $(d1) (_)$(jl) | $(d2) (_)$(tx) $(d4) (_)$(tx) |
1465- $(jl) _ _ _| |_ __ _$(tx) | Type \" ?\" for help, \" ]?\" for Pkg help.
1466- $(jl) | | | | | | |/ _` |$(tx) |
1467- $(jl) | | |_| | | | (_| |$(tx) | Version $(VERSION )$(commit_date)
1468- $(jl) _/ |\\ __'_|_|_|\\ __'_|$(tx) | $(commit_string)
1469- $(jl) |__/$(tx) |
1470-
1471- """ )
1472- end
1473- else
1474- if short
1475- print (io,"""
1476- o | Version $(VERSION )$(commit_date)
1477- o o | $(commit_string)
1478- """ )
1479- else
1480- print (io,"""
1481- _
1482- _ _ _(_)_ | Documentation: https://docs.julialang.org
1483- (_) | (_) (_) |
1484- _ _ _| |_ __ _ | Type \" ?\" for help, \" ]?\" for Pkg help.
1485- | | | | | | |/ _` | |
1486- | | |_| | | | (_| | | Version $(VERSION )$(commit_date)
1487- _/ |\\ __'_|_|_|\\ __'_| | $(commit_string)
1488- |__/ |
1489-
1490- """ )
1491- end
1454+ commit_date = isempty (Base. GIT_VERSION_INFO. date_string) ? " " : styled " {light:($(split(Base.GIT_VERSION_INFO.date_string)[1]))}"
1455+ doclink = styled " {bold:Documentation\: } {(underline=grey),link={https://docs.julialang.org}:https\: //docs.julialang.org}"
1456+ help = styled " Type {region,repl_prompt_help:?} for help, {region,repl_prompt_pkg:]?} for {(underline=grey),link={https://pkgdocs.julialang.org/}:Pkg} help."
1457+
1458+ size = clamp (if all (displaysize (io) .>= (5 , 70 )); 4 # Full size
1459+ elseif all (displaysize (io) .>= (5 , 45 )); 3 # Narrower
1460+ elseif all (displaysize (io) .>= (3 , 50 )); 2 # Tiny
1461+ else 1 end ,
1462+ 0 , maxsize)
1463+
1464+ if size == 4 # Full size
1465+ print (io, styled """
1466+ {bold,green:_}
1467+ {bold,blue:_} _ {bold:{red:_}{green:(_)}{magenta:_}} {shadow:│} $doclink
1468+ {bold,blue:(_)} | {bold:{red:(_)} {magenta:(_)}} {shadow:│}
1469+ _ _ _| |_ __ _ {shadow:│} $help
1470+ | | | | | | |/ _` | {shadow:│}
1471+ | | |_| | | | (_| | {shadow:│} Version {bold:$VERSION}$commit_date
1472+ _/ |\\ __'_|_|_|\\ __'_| {shadow:│} $commit_string
1473+ |__/ {shadow:│}
1474+ \n """ )
1475+ elseif size == 3 # Rotated
1476+ print (io, styled """
1477+ {bold,green:_}
1478+ {bold,blue:_} _ {bold:{red:_}{green:(_)}{magenta:_}}
1479+ {bold,blue:(_)} | {bold:{red:(_)} {magenta:(_)}}
1480+ _ _ _| |_ __ _
1481+ | | | | | | |/ _` |
1482+ | | |_| | | | (_| |
1483+ _/ |\\ __'_|_|_|\\ __'_|
1484+ |__/
1485+
1486+ $doclink
1487+ $help
1488+
1489+ Version {bold:$VERSION}$commit_date
1490+ $commit_string
1491+ \n """ )
1492+ elseif size == 2 # Tiny
1493+ print (io, styled """
1494+ {bold,green:o} {shadow:│} Version {bold:$VERSION}$commit_date
1495+ {bold:{red:o} {magenta:o}} {shadow:│} $commit_string
1496+ """ )
1497+ elseif size == 1 # Text only
1498+ print (io, styled """ {bold:{blue:∴} {magenta:Julia} $VERSION}$commit_date\n """ )
14921499 end
14931500end
14941501
0 commit comments