Skip to content

Commit

Permalink
Multiple banner sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
tecosaur committed May 16, 2023
1 parent 1f1607d commit a68bb6f
Showing 1 changed file with 61 additions and 13 deletions.
74 changes: 61 additions & 13 deletions base/client.jl
Original file line number Diff line number Diff line change
Expand Up @@ -422,26 +422,74 @@ function banner(io::IO = stdout)
commit = GIT_VERSION_INFO.commit_short

if distance == 0
commit_string = S"Commit {(foreground=grey):$commit} ({italic,warning:$days $unit} old master)"
commit_string =
S"""Commit {(foreground=grey):$commit} \
({warning:⌛ {italic:$days $unit}} old master)"""
else
branch = GIT_VERSION_INFO.branch
commit_string = S"{emphasis:$branch}/{(foreground=grey):$commit} (fork {italic:{warning:$distance commits}, {warning:$days $unit}})"
commit_string =
S"""{emphasis:$branch}/{(foreground=grey):$commit} \
({italic:{success:{bold,(italic=false):↑} $distance commits}, \
{warning:{(italic=false):⌛} $days $unit}})"""
end
end

commit_date = isempty(Base.GIT_VERSION_INFO.date_string) ? "" : " ($(split(Base.GIT_VERSION_INFO.date_string)[1]))"
sep = StyledChar('', :face => Face(foreground=:grey))

print(io, S"""
{bold,(foreground=green):_}
{bold,(foreground=blue):_} _ {bold:{(foreground=red):_}{(foreground=green):(_)}{(foreground=magenta):_}} $sep {bold:Documentation:} {(underline=bright_blue),link={https://docs.julialang.org}:https://docs.julialang.org}
{bold,(foreground=blue):(_)} | {bold:{(foreground=red):(_)} {(foreground=magenta):(_)}} $sep
_ _ _| |_ __ _ $sep Type {region,julia_help_prompt:?} for help, {region,julia_pkg_prompt:]?} for {(underline=bright_blue),link={https://pkgdocs.julialang.org/}:Pkg} help.
| | | | | | |/ _` | $sep
| | |_| | | | (_| | $sep Version {bold:$VERSION}$commit_date
_/ |\\__'_|_|_|\\__'_| $sep $commit_string
|__/ $sep
\n""")
doclink = S"{bold:Documentation:} {(underline=grey),link={https://docs.julialang.org}:https://docs.julialang.org}"
help = S"Type {region,julia_help_prompt:?} for help, {region,julia_pkg_prompt:]?} for {(underline=grey),link={https://pkgdocs.julialang.org/}:Pkg} help."

if all(displaysize(io) .>= (25, 70)) # Full size
print(io, S"""
{bold,(foreground=green):_}
{bold,(foreground=blue):_} _ {bold:{(foreground=red):_}{(foreground=green):(_)}{(foreground=magenta):_}} $sep $doclink
{bold,(foreground=blue):(_)} | {bold:{(foreground=red):(_)} {(foreground=magenta):(_)}} $sep
_ _ _| |_ __ _ $sep $help
| | | | | | |/ _` | $sep
| | |_| | | | (_| | $sep Version {bold:$VERSION}$commit_date
_/ |\\__'_|_|_|\\__'_| $sep $commit_string
|__/ $sep
\n""")
elseif all(displaysize(io) .>= (15, 70)) # Shorter
print(io, S"""
{bold,(foreground=green):_}
{bold,(foreground=blue):_} _ {bold:{(foreground=red):_}{(foreground=green):(_)}{(foreground=magenta):_}} $sep $doclink
{bold,(foreground=blue):(_)} _ _ | |{bold:{(foreground=red):(_)} {(foreground=magenta):(_)}}_ $sep $help
| || || || || |/ _` | $sep
_/ | \\_._||_||_|\\__/_| $sep Version {bold:$VERSION}$commit_date
|__/ $sep $commit_string
\n""")
elseif all(displaysize(io) .>= (25, 45)) # Narrower
print(io, S"""
{bold,(foreground=green):_}
{bold,(foreground=blue):_} _ {bold:{(foreground=red):_}{(foreground=green):(_)}{(foreground=magenta):_}}
{bold,(foreground=blue):(_)} _ _ | |{bold:{(foreground=red):(_)} {(foreground=magenta):(_)}}_
| || || || || |/ _` |
_/ | \\_._||_||_|\\__/_|
|__/
$doclink
$help
Version {bold:$VERSION}$commit_date
$commit_string
\n""")
elseif all(displaysize(io) .>= (8, 55)) # Tiny
print(io, S"""
{bold,(foreground=blue):o} ╷{(foreground=green):∴} $sep $doclink
│╷ ╷││╭─┐ $sep Version {bold:$VERSION}$commit_date
│╰─┘╵╵╰─╰ $sep $commit_string
""")
elseif all(displaysize(io) .>= (5, 25)) # Tinier
print(io, S"""
{bold,(foreground=blue):o} |{(foreground=green):∴} _
||_|||(_|
╯{(foreground=grey):{bold:$VERSION}$commit_date}
\n""")
else # Text only
print(io, S"""{bold:{(foreground=blue):∴} {(foreground=magenta):Julia} $VERSION}$commit_date\n""")
end
end

global active_repl
Expand Down

0 comments on commit a68bb6f

Please sign in to comment.