Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit23c3309

Browse files
authored
[release-1.13] Revert "Make banner size depend on terminal size (#51811)" (#60186)
1 parent336d9d0 commit23c3309

File tree

6 files changed

+81
-134
lines changed

6 files changed

+81
-134
lines changed

‎base/client.jl‎

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ end
484484
functionrun_std_repl(REPL::Module, quiet::Bool, banner::Symbol, history_file::Bool)
485485
term_env=get(ENV,"TERM",@static Sys.iswindows()?"":"dumb")
486486
term= REPL.Terminals.TTYTerminal(term_env,stdin,stdout,stderr)
487-
banner==:no|| REPL.banner(term, banner)
487+
banner==:no|| REPL.banner(term,short=banner==:short)
488488
if term.term_type=="dumb"
489489
repl= REPL.BasicREPL(term)
490490
quiet||@warn"Terminal not fully functional"
@@ -607,26 +607,12 @@ end
607607
functionrepl_main(_)
608608
opts= Base.JLOptions()
609609
interactiveinput=isa(stdin, Base.TTY)
610-
bval=if opts.banner==-1# Auto
611-
Int(interactiveinput)
612-
else
613-
opts.banner
614-
end
615-
# All the options produced by `jloptions.c`'s `case opt_banner`.
616-
# 0=off, 1=largest, ..., N=smallest
617-
banner=if bval==0
618-
:no
619-
elseif bval==1
620-
:full
621-
elseif bval==2
622-
:narrow
623-
elseif bval==3
624-
:short
625-
elseif bval==4
626-
:tiny
627-
else# For type stability of `banner`
628-
:unreachable
629-
end
610+
b= opts.banner
611+
auto= b==-1
612+
banner= b==0|| (auto&&!interactiveinput)?:no:
613+
b==1|| (auto&& interactiveinput)?:yes:
614+
:short# b == 2
615+
630616
quiet= (opts.quiet!=0)
631617
history_file= (opts.historyfile!=0)
632618
returnrun_main_repl(interactiveinput, quiet, banner, history_file)

‎src/jloptions.c‎

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,7 @@ static const char opts[] =
235235
" -i, --interactive Interactive mode; REPL runs and\n"
236236
" `isinteractive()` is true.\n"
237237
" -q, --quiet Quiet startup: no banner, suppress REPL warnings\n"
238-
" --banner={yes|no|auto*|<size>} Enable or disable startup banner, or specify a\n"
239-
" preferred <size> (tiny, short, narrow, or full).\n"
238+
" --banner={yes|no|short|auto*} Enable or disable startup banner\n"
240239
" --color={yes|no|auto*} Enable or disable color text\n"
241240
" --history-file={yes*|no} Load or save history\n\n"
242241

@@ -612,22 +611,16 @@ JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp)
612611
jl_options.banner=0;
613612
break;
614613
caseopt_banner:// banner
615-
if (!strcmp(optarg,"auto"))
616-
jl_options.banner=-1;
614+
if (!strcmp(optarg,"yes"))
615+
jl_options.banner=1;
617616
elseif (!strcmp(optarg,"no"))
618617
jl_options.banner=0;
619-
elseif (!strcmp(optarg,"yes"))
620-
jl_options.banner=1;
621-
elseif (!strcmp(optarg,"full"))
622-
jl_options.banner=1;// Same as "yes".
623-
elseif (!strcmp(optarg,"narrow"))
624-
jl_options.banner=2;
618+
elseif (!strcmp(optarg,"auto"))
619+
jl_options.banner=-1;
625620
elseif (!strcmp(optarg,"short"))
626-
jl_options.banner=3;
627-
elseif (!strcmp(optarg,"tiny"))
628-
jl_options.banner=4;
621+
jl_options.banner=2;
629622
else
630-
jl_errorf("julia: invalid argument to --banner={yes|no|auto|full|narrow|short|tiny} (%s)",optarg);
623+
jl_errorf("julia: invalid argument to --banner={yes|no|auto|short} (%s)",optarg);
631624
break;
632625
caseopt_experimental_features:
633626
jl_options.use_experimental_features=JL_OPTIONS_USE_EXPERIMENTAL_FEATURES_YES;

‎stdlib/REPL/src/REPL.jl‎

Lines changed: 53 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1704,21 +1704,11 @@ function ends_with_semicolon(code)
17041704
return semi
17051705
end
17061706

