From a378b60fe483130d0d30206deb8ba662e93944da Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Wed, 6 Jan 2016 20:01:14 -0500 Subject: [PATCH] rename iosize to displaysize (ref #13825) --- base/Terminals.jl | 12 ++++++------ base/deprecated.jl | 8 ++++---- base/dict.jl | 4 ++-- base/docs/utils.jl | 12 ++++++------ base/exports.jl | 2 +- base/interactiveutil.jl | 2 +- base/markdown/render/terminal/render.jl | 2 +- base/pkg/entry.jl | 2 +- base/profile.jl | 2 +- base/range.jl | 2 +- base/show.jl | 4 ++-- base/sparse/sparsematrix.jl | 2 +- base/sparse/sparsevector.jl | 2 +- base/stream.jl | 12 ++++++------ doc/stdlib/io-network.rst | 2 +- test/dict.jl | 6 +++--- 16 files changed, 38 insertions(+), 38 deletions(-) diff --git a/base/Terminals.jl b/base/Terminals.jl index 384671f065946..4e23bd1af6b09 100644 --- a/base/Terminals.jl +++ b/base/Terminals.jl @@ -29,7 +29,7 @@ import Base: flush, read, readuntil, - iosize, + displaysize, start_reading, stop_reading, write, @@ -43,7 +43,7 @@ import Base: abstract TextTerminal <: Base.IO # INTERFACE -iosize(::TextTerminal) = error("Unimplemented") +displaysize(::TextTerminal) = error("Unimplemented") writepos(t::TextTerminal, x, y, s::Array{UInt8,1}) = error("Unimplemented") cmove(t::TextTerminal, x, y) = error("Unimplemented") getX(t::TextTerminal) = error("Unimplemented") @@ -88,8 +88,8 @@ function writepos(t::TextTerminal, x, y, args...) cmove(t, x, y) write(t, args...) end -width(t::TextTerminal) = iosize(t)[2] -height(t::TextTerminal) = iosize(t)[1] +width(t::TextTerminal) = displaysize(t)[2] +height(t::TextTerminal) = displaysize(t)[1] # For terminals with buffers flush(t::TextTerminal) = nothing @@ -158,8 +158,8 @@ disable_bracketed_paste(t::UnixTerminal) = write(t.out_stream, "$(CSI)?2004l") end_keypad_transmit_mode(t::UnixTerminal) = # tput rmkx write(t.out_stream, "$(CSI)?1l\x1b>") -function Base.iosize(t::UnixTerminal) - return iosize(t.out_stream) +function Base.displaysize(t::UnixTerminal) + return displaysize(t.out_stream) end clear(t::UnixTerminal) = write(t.out_stream, "\x1b[H\x1b[2J") diff --git a/base/deprecated.jl b/base/deprecated.jl index f90b13a3d4608..6e508af9ed3f5 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -921,17 +921,17 @@ export isreadable, iswritable, isexecutable @deprecate RemoteRef RemoteChannel function tty_size() - depwarn("tty_size is deprecated. use `iosize(io)` as a replacement", :tty_size) + depwarn("tty_size is deprecated. use `displaysize(io)` as a replacement", :tty_size) if isdefined(Base, :active_repl) os = REPL.outstream(Base.active_repl) if isa(os, Terminals.TTYTerminal) - return iosize(os) + return displaysize(os) end end if isdefined(Base, :STDOUT) - return iosize(STDOUT) + return displaysize(STDOUT) end - return iosize() + return displaysize() end #14335 diff --git a/base/dict.jl b/base/dict.jl index 2c0788fafd147..e4e49c09c136d 100644 --- a/base/dict.jl +++ b/base/dict.jl @@ -98,7 +98,7 @@ function showdict{K,V}(io::IO, t::Associative{K,V}; compact = false) isempty(t) && return print(io, ":") if limit - sz = iosize(io) + sz = displaysize(io) rows, cols = sz[1] - 3, sz[2] rows < 2 && (print(io, " …"); return) cols < 12 && (cols = 12) # Minimum widths of 2 for key, 4 for value @@ -158,7 +158,7 @@ function showkv{T<:Union{KeyIterator,ValueIterator}}(io::IO, iter::T) print(io, ". ", T<:KeyIterator ? "Keys" : "Values", ":") limit::Bool = limit_output(io) if limit - sz = iosize(io) + sz = displaysize(io) rows, cols = sz[1] - 3, sz[2] rows < 2 && (print(io, " …"); return) cols < 4 && (cols = 4) diff --git a/base/docs/utils.jl b/base/docs/utils.jl index 8ba9e82c230b7..3f69f691d2a53 100644 --- a/base/docs/utils.jl +++ b/base/docs/utils.jl @@ -94,7 +94,7 @@ end function repl_search(io::IO, s) pre = "search:" print(io, pre) - printmatches(io, s, completions(s), cols = iosize(io)[2] - length(pre)) + printmatches(io, s, completions(s), cols = displaysize(io)[2] - length(pre)) println(io, "\n") end @@ -243,7 +243,7 @@ end printmatch(args...) = printfuzzy(STDOUT, args...) -function printmatches(io::IO, word, matches; cols = iosize(io)[2]) +function printmatches(io::IO, word, matches; cols = displaysize(io)[2]) total = 0 for match in matches total + length(match) + 1 > cols && break @@ -254,9 +254,9 @@ function printmatches(io::IO, word, matches; cols = iosize(io)[2]) end end -printmatches(args...; cols = iosize(STDOUT)[2]) = printmatches(STDOUT, args..., cols = cols) +printmatches(args...; cols = displaysize(STDOUT)[2]) = printmatches(STDOUT, args..., cols = cols) -function print_joined_cols(io::IO, ss, delim = "", last = delim; cols = iosize(io)[2]) +function print_joined_cols(io::IO, ss, delim = "", last = delim; cols = displaysize(io)[2]) i = 0 total = 0 for i = 1:length(ss) @@ -266,13 +266,13 @@ function print_joined_cols(io::IO, ss, delim = "", last = delim; cols = iosize(i print_joined(io, ss[1:i], delim, last) end -print_joined_cols(args...; cols = iosize(STDOUT)[2]) = print_joined_cols(STDOUT, args...; cols=cols) +print_joined_cols(args...; cols = displaysize(STDOUT)[2]) = print_joined_cols(STDOUT, args...; cols=cols) function print_correction(io, word) cors = levsort(word, accessible(current_module())) pre = "Perhaps you meant " print(io, pre) - print_joined_cols(io, cors, ", ", " or "; cols = iosize(io)[2] - length(pre)) + print_joined_cols(io, cors, ", ", " or "; cols = displaysize(io)[2] - length(pre)) println(io) return end diff --git a/base/exports.jl b/base/exports.jl index 76044cc203a5a..71a5fc37be959 100644 --- a/base/exports.jl +++ b/base/exports.jl @@ -1146,7 +1146,7 @@ export htol, hton, IOContext, - iosize, + displaysize, ismarked, isopen, isreadonly, diff --git a/base/interactiveutil.jl b/base/interactiveutil.jl index aff24694ad3ac..654ef2f10d523 100644 --- a/base/interactiveutil.jl +++ b/base/interactiveutil.jl @@ -430,7 +430,7 @@ Print information about exported global variables in a module, optionally restri The memory consumption estimate is an approximate lower bound on the size of the internal structure of the object. """ function whos(io::IO=STDOUT, m::Module=current_module(), pattern::Regex=r"") - maxline = iosize(io)[2] + maxline = displaysize(io)[2] line = zeros(UInt8, maxline) head = PipeBuffer(maxline + 1) for v in sort!(names(m)) diff --git a/base/markdown/render/terminal/render.jl b/base/markdown/render/terminal/render.jl index 2f1c495a6ce14..eeb498b6f995f 100644 --- a/base/markdown/render/terminal/render.jl +++ b/base/markdown/render/terminal/render.jl @@ -3,7 +3,7 @@ include("formatting.jl") const margin = 2 -cols(io) = iosize(io)[2] +cols(io) = displaysize(io)[2] function term(io::IO, content::Vector, cols) isempty(content) && return diff --git a/base/pkg/entry.jl b/base/pkg/entry.jl index 43af5350a6bb7..9f4f7675f115d 100644 --- a/base/pkg/entry.jl +++ b/base/pkg/entry.jl @@ -490,7 +490,7 @@ function resolve( end function warnbanner(msg...; label="[ WARNING ]", prefix="") - cols = Base.iosize(STDERR)[2] + cols = Base.displaysize(STDERR)[2] warn(prefix="", Base.cpad(label,cols,"=")) println(STDERR) warn(prefix=prefix, msg...) diff --git a/base/profile.jl b/base/profile.jl index 6c9469cd99208..4703046e4ab86 100644 --- a/base/profile.jl +++ b/base/profile.jl @@ -81,7 +81,7 @@ function print{T<:Unsigned}(io::IO, data::Vector{T} = fetch(), lidict::Dict = ge combine = true, maxdepth::Int = typemax(Int), sortedby::Symbol = :filefuncline) - cols = Base.iosize(io)[2] + cols = Base.displaysize(io)[2] if format == :tree tree(io, data, lidict, C, combine, cols, maxdepth) elseif format == :flat diff --git a/base/range.jl b/base/range.jl index c28aa8c42c714..93eb9f4d70219 100644 --- a/base/range.jl +++ b/base/range.jl @@ -266,7 +266,7 @@ function print_range(io::IO, r::Range, # This function borrows from print_matrix() in show.jl # and should be called by writemime (replutil.jl) and by display() limit = limit_output(io) - sz = iosize(io) + sz = displaysize(io) screenheight, screenwidth = sz[1] - 4, sz[2] screenwidth -= length(pre) + length(post) postsp = "" diff --git a/base/show.jl b/base/show.jl index 326d876845214..027b95bbbd2e1 100644 --- a/base/show.jl +++ b/base/show.jl @@ -67,7 +67,7 @@ limit_output(::ANY) = _limit_output::Bool limit_output(io::IOContext) = get(io, :limit_output, _limit_output::Bool) === true _limit_output = false # delete with with_output_limit deprecation -iosize(io::IOContext) = haskey(io, :iosize) ? io[:iosize] : iosize(io.io) +displaysize(io::IOContext) = haskey(io, :displaysize) ? io[:displaysize] : displaysize(io.io) show(io::IO, x::ANY) = show_default(io, x) @@ -1197,7 +1197,7 @@ function print_matrix(io::IO, X::AbstractVecOrMat, if !limit_output(io) screenheight = screenwidth = typemax(Int) else - sz = iosize(io) + sz = displaysize(io) screenheight, screenwidth = sz[1] - 4, sz[2] end screenwidth -= length(pre) + length(post) diff --git a/base/sparse/sparsematrix.jl b/base/sparse/sparsematrix.jl index 11101bad24c60..fb1a5cd516a74 100644 --- a/base/sparse/sparsematrix.jl +++ b/base/sparse/sparsematrix.jl @@ -85,7 +85,7 @@ function Base.showarray(io::IO, S::SparseMatrixCSC; limit::Bool = Base.limit_output(io) if limit - rows = iosize(io)[1] + rows = displaysize(io)[1] half_screen_rows = div(rows - 8, 2) else half_screen_rows = typemax(Int) diff --git a/base/sparse/sparsevector.jl b/base/sparse/sparsevector.jl index 23e1f71afc667..78d0ab610bb1c 100644 --- a/base/sparse/sparsevector.jl +++ b/base/sparse/sparsevector.jl @@ -597,7 +597,7 @@ function showarray(io::IO, x::AbstractSparseVector; end limit::Bool = Base.limit_output(io) - half_screen_rows = limit ? div(iosize(io)[1] - 8, 2) : typemax(Int) + half_screen_rows = limit ? div(displaysize(io)[1] - 8, 2) : typemax(Int) pad = ndigits(n) sep = "\n\t" for k = 1:length(nzind) diff --git a/base/stream.jl b/base/stream.jl index d8e0ff76b90bb..01d5c7c15c3a2 100644 --- a/base/stream.jl +++ b/base/stream.jl @@ -383,15 +383,15 @@ end ispty(s::IO) = false end -" iosize(io) -> (lines, columns) +" displaysize(io) -> (lines, columns) Return the nominal size of the screen that may be used for rendering output to this io object" -iosize(io::IO) = iosize() -iosize() = (parse(Int, get(ENV, "LINES", "24")), - parse(Int, get(ENV, "COLUMNS", "80")))::Tuple{Int, Int} +displaysize(io::IO) = displaysize() +displaysize() = (parse(Int, get(ENV, "LINES", "24")), + parse(Int, get(ENV, "COLUMNS", "80")))::Tuple{Int, Int} -function iosize(io::TTY) +function displaysize(io::TTY) local h::Int, w::Int - default_size = iosize() + default_size = displaysize() @windows_only if ispty(io) # io is actually a libuv pipe but a cygwin/msys2 pty diff --git a/doc/stdlib/io-network.rst b/doc/stdlib/io-network.rst index d2e702e23d318..2dc48956a0ec8 100644 --- a/doc/stdlib/io-network.rst +++ b/doc/stdlib/io-network.rst @@ -624,7 +624,7 @@ Text I/O Decodes the base64-encoded ``string`` and returns a ``Vector{UInt8}`` of the decoded bytes. -.. function:: iosize(io) -> (lines, columns) +.. function:: displaysize(io) -> (lines, columns) .. Docstring generated from Julia source diff --git a/test/dict.jl b/test/dict.jl index 5a953b1a8db64..7a1c7700c4628 100644 --- a/test/dict.jl +++ b/test/dict.jl @@ -257,7 +257,7 @@ for d in (Dict("\n" => "\n", "1" => "\n", "\n" => "2"), for cols in (12, 40, 80), rows in (2, 10, 24) # Ensure output is limited as requested s = IOBuffer() - io = Base.IOContext(Base.IOContext(s, :limit_output => true), :iosize => (rows, cols)) + io = Base.IOContext(Base.IOContext(s, :limit_output => true), :displaysize => (rows, cols)) Base.showdict(io, d) out = split(takebuf_string(s),'\n') for line in out[2:end] @@ -267,7 +267,7 @@ for d in (Dict("\n" => "\n", "1" => "\n", "\n" => "2"), for f in (keys, values) s = IOBuffer() - io = Base.IOContext(Base.IOContext(s, :limit_output => true), :iosize => (rows, cols)) + io = Base.IOContext(Base.IOContext(s, :limit_output => true), :displaysize => (rows, cols)) Base.showkv(io, f(d)) out = split(takebuf_string(s),'\n') for line in out[2:end] @@ -287,7 +287,7 @@ end type Alpha end Base.show(io::IO, ::Alpha) = print(io,"α") let sbuff = IOBuffer(), - io = Base.IOContext(Base.IOContext(sbuff, :limit_output => true), :iosize => (10, 20)) + io = Base.IOContext(Base.IOContext(sbuff, :limit_output => true), :displaysize => (10, 20)) Base.showdict(io, Dict(Alpha()=>1)) @test !contains(bytestring(sbuff), "…")