beetlebug▾
/

ztcl::pty tty

Sets raw mode on the terminal of the program of the interpreter, or gives its size.

ztcl::pty tty raw|restore|size

Description

Acts on the terminal of the standard input and output of the program that runs the interpreter, such as the ztcl runner, for a full-screen program in Tcl. raw turns off the echo, the line input, and the keys of signals, so each key comes as its bytes. restore puts back the mode from before the first raw. size gives {COLS ROWS} of the window. On Windows, raw also turns on the virtual terminal input and output of the console. Poll size to see a change of the window.

Arguments

ArgumentTypeDefaultDescription
MODEwordrequiredraw, restore, or size.

Returns

An empty string, or a list of the columns and the rows for size.

Examples

Each example of this page runs after # The shell of the platform: in host mode the separator of Windows is a backslash. set sh [expr {[file separator] eq "/" ? "/bin/sh" : "cmd.exe"}] # Reads the output with no block until the program ends, and gives its status. proc finish {t} { fconfigure $t -blocking 0 for {set n 0} {[ztcl::pty status $t] eq "running" && $n < 1000} {incr n} { read $t; after 10 } ztcl::pty status $t } .

% # With no raw mode set, restore changes nothing.
> ztcl::pty tty restore

Errors

% ztcl::pty tty bogus
bad option "bogus": must be raw, restore, or size
-errorcode NONE

% ztcl::pty tty
wrong # args: should be "ztcl::pty tty raw|restore|size"
-errorcode TCL WRONGARGS

Facts

Capability
exec. A new interpreter does not have it until the host turns it on.
Tcl release
Tcl 9.1 and 8.6.
Since
ztcl 1.0.0-beta.4

See also