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,78 @@ 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 " {(weight=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) .>= (20 , 70 )); 6 # Full size
1459+ elseif all (displaysize (io) .>= (15 , 70 )); 5 # Shorter
1460+ elseif all (displaysize (io) .>= (25 , 45 )); 4 # Narrower
1461+ elseif all (displaysize (io) .>= (8 , 55 )); 3 # Tiny
1462+ elseif all (displaysize (io) .>= (5 , 25 )); 2 # Tinier
1463+ else 1 end ,
1464+ 0 , maxsize)
1465+
1466+ if size == 6 # Full size
1467+ print (io, styled """
1468+ {bold,green:_}
1469+ {bold,blue:_} _ {bold:{red:_}{green:(_)}{magenta:_}} {shadow:│} $doclink
1470+ {bold,blue:(_)} | {bold:{red:(_)} {magenta:(_)}} {shadow:│}
1471+ _ _ _| |_ __ _ {shadow:│} $help
1472+ | | | | | | |/ _` | {shadow:│}
1473+ | | |_| | | | (_| | {shadow:│} Version {bold:$VERSION}$commit_date
1474+ _/ |\\ __'_|_|_|\\ __'_| {shadow:│} $commit_string
1475+ |__/ {shadow:│}
1476+ \n """ )
1477+ elseif size == 5 # Shorter
1478+ print (io, styled """
1479+ {bold,green:_}
1480+ {bold,blue:_} _ {bold:{red:_}{green:(_)}{magenta:_}} {shadow:│} $doclink
1481+ {bold,blue:(_)} _ _ | |{bold:{red:(_)} {magenta:(_)}}_ {shadow:│} $help
1482+ | || || || || |/ _` | {shadow:│}
1483+ _/ | \\ _._||_||_|\\ __/_| {shadow:│} Version {bold:$VERSION}$commit_date
1484+ |__/ {shadow:│} $commit_string
1485+ \n """ )
1486+ elseif size == 4 # Narrower
1487+ print (io, styled """
1488+ {bold,green:_}
1489+ {bold,blue:_} _ {bold:{red:_}{green:(_)}{magenta:_}}
1490+ {bold,blue:(_)} _ _ | |{bold:{red:(_)} {magenta:(_)}}_
1491+ | || || || || |/ _` |
1492+ _/ | \\ _._||_||_|\\ __/_|
1493+ |__/
1494+
1495+ $doclink
1496+ $help
1497+
1498+ Version {bold:$VERSION}$commit_date
1499+ $commit_string
1500+ \n """ )
1501+ elseif size == 3 # Tiny
1502+ print (io, styled """
1503+ {bold,blue:o} ╷{green:∴} {shadow:│} $doclink
1504+ │╷ ╷││╭─┐ {shadow:│} Version {bold:$VERSION}$commit_date
1505+ │╰─┘╵╵╰─╰ {shadow:│} $commit_string
1506+ ╯
1507+ """ )
1508+ elseif size == 2 # Tinier
1509+ print (io, styled """
1510+ {bold,blue:o} |{green:∴} _
1511+ ||_|||(_|
1512+ ╯{grey:{bold:$VERSION}$commit_date}
1513+ \n """ )
1514+ elseif size == 1 # Text only
1515+ print (io, styled """ {bold:{blue:∴} {magenta:Julia} $VERSION}$commit_date\n """ )
14921516 end
14931517end
14941518
0 commit comments