Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
5
Task/Terminal-control-Dimensions/00-META.yaml
Normal file
5
Task/Terminal-control-Dimensions/00-META.yaml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
category:
|
||||
- Initialization
|
||||
from: http://rosettacode.org/wiki/Terminal_control/Dimensions
|
||||
note: Terminal control
|
||||
2
Task/Terminal-control-Dimensions/00-TASK.txt
Normal file
2
Task/Terminal-control-Dimensions/00-TASK.txt
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
Determine the height and width of the terminal, and store this information into variables for subsequent use.
|
||||
[[Terminal Control::task| ]]
|
||||
|
|
@ -0,0 +1,93 @@
|
|||
/* ARM assembly AARCH64 Raspberry PI 3B */
|
||||
/* program terminalSize64.s */
|
||||
|
||||
/*******************************************/
|
||||
/* Constantes file */
|
||||
/*******************************************/
|
||||
/* for this file see task include a file in language AArch64 assembly*/
|
||||
.include "../includeConstantesARM64.inc"
|
||||
|
||||
.equ TIOCGWINSZ, 0x5413
|
||||
.equ IOCTL, 0x1D // Linux syscall
|
||||
/*******************************************/
|
||||
/* Structures */
|
||||
/********************************************/
|
||||
/* structure terminal size */
|
||||
.struct 0
|
||||
term_s_lines: // input modes
|
||||
.struct term_s_lines + 2
|
||||
term_s_cols: // output modes
|
||||
.struct term_s_cols + 2
|
||||
term_s_filler: // control modes
|
||||
.struct term_s_filler + 12
|
||||
term_fin:
|
||||
/*******************************************/
|
||||
/* Initialized data */
|
||||
/*******************************************/
|
||||
.data
|
||||
szMessStartPgm: .asciz "Program start \n"
|
||||
szMessEndPgm: .asciz "Program normal end.\n"
|
||||
szMessResult: .asciz "Terminal lines : @ cols : @ \n"
|
||||
szMessErreur: .asciz "\033[31mError IOCTL.\n"
|
||||
szCarriageReturn: .asciz "\n"
|
||||
/*******************************************/
|
||||
/* UnInitialized data */
|
||||
/*******************************************/
|
||||
.bss
|
||||
.align 4
|
||||
sZoneConv: .skip 24
|
||||
stTerminal: .skip term_fin // structure terminal
|
||||
/*******************************************/
|
||||
/* code section */
|
||||
/*******************************************/
|
||||
.text
|
||||
.global main
|
||||
main:
|
||||
ldr x0,qAdrszMessStartPgm //display start message
|
||||
bl affichageMess
|
||||
|
||||
/* read terminal dimensions */
|
||||
mov x0,STDIN // input console
|
||||
mov x1,TIOCGWINSZ // code IOCTL
|
||||
ldr x2,qAdrstTerminal // structure address
|
||||
mov x8,IOCTL // call system Linux
|
||||
svc 0
|
||||
cbnz x0,98f // error ?
|
||||
|
||||
ldr x2,qAdrstTerminal
|
||||
ldrh w0,[x2,term_s_lines] // load two bytes
|
||||
ldr x1,qAdrsZoneConv
|
||||
bl conversion10 // and decimal conversion
|
||||
ldr x0,qAdrszMessResult
|
||||
bl strInsertAtChar // and insertion in message
|
||||
mov x5,x0 // save address of new message
|
||||
ldrh w0,[x2,term_s_cols] // load two bytes
|
||||
ldr x1,qAdrsZoneConv
|
||||
bl conversion10 // and decimal conversion
|
||||
mov x0,x5 // restaur address of message
|
||||
bl strInsertAtChar // and insertion in message
|
||||
bl affichageMess
|
||||
|
||||
ldr x0,qAdrszMessEndPgm //display end message
|
||||
bl affichageMess
|
||||
b 100f
|
||||
98: // error display
|
||||
ldr x0,qAdrszMessErreur
|
||||
bl affichageMess
|
||||
mov x0,-1
|
||||
100: //standard end of the program
|
||||
mov x0,0 //return code
|
||||
mov x8,EXIT //request to exit program
|
||||
svc 0 //perform system call
|
||||
qAdrszMessStartPgm: .quad szMessStartPgm
|
||||
qAdrszMessEndPgm: .quad szMessEndPgm
|
||||
qAdrszMessErreur: .quad szMessErreur
|
||||
qAdrszCarriageReturn: .quad szCarriageReturn
|
||||
qAdrstTerminal: .quad stTerminal
|
||||
qAdrszMessResult: .quad szMessResult
|
||||
qAdrsZoneConv: .quad sZoneConv
|
||||
/********************************************************/
|
||||
/* File Include fonctions */
|
||||
/********************************************************/
|
||||
/* for this file see task include a file in language AArch64 assembly */
|
||||
.include "../includeARM64.inc"
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
PROC Main()
|
||||
BYTE ROWCRS=$0054 ;Current cursor row
|
||||
CARD COLCRS=$0055 ;Current cursor column
|
||||
CARD width
|
||||
BYTE height
|
||||
|
||||
Graphics(0)
|
||||
Position(0,0) ;go to the top-left corner
|
||||
Put(28) Put(30) ;go up and left - the bottom-right corner
|
||||
width=COLCRS+1
|
||||
height=ROWCRS+1
|
||||
|
||||
Position(2,1)
|
||||
PrintF("Number of colums: %U%E",width)
|
||||
PrintF("Number of rows: %B%E",height)
|
||||
RETURN
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
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
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
WIDTH = PEEK(33)
|
||||
HEIGHT = PEEK(35) - PEEK(34)
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
print ["Terminal width:" terminal\width]
|
||||
print ["Terminal height:" terminal\height]
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
DllCall( "AllocConsole" ) ; create a console if not launched from one
|
||||
hConsole := DllCall( "GetStdHandle", int, STDOUT := -11 )
|
||||
|
||||
MsgBox Resize the console...
|
||||
|
||||
VarSetCapacity(csbi, 22) ; CONSOLE_SCREEN_BUFFER_INFO structure
|
||||
DllCall("GetConsoleScreenBufferInfo", UPtr, hConsole, UPtr, &csbi)
|
||||
Left := NumGet(csbi, 10, "short")
|
||||
Top := NumGet(csbi, 12, "short")
|
||||
Right := NumGet(csbi, 14, "short")
|
||||
Bottom := NumGet(csbi, 16, "short")
|
||||
|
||||
columns := right - left + 1
|
||||
rows := bottom - top + 1
|
||||
MsgBox %columns% columns and %rows% rows
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
dx% = @vdu.tr%-@vdu.tl% : REM Width of text viewport in pixels
|
||||
dy% = @vdu.tb%-@vdu.tt% : REM Height of text viewport in pixels
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
PRINT:VDU 8:dx%=POS+1:PRINT : REM Width of text viewport in characters
|
||||
REPEAT:dy%=VPOS:PRINT:UNTIL VPOS=dy%:dy%=dy%+1 : REM Height of text viewport in characters
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
dx% = VDU(10)-VDU(8)+1 : REM Width of text viewport in characters
|
||||
dy% = VDU(9)-VDU(11)+1 : REM Height of text viewport in characters
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
' ANSI terminal dimensions
|
||||
X = COLUMNS
|
||||
Y = ROWS
|
||||
|
||||
PRINT "X,Y: ", X, ",", Y
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
@echo off
|
||||
|
||||
for /f "tokens=1,2 delims= " %%A in ('mode con') do (
|
||||
if "%%A"=="Lines:" set line=%%B
|
||||
if "%%A"=="Columns:" set cols=%%B
|
||||
)
|
||||
|
||||
echo Lines: %line%
|
||||
echo Columns: %cols%
|
||||
exit /b 0
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
#!/bin/csh -f
|
||||
set WIDTH=`tput cols`
|
||||
set HEIGHT=`tput lines`
|
||||
echo "The terminal is $WIDTH characters wide and has $HEIGHT lines."
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
static void Main(string[] args)
|
||||
{
|
||||
int bufferHeight = Console.BufferHeight;
|
||||
int bufferWidth = Console.BufferWidth;
|
||||
int windowHeight = Console.WindowHeight;
|
||||
int windowWidth = Console.WindowWidth;
|
||||
|
||||
Console.Write("Buffer Height: ");
|
||||
Console.WriteLine(bufferHeight);
|
||||
Console.Write("Buffer Width: ");
|
||||
Console.WriteLine(bufferWidth);
|
||||
Console.Write("Window Height: ");
|
||||
Console.WriteLine(windowHeight);
|
||||
Console.Write("Window Width: ");
|
||||
Console.WriteLine(windowWidth);
|
||||
Console.ReadLine();
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
#include <sys/ioctl.h> /* ioctl, TIOCGWINSZ */
|
||||
#include <err.h> /* err */
|
||||
#include <fcntl.h> /* open */
|
||||
#include <stdio.h> /* printf */
|
||||
#include <unistd.h> /* close */
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
struct winsize ws;
|
||||
int fd;
|
||||
|
||||
/* Open the controlling terminal. */
|
||||
fd = open("/dev/tty", O_RDWR);
|
||||
if (fd < 0)
|
||||
err(1, "/dev/tty");
|
||||
|
||||
/* Get window size of terminal. */
|
||||
if (ioctl(fd, TIOCGWINSZ, &ws) < 0)
|
||||
err(1, "/dev/tty");
|
||||
|
||||
printf("%d rows by %d columns\n", ws.ws_row, ws.ws_col);
|
||||
printf("(%d by %d pixels)\n", ws.ws_xpixel, ws.ws_ypixel);
|
||||
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
#include <windows.h>
|
||||
#include <wchar.h>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
HANDLE console;
|
||||
CONSOLE_SCREEN_BUFFER_INFO info;
|
||||
short rows;
|
||||
short columns;
|
||||
/* Create a handle to the console screen. */
|
||||
console = CreateFileW(L"CONOUT$", GENERIC_READ | GENERIC_WRITE,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
|
||||
0, NULL);
|
||||
if (console == INVALID_HANDLE_VALUE)
|
||||
return 1;
|
||||
|
||||
/* Calculate the size of the console window. */
|
||||
if (GetConsoleScreenBufferInfo(console, &info) == 0)
|
||||
return 1;
|
||||
CloseHandle(console);
|
||||
columns = info.srWindow.Right - info.srWindow.Left + 1;
|
||||
rows = info.srWindow.Bottom - info.srWindow.Top + 1;
|
||||
|
||||
wprintf(L"%d columns by %d rows\n", columns, rows);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
IDENTIFICATION DIVISION.
|
||||
PROGRAM-ID. terminal-dimensions.
|
||||
|
||||
DATA DIVISION.
|
||||
WORKING-STORAGE SECTION.
|
||||
01 num-lines PIC 9(3).
|
||||
01 num-cols PIC 9(3).
|
||||
|
||||
SCREEN SECTION.
|
||||
01 display-screen.
|
||||
03 LINE 01 COL 01 PIC 9(3) FROM num-lines.
|
||||
03 LINE 01 COL 05 VALUE "rows by " .
|
||||
03 LINE 01 COL 13 PIC 9(3) FROM num-cols.
|
||||
03 LINE 01 COL 16 VALUE " columns.".
|
||||
|
||||
PROCEDURE DIVISION.
|
||||
ACCEPT num-lines FROM LINES
|
||||
ACCEPT num-cols FROM COLUMNS
|
||||
|
||||
DISPLAY display-screen
|
||||
|
||||
* This pauses the program, as ncurses will immediately revert
|
||||
* back to the console when the program ends.
|
||||
CALL "C$SLEEP" USING BY CONTENT 3
|
||||
|
||||
GOBACK
|
||||
.
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
include graphics.e
|
||||
|
||||
sequence vc
|
||||
integer term_height, term_width
|
||||
|
||||
vc = video_config()
|
||||
|
||||
term_height = vc[VC_LINES]
|
||||
term_width = vc[VC_COLUMNS]
|
||||
|
||||
printf(1,"Terminal height is %d\n",term_height)
|
||||
printf(1,"Terminal width is %d\n",term_width)
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
open System
|
||||
|
||||
let bufferHeight = Console.BufferHeight
|
||||
let bufferWidth = Console.BufferWidth
|
||||
let windowHeight = Console.WindowHeight
|
||||
let windowWidth = Console.WindowWidth
|
||||
|
||||
Console.Write("Buffer Height: ")
|
||||
Console.WriteLine(bufferHeight)
|
||||
Console.Write("Buffer Width: ")
|
||||
Console.WriteLine(bufferWidth)
|
||||
Console.Write("Window Height: ")
|
||||
Console.WriteLine(windowHeight)
|
||||
Console.Write("Window Width: ")
|
||||
Console.WriteLine(windowWidth)
|
||||
Console.ReadLine()
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
variable term-width
|
||||
variable term-height
|
||||
|
||||
s" gforth" environment? [if]
|
||||
2drop form ( height width )
|
||||
[else] \ SwiftForth
|
||||
get-size ( width height ) swap
|
||||
[then]
|
||||
term-width ! term-height !
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
Dim As Integer w, h, p, bpp, tasa
|
||||
Dim driver_name As String
|
||||
Screeninfo w, h, p, bpp, , tasa
|
||||
|
||||
Print !"Informaci¢n sobre el escritorio (terminal):\n"
|
||||
Print " Ancho de la terminal: "; w; " (pixel)"
|
||||
Print "Altura de la terminal: "; h; " (pixel)"
|
||||
Print " Profundidad de color: "; p; " (bits)"
|
||||
Print " Tasa de refresco: "; tasa; " (Hz)"
|
||||
|
||||
' Sets screen mode 13 (640*480, 8bpp)
|
||||
Screen 12
|
||||
Screeninfo w, h, p, bpp, , tasa, driver_name
|
||||
|
||||
Print !"Informaci¢n sobre el modo gr fico:\n"
|
||||
Print " Ancho de la pantalla: "; w; " (pixel)"
|
||||
Print "Altura de la pantalla: "; h; " (pixel)"
|
||||
Print " Profundidad de color: "; p; " (bits)"
|
||||
Print " Bytes por pixel: "; bpp
|
||||
Print " Tasa de refresco: "; tasa; " (Hz)"
|
||||
Print " Nombre del driver: "; driver_name
|
||||
Sleep
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"golang.org/x/crypto/ssh/terminal"
|
||||
)
|
||||
|
||||
func main() {
|
||||
w, h, err := terminal.GetSize(int(os.Stdout.Fd()))
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
fmt.Println(h, w)
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var h, w int
|
||||
cmd := exec.Command("stty", "size")
|
||||
cmd.Stdin = os.Stdin
|
||||
d, _ := cmd.Output()
|
||||
fmt.Sscan(string(d), &h, &w)
|
||||
fmt.Println(h, w)
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"code.google.com/p/goncurses"
|
||||
)
|
||||
|
||||
func main() {
|
||||
s, err := goncurses.Init()
|
||||
if err != nil {
|
||||
log.Fatal("init:", err)
|
||||
}
|
||||
defer goncurses.End()
|
||||
height, width := s.MaxYX()
|
||||
fmt.Println(height, width)
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
_2 {.qsmsize_jijs_''
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
julia> using Gtk
|
||||
|
||||
julia> screen_size()
|
||||
(3840, 1080)
|
||||
|
||||
julia>
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
// version 1.1.2
|
||||
|
||||
/*
|
||||
I needed to execute the terminal command: 'export COLUMNS LINES'
|
||||
before running this program for it to work (returned 'null' sizes otherwise).
|
||||
*/
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val lines = System.getenv("LINES")
|
||||
val columns = System.getenv("COLUMNS")
|
||||
println("Lines = $lines")
|
||||
println("Columns = $columns")
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
4000 d5 push de
|
||||
4001 e5 push hl
|
||||
4002 cd 69 bb call &bb69
|
||||
4005 ed 53 20 40 ld (&4020),de
|
||||
4009 22 22 40 ld (&4022),hl
|
||||
400c e1 pop hl
|
||||
400d d1 pop de
|
||||
400e c9 ret
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
10 s=&4000:SYMBOL AFTER 256:MEMORY s-1
|
||||
20 FOR i=0 to 14:READ a:POKE s+i,a:NEXT
|
||||
30 DATA &d5,&e5,&cd,&69,&bb,&ed,&53,&20,&40,&22,&22,&40,&e1,&d1,&c9
|
||||
40 CALL s
|
||||
50 h=PEEK(&4020)-PEEK(&4022)+1
|
||||
60 w=PEEK(&4021)-PEEK(&4023)+1
|
||||
70 PRINT "window width:"; w; ", height:"; h
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
10 w%=0:h%=0 ' initialize and force integer type
|
||||
20 |getwh,@w%,@h% ' call RSX and pass variables as pointers
|
||||
30 PRINT "window width:"; w%; ", height:"; h%
|
||||
|
|
@ -0,0 +1 @@
|
|||
10 PRINT "window width:"PEEK(&B72C)+1", height:"PEEK(&B72B)+1
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
WIDTH=RunThrough["tput cols", ""];
|
||||
HEIGHT=RunThrough["tput lines", ""];
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
import terminal
|
||||
|
||||
let (width, height) = terminalSize()
|
||||
|
||||
echo "Terminal width: ", width
|
||||
echo "Terminal height: ", height
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
$ ocaml unix.cma -I +ANSITerminal ANSITerminal.cma
|
||||
|
||||
# let width, height = ANSITerminal.size () ;;
|
||||
val width : int = 126
|
||||
val height : int = 47
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
use Term::Size;
|
||||
|
||||
($cols, $rows) = Term::Size::chars;
|
||||
print "The terminal has $cols columns and $rows lines\n";
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
(notonline)-->
|
||||
<span style="color: #008080;">without</span> <span style="color: #008080;">js</span> <span style="color: #000080;font-style:italic;">-- (video_config)</span>
|
||||
<span style="color: #004080;">sequence</span> <span style="color: #000000;">vc</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">video_config</span><span style="color: #0000FF;">()</span>
|
||||
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Terminal buffer height is %d\n"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">vc</span><span style="color: #0000FF;">[</span><span style="color: #000000;">VC_LINES</span><span style="color: #0000FF;">])</span>
|
||||
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Terminal buffer width is %d\n"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">vc</span><span style="color: #0000FF;">[</span><span style="color: #000000;">VC_COLUMNS</span><span style="color: #0000FF;">])</span>
|
||||
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Terminal screen height is %d\n"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">vc</span><span style="color: #0000FF;">[</span><span style="color: #004600;">VC_SCRNLINES</span><span style="color: #0000FF;">])</span>
|
||||
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Terminal screen width is %d\n"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">vc</span><span style="color: #0000FF;">[</span><span style="color: #000000;">VC_SCRNCOLS</span><span style="color: #0000FF;">])</span>
|
||||
<!--
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
(setq
|
||||
Width (in '(tput cols) (read))
|
||||
Height (in '(tput lines) (read)) )
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
Macro ConsoleHandle()
|
||||
GetStdHandle_( #STD_OUTPUT_HANDLE )
|
||||
EndMacro
|
||||
|
||||
Procedure ConsoleWidth()
|
||||
Protected CBI.CONSOLE_SCREEN_BUFFER_INFO
|
||||
Protected hConsole = ConsoleHandle()
|
||||
GetConsoleScreenBufferInfo_( hConsole, @CBI )
|
||||
ProcedureReturn CBI\srWindow\right - CBI\srWindow\left + 1
|
||||
EndProcedure
|
||||
|
||||
Procedure ConsoleHeight()
|
||||
Protected CBI.CONSOLE_SCREEN_BUFFER_INFO
|
||||
Protected hConsole = ConsoleHandle()
|
||||
GetConsoleScreenBufferInfo_( hConsole, @CBI )
|
||||
ProcedureReturn CBI\srWindow\bottom - CBI\srWindow\top + 1
|
||||
EndProcedure
|
||||
|
||||
If OpenConsole()
|
||||
x$=Str(ConsoleWidth())
|
||||
y$=Str(ConsoleHeight())
|
||||
PrintN("This window is "+x$+"x"+y$+ " chars.")
|
||||
;
|
||||
Print(#CRLF$+"Press ENTER to exit"):Input()
|
||||
EndIf
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
import os
|
||||
|
||||
def get_windows_terminal():
|
||||
from ctypes import windll, create_string_buffer
|
||||
h = windll.kernel32.GetStdHandle(-12)
|
||||
csbi = create_string_buffer(22)
|
||||
res = windll.kernel32.GetConsoleScreenBufferInfo(h, csbi)
|
||||
|
||||
#return default size if actual size can't be determined
|
||||
if not res: return 80, 25
|
||||
|
||||
import struct
|
||||
(bufx, bufy, curx, cury, wattr, left, top, right, bottom, maxx, maxy)\
|
||||
= struct.unpack("hhhhHhhhhhh", csbi.raw)
|
||||
width = right - left + 1
|
||||
height = bottom - top + 1
|
||||
|
||||
return width, height
|
||||
|
||||
def get_linux_terminal():
|
||||
width = os.popen('tput cols', 'r').readline()
|
||||
height = os.popen('tput lines', 'r').readline()
|
||||
|
||||
return int(width), int(height)
|
||||
|
||||
print get_linux_terminal() if os.name == 'posix' else get_windows_terminal()
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
width = 'tput'( 'cols' )
|
||||
height = 'tput'( 'lines' )
|
||||
|
||||
say 'The terminal is' width 'characters wide'
|
||||
say 'and has' height 'lines'
|
||||
|
|
@ -0,0 +1 @@
|
|||
width=linesize()
|
||||
|
|
@ -0,0 +1 @@
|
|||
parse value scrsize() with sd sw
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
#lang racket
|
||||
(require (planet neil/charterm:3:0))
|
||||
(with-charterm
|
||||
(charterm-screen-size))
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
my $stty = qx[stty -a];
|
||||
my $lines = $stty.match(/ 'rows ' <( \d+/);
|
||||
my $cols = $stty.match(/ 'columns ' <( \d+/);
|
||||
say "$lines $cols";
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
-3 5 out wait 5 in !cw
|
||||
-4 5 out wait 5 in !ch
|
||||
|
|
@ -0,0 +1 @@
|
|||
system("mode 50,20")
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
def winsize
|
||||
# Ruby 1.9.3 added 'io/console' to the standard library.
|
||||
require 'io/console'
|
||||
IO.console.winsize
|
||||
rescue LoadError
|
||||
# This works with older Ruby, but only with systems
|
||||
# that have a tput(1) command, such as Unix clones.
|
||||
[Integer(`tput li`), Integer(`tput co`)]
|
||||
end
|
||||
|
||||
rows, cols = winsize
|
||||
printf "%d rows by %d columns\n", rows, cols
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
require 'curses'
|
||||
|
||||
begin
|
||||
Curses.init_screen
|
||||
|
||||
r, c = Curses.lines, Curses.cols
|
||||
|
||||
Curses.setpos r / 2, 0
|
||||
Curses.addstr "#{r} rows by #{c} columns".center(c)
|
||||
Curses.getch
|
||||
ensure
|
||||
Curses.close_screen
|
||||
end
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
/*
|
||||
First execute the terminal command: 'export COLUMNS LINES'
|
||||
before running this program for it to work (returned 'null' sizes otherwise).
|
||||
*/
|
||||
|
||||
val (lines, columns) = (System.getenv("LINES"), System.getenv("COLUMNS"))
|
||||
println(s"Lines = $lines, Columns = $columns")
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
$ include "seed7_05.s7i";
|
||||
include "console.s7i";
|
||||
|
||||
const proc: main is func
|
||||
local
|
||||
var text: console is STD_NULL;
|
||||
begin
|
||||
console := open(CONSOLE);
|
||||
writeln(console, "height: " <& height(console) lpad 3);
|
||||
writeln(console, "width: " <& width(console) lpad 3);
|
||||
# Terminal windows often restore the previous
|
||||
# content, when a program is terminated. Therefore
|
||||
# the program waits until Return/Enter is pressed.
|
||||
readln;
|
||||
end func;
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
var stty = `stty -a`;
|
||||
var lines = stty.match(/\brows\h+(\d+)/);
|
||||
var cols = stty.match(/\bcolumns\h+(\d+)/);
|
||||
say "#{lines} #{cols}";
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
set width [exec tput cols]
|
||||
set height [exec tput lines]
|
||||
puts "The terminal is $width characters wide and has $height lines"
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
lassign [exec stty size] width height
|
||||
puts "The terminal is $width characters wide and has $height lines"
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
#!/bin/sh
|
||||
WIDTH=`tput cols`
|
||||
HEIGHT=`tput lines`
|
||||
echo "The terminal is $WIDTH characters wide and has $HEIGHT lines."
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
#!/bin/sh
|
||||
WIDTH=`tput co`
|
||||
HEIGHT=`tput li`
|
||||
echo "The terminal is $WIDTH characters wide and has $HEIGHT lines."
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
Module Module1
|
||||
|
||||
Sub Main()
|
||||
Dim bufferHeight = Console.BufferHeight
|
||||
Dim bufferWidth = Console.BufferWidth
|
||||
Dim windowHeight = Console.WindowHeight
|
||||
Dim windowWidth = Console.WindowWidth
|
||||
|
||||
Console.Write("Buffer Height: ")
|
||||
Console.WriteLine(bufferHeight)
|
||||
Console.Write("Buffer Width: ")
|
||||
Console.WriteLine(bufferWidth)
|
||||
Console.Write("Window Height: ")
|
||||
Console.WriteLine(windowHeight)
|
||||
Console.Write("Window Width: ")
|
||||
Console.WriteLine(windowWidth)
|
||||
End Sub
|
||||
|
||||
End Module
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
/* terminal_control_dimensions.wren */
|
||||
|
||||
class C {
|
||||
foreign static terminalWidth
|
||||
foreign static terminalHeight
|
||||
}
|
||||
|
||||
var w = C.terminalWidth
|
||||
var h = C.terminalHeight
|
||||
System.print("The dimensions of the terminal are:")
|
||||
System.print(" Width = %(w)")
|
||||
System.print(" Height = %(h)")
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
#include "wren.h"
|
||||
|
||||
void C_terminalWidth(WrenVM* vm) {
|
||||
struct winsize w;
|
||||
ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
|
||||
wrenSetSlotDouble(vm, 0, (double)w.ws_col);
|
||||
}
|
||||
|
||||
void C_terminalHeight(WrenVM* vm) {
|
||||
struct winsize w;
|
||||
ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
|
||||
wrenSetSlotDouble(vm, 0, (double)w.ws_row);
|
||||
}
|
||||
|
||||
WrenForeignMethodFn bindForeignMethod(
|
||||
WrenVM* vm,
|
||||
const char* module,
|
||||
const char* className,
|
||||
bool isStatic,
|
||||
const char* signature) {
|
||||
if (strcmp(module, "main") == 0) {
|
||||
if (strcmp(className, "C") == 0) {
|
||||
if (isStatic && strcmp(signature, "terminalWidth") == 0) {
|
||||
return C_terminalWidth;
|
||||
} else if (isStatic && strcmp(signature, "terminalHeight") == 0) {
|
||||
return C_terminalHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void writeFn(WrenVM* vm, const char* text) {
|
||||
printf("%s", text);
|
||||
}
|
||||
|
||||
void errorFn(WrenVM* vm, WrenErrorType errorType, const char* module, const int line, const char* msg) {
|
||||
switch (errorType) {
|
||||
case WREN_ERROR_COMPILE:
|
||||
printf("[%s line %d] [Error] %s\n", module, line, msg);
|
||||
break;
|
||||
case WREN_ERROR_STACK_TRACE:
|
||||
printf("[%s line %d] in %s\n", module, line, msg);
|
||||
break;
|
||||
case WREN_ERROR_RUNTIME:
|
||||
printf("[Runtime Error] %s\n", msg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
char *readFile(const char *fileName) {
|
||||
FILE *f = fopen(fileName, "r");
|
||||
fseek(f, 0, SEEK_END);
|
||||
long fsize = ftell(f);
|
||||
rewind(f);
|
||||
char *script = malloc(fsize + 1);
|
||||
fread(script, 1, fsize, f);
|
||||
fclose(f);
|
||||
script[fsize] = 0;
|
||||
return script;
|
||||
}
|
||||
|
||||
int main() {
|
||||
WrenConfiguration config;
|
||||
wrenInitConfiguration(&config);
|
||||
config.writeFn = &writeFn;
|
||||
config.errorFn = &errorFn;
|
||||
config.bindForeignMethodFn = &bindForeignMethod;
|
||||
WrenVM* vm = wrenNewVM(&config);
|
||||
const char* module = "main";
|
||||
const char* fileName = "terminal_control_dimensions.wren";
|
||||
char *script = readFile(fileName);
|
||||
WrenInterpretResult result = wrenInterpret(vm, module, script);
|
||||
switch (result) {
|
||||
case WREN_RESULT_COMPILE_ERROR:
|
||||
printf("Compile Error!\n");
|
||||
break;
|
||||
case WREN_RESULT_RUNTIME_ERROR:
|
||||
printf("Runtime Error!\n");
|
||||
break;
|
||||
case WREN_RESULT_SUCCESS:
|
||||
break;
|
||||
}
|
||||
wrenFreeVM(vm);
|
||||
free(script);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
include c:\cxpl\codes;
|
||||
int W, H;
|
||||
[W:= Peek($40, $4A); \IBM-PC BIOS data
|
||||
H:= Peek($40, $84) + 1;
|
||||
Text(0, "Terminal width and height = ");
|
||||
IntOut(0, W); ChOut(0, ^x); IntOut(0, H);
|
||||
]
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
clear screen
|
||||
w = peek("screenwidth")
|
||||
h = peek("screenheight")
|
||||
print "Informaci¢n sobre el escritorio (terminal):"
|
||||
print " Ancho de la terminal: ", w, " (pixel)"
|
||||
print "Altura de la terminal: ", h, " (pixel)"
|
||||
|
||||
open window 640,480
|
||||
w = peek("winheight")
|
||||
h = peek("winwidth")
|
||||
print "\n\nInformaci¢n sobre el modo gr fico:"
|
||||
print " Ancho de la pantalla: ", w, " (pixel)"
|
||||
print "Altura de la pantalla: ", h, " (pixel)\n"
|
||||
close window
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
h,w:=System.popen("stty size","r").readln().split();
|
||||
println(w," x ",h);
|
||||
Loading…
Add table
Add a link
Reference in a new issue