Terminal control/Dimensions: Difference between revisions

Line 313:
 
=={{header|Julia}}==
<lang julia>
Note that with many modern graphical displays the dimensions found will usually reflect the terminal window in which Julia is run, not the entire screen, unless the terminal is run full screen.
<lang julia>if Base.Sys.islinux()using Gtk
 
run(`export LINES COLUMNS`)
julia> screen_size()
println("Lines: $(ENV["LINES"])")
(3840, 1080)
println("Columns: $(ENV["COLUMNS"])")
 
elseif Base.Sys.iswindows()
julia>
txt = split(read(`mode`, String), "\n")
for line in txt
m = match(r"ines:\s+(\d+)|umns:\s+(\d+)", line)
if m != nothing
if m.captures[1] != nothing
println("Lines: $(m.captures[1])")
else
println("Columns: $(m.captures[2])")
end
end
end
end
</lang>
 
4,103

edits