Skip to content

Commit

Permalink
Fix undefined displaysize on 0.4 (#1060)
Browse files Browse the repository at this point in the history
  • Loading branch information
ararslan authored and nalimilan committed Sep 8, 2016
1 parent d1fc340 commit 1479020
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
6 changes: 6 additions & 0 deletions src/DataFrames.jl
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ export @~,
##
##############################################################################

if VERSION < v"0.5.0-dev+2023"
_displaysize(x...) = Base.tty_size()
else
const _displaysize = Base.displaysize
end

for (dir, filename) in [
("other", "utils.jl"),
("other", "index.jl"),
Expand Down
2 changes: 1 addition & 1 deletion src/abstractdataframe/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ end
write(io, "<th>$column_name</th>")
end
write(io, "</tr>")
tty_rows, tty_cols = Base.displaysize(io)
tty_rows, tty_cols = _displaysize(io)
mxrow = min(n,tty_rows)
for row in 1:mxrow
write(io, "<tr>")
Expand Down
11 changes: 3 additions & 8 deletions src/abstractdataframe/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,6 @@ function getprintedwidth(maxwidths::Vector{Int}) # -> Int
return totalwidth
end

# For Julia < 0.5
if VERSION < v"0.5.0-dev+2023"
displaysize(io::IO) = Base.tty_size()
end

#' @description
#'
#' When rendering an AbstractDataFrame to a REPL window in chunks, each of
Expand Down Expand Up @@ -199,7 +194,7 @@ end
#' chunkbounds = getchunkbounds(maxwidths, true)
function getchunkbounds(maxwidths::Vector{Int},
splitchunks::Bool,
availablewidth::Int=displaysize()[2]) # -> Vector{Int}
availablewidth::Int=_displaysize()[2]) # -> Vector{Int}
ncols = length(maxwidths) - 1
rowmaxwidth = maxwidths[ncols + 1]
if splitchunks
Expand Down Expand Up @@ -340,7 +335,7 @@ function showrows(io::IO,
end

rowmaxwidth = maxwidths[ncols + 1]
chunkbounds = getchunkbounds(maxwidths, splitchunks, displaysize(io)[2])
chunkbounds = getchunkbounds(maxwidths, splitchunks, _displaysize(io)[2])
nchunks = length(chunkbounds) - 1

for chunkindex in 1:nchunks
Expand Down Expand Up @@ -446,7 +441,7 @@ function Base.show(io::IO,
rowlabel::Symbol = @compat(Symbol("Row")),
displaysummary::Bool = true) # -> Void
nrows = size(df, 1)
dsize = displaysize(io)
dsize = _displaysize(io)
availableheight = dsize[1] - 5
nrowssubset = fld(availableheight, 2)
bound = min(nrowssubset - 1, nrows)
Expand Down

0 comments on commit 1479020

Please sign in to comment.