Terminal control/Dimensions: Difference between revisions

Content added Content deleted
(Rename Perl 6 -> Raku, alphabetize, minor clean-up)
Line 292: Line 292:
fmt.Println(height, width)
fmt.Println(height, width)
}</lang>
}</lang>

=={{header|Nim}}==

<lang nim>import terminal

echo "Terminal width: " & $terminalWidth()
echo "Terminal height: " & $terminalHeight()
</lang>


=={{header|J}}==
=={{header|J}}==
Line 310: Line 302:


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.
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}}==
=={{header|Julia}}==
Line 376: Line 367:
<lang Mathematica>WIDTH=RunThrough["tput cols", ""];
<lang Mathematica>WIDTH=RunThrough["tput cols", ""];
HEIGHT=RunThrough["tput lines", ""];</lang>
HEIGHT=RunThrough["tput lines", ""];</lang>

=={{header|Nim}}==

<lang nim>import terminal

echo "Terminal width: " & $terminalWidth()
echo "Terminal height: " & $terminalHeight()
</lang>


=={{header|OCaml}}==
=={{header|OCaml}}==
Line 394: Line 393:
print "The terminal has $cols columns and $rows lines\n";</lang>
print "The terminal has $cols columns and $rows lines\n";</lang>


=={{header|Perl 6}}==
Using <i>stty</i> just for the heck of it.
<lang perl6>my $stty = qx[stty -a];
my $lines = $stty.match(/ 'rows ' <( \d+/);
my $cols = $stty.match(/ 'columns ' <( \d+/);
say "$lines $cols";</lang>
=={{header|Phix}}==
=={{header|Phix}}==
The buffer is usually somewhat larger (and never smaller) than the current physical screen size. I would guess that most applications are more interested in the latter.
The buffer is usually somewhat larger (and never smaller) than the current physical screen size. I would guess that most applications are more interested in the latter.
Line 491: Line 484:
(charterm-screen-size))
(charterm-screen-size))
</lang>
</lang>

=={{header|Raku}}==
(formerly Perl 6)
Using <i>stty</i> just for the heck of it.
<lang perl6>my $stty = qx[stty -a];
my $lines = $stty.match(/ 'rows ' <( \d+/);
my $cols = $stty.match(/ 'columns ' <( \d+/);
say "$lines $cols";</lang>


=={{header|Retro}}==
=={{header|Retro}}==
Line 568: Line 569:
val (lines, columns) = (System.getenv("LINES"), System.getenv("COLUMNS"))
val (lines, columns) = (System.getenv("LINES"), System.getenv("COLUMNS"))
println(s"Lines = $lines, Columns = $columns")</lang>
println(s"Lines = $lines, Columns = $columns")</lang>

=={{header|Seed7}}==
=={{header|Seed7}}==
The functions [http://seed7.sourceforge.net/libraries/console.htm#height%28ref_console_file%29 height] and
The functions [http://seed7.sourceforge.net/libraries/console.htm#height%28ref_console_file%29 height] and