Terminal control/Dimensions: Difference between revisions

m
m (syntax highlighting fixup automation)
m (→‎{{header|Wren}}: Minor tidy)
 
(3 intermediate revisions by 3 users not shown)
Line 127:
Number of rows: 24
</pre>
 
=={{header|AppleScript}}==
<syntaxhighlight lang="AppleScript">local numColumns, numRows
tell application "Terminal"
if not running then activate
set {numColumns, numRows} to {number of columns, number of rows} of tab 1 of window 1
end tell
</syntaxhighlight>
 
=={{header|Applesoft BASIC}}==
Line 547 ⟶ 555:
20 |getwh,@w%,@h% ' call RSX and pass variables as pointers
30 PRINT "window width:"; w%; ", height:"; h%</syntaxhighlight>
 
But the fastest way is still to use the system values ​​for the current window :
 
<syntaxhighlight lang="locobasic">10 PRINT "window width:"PEEK(&B72C)+1", height:"PEEK(&B72B)+1
</syntaxhighlight>
 
=={{header|Mathematica}}/{{header|Wolfram Language}}==
Line 826 ⟶ 839:
echo "The terminal is $WIDTH characters wide and has $HEIGHT lines."</syntaxhighlight>
 
=={{header|Visual Basic .NET}}==
{{trans|C#}}
<syntaxhighlight lang="vb">Module Module1
Line 867 ⟶ 880:
=={{header|Wren}}==
As there is currently no way to obtain this information via Wren CLI, we instead embed a Wren script in a C application and ask the host program to get it for us.
<syntaxhighlight lang="ecmascriptwren">/* terminal_control_dimensionsTerminal_control_Dimensions.wren */
 
class C {
Line 881 ⟶ 894:
<br>
We now embed this Wren script in the following C program, compile and run it.
<syntaxhighlight lang="c">#include/* <stdlibgcc Terminal_control_Dimensions.h>c -o Terminal_control_Dimensions -lwren -lm */
 
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
Line 956 ⟶ 971:
WrenVM* vm = wrenNewVM(&config);
const char* module = "main";
const char* fileName = "terminal_control_dimensionsTerminal_control_Dimensions.wren";
char *script = readFile(fileName);
WrenInterpretResult result = wrenInterpret(vm, module, script);
9,476

edits