Terminal control/Dimensions: Difference between revisions

(Added nim implementation.)
Line 310:
 
Note also that this will typically include 37 extra pixels horizontally and 79 extra pixels vertically, which are not available to display text. In other words, if the result was 700 500 you would really have 663 pixels of width and 421 pixels of height.
 
 
=={{header|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()
run(`export LINES COLUMNS`)
println("Lines: $(ENV["LINES"])")
println("Columns: $(ENV["COLUMNS"])")
elseif Base.Sys.iswindows()
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>
 
=={{header|Kotlin}}==
4,105

edits