Skip to content

Commit

Permalink
rename iosize to displaysize (ref #13825)
Browse files Browse the repository at this point in the history
  • Loading branch information
vtjnash committed Jan 7, 2016
1 parent 452f903 commit a378b60
Show file tree
Hide file tree
Showing 16 changed files with 38 additions and 38 deletions.
12 changes: 6 additions & 6 deletions base/Terminals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import Base:
flush,
read,
readuntil,
iosize,
displaysize,
start_reading,
stop_reading,
write,
Expand All @@ -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")
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down
8 changes: 4 additions & 4 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions base/dict.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions base/docs/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion base/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1146,7 +1146,7 @@ export
htol,
hton,
IOContext,
iosize,
displaysize,
ismarked,
isopen,
isreadonly,
Expand Down
2 changes: 1 addition & 1 deletion base/interactiveutil.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion base/markdown/render/terminal/render.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion base/pkg/entry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
Expand Down
2 changes: 1 addition & 1 deletion base/profile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion base/range.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
Expand Down
4 changes: 2 additions & 2 deletions base/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion base/sparse/sparsematrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion base/sparse/sparsevector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions base/stream.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion doc/stdlib/io-network.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions test/dict.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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]
Expand All @@ -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), "")
Expand Down

0 comments on commit a378b60

Please sign in to comment.