1707-
"""
1708-
banner(io::IO = stdout, preferred::Symbol = :full)
1709-
1710-
Print the "Julia" informative banner to `io`, using the `preferred` variant
1711-
if reasonable and known.
1712-
1713-
!!! warning
1714-
The particular banner selected by `preferred` is liable to being changed
1715-
without warning. The current variants are: `:tiny`, `:short`, `:narrow`, and `:full`.
1716-
"""
1717-
functionbanner(io::IO=stdout, preferred::Symbol=:full)
1718-
commit_string=if Base.GIT_VERSION_INFO.tagged_commit
1719-
Base.AnnotatedString(TAGGED_RELEASE_BANNER,:face=>:shadow)
1707+
functionbanner(io::IO=stdout; short=false)
1708+
if Base.GIT_VERSION_INFO.tagged_commit
1709+
commit_string= Base.TAGGED_RELEASE_BANNER
17201710
elseifisempty(Base.GIT_VERSION_INFO.commit)
1721-
styled""
1711+
commit_string=""
17221712
else
17231713
days=Int(floor((ccall(:jl_clock_now, Float64, ())- Base.GIT_VERSION_INFO.fork_master_timestamp)/ (60*60*24)))
17241714
days=max(0, days)
@@ -1727,65 +1717,60 @@ function banner(io::IO = stdout, preferred::Symbol = :full)
17271717
commit= Base.GIT_VERSION_INFO.commit_short
17281718

17291719
if distance==0
1730-
styled"""Commit {grey:$commit} \
1731-
({warning:⌛ {italic:$days $unit}} old master)"""
1720+
commit_string="Commit$(commit) ($(days)$(unit) old master)"
17321721
else
17331722
branch= Base.GIT_VERSION_INFO.branch
1734-
styled"""{emphasis:$branch}/{grey:$commit} \
1735-
({italic:{success:{bold,(slant=normal):↑} $distance commits}, \
1736-
{warning:{(slant=normal):⌛} $days $unit}})"""
1723+
commit_string="$(branch)/$(commit) (fork:$(distance) commits,$(days)$(unit))"
17371724
end
17381725
end
17391726

