Skip to content

Commit ffd34d8

Browse files
committed
Changed terminal_size() method in utils.jl to use Base.displaysize
method. Left terminal_size(io) unchanged. Flipped height and width for displaysize return values. This fixes the "Inappropriate ioctl for device" error when running in an interactive repl.
1 parent b91bd4a commit ffd34d8

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Diff for: src/utils.jl

+8-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,15 @@ const HEIGHT = Ref{Int}()
66
const MODE = Ref{Symbol}(:default)
77

88
function terminal_size(io)
9-
return displaysize(stdout)
9+
ws = IOCTL.ioctl(io, IOCTL.TIOCGWINSZ)
10+
# width, height
11+
return (Int(ws.ws_col), Int(ws.ws_row))
12+
end
13+
14+
function terminal_size()
15+
ds = displaysize(stdout)
16+
return (last(ds), first(ds))
1017
end
11-
terminal_size() = terminal_size(stdout)
1218

1319
terminal_size(io, coord::Int) = terminal_size(io)[coord]
1420
terminal_size(coord::Int) = terminal_size(stdout, coord)

0 commit comments

Comments
 (0)