1740-
commit_date=isempty(Base.GIT_VERSION_INFO.date_string)?"":styled" {light:($(split(Base.GIT_VERSION_INFO.date_string)[1]))}"
1741-
doclink=styled"{bold:Documentation:} {(underline=grey),link={https://docs.julialang.org}:https://docs.julialang.org}"
1742-
help=styled"Type {repl_prompt_help:?} for help, {repl_prompt_pkg:]?} for {(underline=grey),link={https://pkgdocs.julialang.org/}:Pkg} help."
1743-
1744-
sizenames= (:tiny,:short,:narrow,:full)
1745-
maxsize=something(findfirst(==(preferred), sizenames),length(sizenames))
1746-
size=min(ifall(displaysize(io).>= (8,70));4# Full size
1747-
elseifall(displaysize(io).>= (8,45));3# Narrower
1748-
elseifall(displaysize(io).>= (3,50));2# Tiny
1749-
else1end,
1750-
max(0, maxsize))
1751-
1752-
if size==4# Full size
1753-
print(io,styled"""
1754-
{bold,green:_}
1755-
{bold,blue:_} _ {bold:{red:_}{green:(_)}{magenta:_}} {shadow:│} $doclink
1756-
{bold,blue:(_)} | {bold:{red:(_)} {magenta:(_)}} {shadow:│}
1757-
_ _ _| |_ __ _ {shadow:│} $help
1758-
| | | | | | |/ _` | {shadow:│}
1759-
| | |_| | | | (_| | {shadow:│} Version {bold:$VERSION}$commit_date
1760-
_/ |\\__'_|_|_|\\__'_| {shadow:│} $commit_string
1761-
|__/ {shadow:│}
1762-
\n""")
1763-
elseif size==3# Rotated
1764-
print(io,styled"""
1765-
{bold,green:_}
1766-
{bold,blue:_} _ {bold:{red:_}{green:(_)}{magenta:_}}
1767-
{bold,blue:(_)} | {bold:{red:(_)} {magenta:(_)}}
1768-
_ _ _| |_ __ _
1769-
| | | | | | |/ _` |
1770-
| | |_| | | | (_| |
1771-
_/ |\\__'_|_|_|\\__'_|
1772-
|__/
1773-
1774-
$doclink
1775-
$help
1776-
1777-
Version {bold:$VERSION}$commit_date
1778-
$commit_string
1779-
\n""")
1780-
elseif size==2# Tiny
1781-
print(io,styled"""
1782-
{bold,green:o} {shadow:│} Version {bold:$VERSION}$commit_date
1783-
{bold:{red:o} {magenta:o}} {shadow:│} $commit_string
1784-
""",ifelse(displaysize(io)> (12,0),"\n",""))
1785-
elseif size==1&& Base.GIT_VERSION_INFO.tagged_commit# Text only
1786-
print(io,styled"""{bold:{blue:∴} {magenta:Julia} $VERSION}$commit_date\n""")
1787-
elseif size==1# Text only
1788-
print(io,styled"""{bold:{blue:∴} {magenta:Julia} $VERSION}$commit_date $commit_string\n""")
1727+
commit_date=isempty(Base.GIT_VERSION_INFO.date_string)?"":" ($(split(Base.GIT_VERSION_INFO.date_string)[1]))"
1728+
1729+
ifget(io,:color,false)::Bool
1730+
c= Base.text_colors
1731+
tx= c[:normal]# text
1732+
jl= c[:normal]# julia
1733+
d1= c[:bold]* c[:blue]# first dot
1734+
d2= c[:bold]* c[:red]# second dot
1735+
d3= c[:bold]* c[:green]# third dot
1736+
d4= c[:bold]* c[:magenta]# fourth dot
1737+
1738+
if short
1739+
print(io,"""
1740+
$(d3)o$(tx) | Version$(VERSION)$(commit_date)
1741+
$(d2)o$(tx)$(d4)o$(tx) |$(commit_string)
1742+
""")
1743+
else
1744+
print(io,"""$(d3)_$(tx)
1745+
$(d1)_$(tx)$(jl)_$(tx)$(d2)_$(d3)(_)$(d4)_$(tx) | Documentation: https://docs.julialang.org
1746+
$(d1)(_)$(jl) |$(d2)(_)$(tx)$(d4)(_)$(tx) |
1747+
$(jl)_ _ _| |_ __ _$(tx) | Type\"?\" for help,\"]?\" for Pkg help.
1748+
$(jl)| | | | | | |/ _` |$(tx) |
1749+
$(jl)| | |_| | | | (_| |$(tx) | Version$(VERSION)$(commit_date)
1750+
$(jl)_/ |\\__'_|_|_|\\__'_|$(tx) |$(commit_string)
1751+
$(jl)|__/$(tx) |
1752+
1753+
""")
1754+
end
1755+
else
1756+
if short
1757+
print(io,"""
1758+
o | Version$(VERSION)$(commit_date)
1759+
o o |$(commit_string)
1760+
""")
1761+
else
1762+
print(io,"""
1763+
_
1764+
_ _ _(_)_ | Documentation: https://docs.julialang.org
1765+
(_) | (_) (_) |
1766+
_ _ _| |_ __ _ | Type\"?\" for help,\"]?\" for Pkg help.
1767+
| | | | | | |/ _` | |
1768+
| | |_| | | | (_| | | Version$(VERSION)$(commit_date)
1769+
_/ |\\__'_|_|_|\\__'_| |$(commit_string)
1770+
|__/ |
1771+
1772+
""")
1773+
end
17891774
end
17901775
end
17911776

‎stdlib/REPL/src/precompile.jl‎

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -223,20 +223,6 @@ let
223223
precompile(Tuple{typeof(Base.setindex!), Base.Dict{Any, Any}, Any, Int})
224224
precompile(Tuple{typeof(Base.delete!), Base.Set{Any}, String})
225225
precompile(Tuple{typeof(Base.:(==)), Char, String})
226-
# For the banner
227-
#TODO: Fix precompilation so this is no longer needed
228-
precompile(Tuple{typeof(Base.AnnotatedDisplay.ansi_write),typeof(Base.write), Base.TTY, Base.AnnotatedString{String}})
229-
precompile(Tuple{typeof(Base.all), Tuple{Bool, Bool}})
230-
precompile(Tuple{typeof(Base.get), Base.Dict{Tuple{Symbol, Any}, Int64}, Tuple{Symbol, REPL.StyledStrings.Face}, Int64})
231-
precompile(Tuple{typeof(Base.get), Base.Dict{Tuple{Symbol, Any}, Int64}, Tuple{Symbol, String}, Int64})
232-
precompile(Tuple{typeof(Base.get), Base.Dict{Tuple{Symbol, Any}, Int64}, Tuple{Symbol, Symbol}, Int64})
233-
precompile(Tuple{typeof(Base.hashindex), Tuple{Symbol, String}, Int64})
234-
precompile(Tuple{typeof(Base.isempty), Base.Dict{String, Any}})
235-
precompile(Tuple{typeof(Base.print), Base.TTY, Base.AnnotatedString{String}})
236-
precompile(Tuple{typeof(Base.setindex!), Base.Dict{Tuple{Symbol, Any}, Int64}, Int64, Tuple{Symbol, REPL.StyledStrings.Face}})
237-
precompile(Tuple{typeof(Base.setindex!), Base.Dict{Tuple{Symbol, Any}, Int64}, Int64, Tuple{Symbol, String}})
238-
precompile(Tuple{typeof(Base.setindex!), Base.Dict{Tuple{Symbol, Any}, Int64}, Int64, Tuple{Symbol, Symbol}})
239-
precompile(Tuple{typeof(REPL.banner), Base.TTY})
240226
finally
241227
ccall(:jl_tag_newly_inferred_disable, Cvoid, ())
242228
end

‎stdlib/REPL/test/repl.jl‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1801,9 +1801,9 @@ let io = IOBuffer()
18011801
seek(io,0)
18021802
@testcountlines(io)==9
18031803
take!(io)
1804-
@test REPL.banner(io,:tiny)===nothing
1804+
@test REPL.banner(io; short=true)===nothing
18051805
seek(io,0)
1806-
@testcountlines(io)==1
1806+
@testcountlines(io)==2
18071807
end
18081808

18091809
@testset"Docstrings"begin

‎test/cmdlineargs.jl‎

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -321,21 +321,18 @@ let exename = `$(Base.julia_cmd()) --startup-file=no --color=no`
321321

322322
# --quiet, --banner
323323
let p="print((Base.JLOptions().quiet, Base.JLOptions().banner))"
324-
@testread(`$exename -e$p`, String)=="(0, -1)"
325-
@testread(`$exename -q -e$p`, String)=="(1, 0)"
326-
@testread(`$exename --quiet -e$p`, String)=="(1, 0)"
327-
@testread(`$exename --banner=auto -e$p`, String)=="(0, -1)"
328-
@testread(`$exename --banner=no -e$p`, String)=="(0, 0)"
329-
@testread(`$exename --banner=yes -e$p`, String)=="(0, 1)"
330-
@testread(`$exename --banner=full -e$p`, String)=="(0, 1)"
331-
@testread(`$exename -q --banner=no -e$p`, String)=="(1, 0)"
332-
@testread(`$exename -q --banner=yes -e$p`, String)=="(1, 1)"
333-
@testread(`$exename -q --banner=tiny -e$p`, String)=="(1, 4)"
334-
@testread(`$exename --banner=no -q -e$p`, String)=="(1, 0)"
335-
@testread(`$exename --banner=yes -q -e$p`, String)=="(1, 1)"
336-
@testread(`$exename --banner=narrow -q -e$p`, String)=="(1, 2)"
337-
@testread(`$exename --banner=short -q -e$p`, String)=="(1, 3)"
338-
@testread(`$exename --banner=tiny -q -e$p`, String)=="(1, 4)"
324+
@testread(`$exename -e$p`, String)=="(0, -1)"
325+
@testread(`$exename -q -e$p`, String)=="(1, 0)"
326+
@testread(`$exename --quiet -e$p`, String)=="(1, 0)"
327+
@testread(`$exename --banner=no -e$p`, String)=="(0, 0)"
328+
@testread(`$exename --banner=yes -e$p`, String)=="(0, 1)"
329+
@testread(`$exename --banner=short -e$p`, String)=="(0, 2)"
330+
@testread(`$exename -q --banner=no -e$p`, String)=="(1, 0)"
331+
@testread(`$exename -q --banner=yes -e$p`, String)=="(1, 1)"
332+
@testread(`$exename -q --banner=short -e$p`, String)=="(1, 2)"
333+
@testread(`$exename --banner=no -q -e$p`, String)=="(1, 0)"
334+
@testread(`$exename --banner=yes -q -e$p`, String)=="(1, 1)"
335+
@testread(`$exename --banner=short -q -e$p`, String)=="(1, 2)"
339336
end
340337

341338
# --home

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp