beetlebug▾
/

ztcl::vt feed

Feeds the bytes of a program to a terminal and gives its reply.

ztcl::vt feed HANDLE BYTES

Description

Feeds the UTF-8 bytes of the string BYTES to the parser. A sequence can end in a later feed.

The result is the reply of the terminal: the bytes that a program gets back for DA (ESC [c), DSR (ESC [5n, ESC [6n), the mode queries, and the OSC color queries. A caller sends the reply to the program. The result is empty when no sequence asks for a reply.

The bell (BEL) adds 1 to the count of bells, and OSC 0 and OSC 2 set the title. A sequence that libghostty-vt does not handle has no effect.

Arguments

ArgumentTypeDefaultDescription
HANDLEhandlerequiredA handle from new.
BYTESstringrequiredThe output of a program.

Returns

The reply of the terminal, or an empty string.

Examples

Each example of this page runs after package require ztcl::vt; set vt [ztcl::vt new].

% set t [ztcl::vt new -size {20 4}]
> set r [ztcl::vt feed $t "abc\x1b\[6n"]
> ztcl::vt delete $t
> string map [list \x1b ESC] $r
ESC[1;4R

% set t [ztcl::vt new]
> set r [ztcl::vt feed $t "\x1b\[c\x1b\[5n"]
> ztcl::vt delete $t
> string map [list \x1b ESC] $r
ESC[?62;22cESC[0n

% set t [ztcl::vt new]
> set r [ztcl::vt feed $t "\x1b\]11;?\x07"]
> ztcl::vt delete $t
> string map [list \x1b ESC \x07 BEL] $r
ESC]11;rgb:ffff/ffff/ffffBEL

% set t [ztcl::vt new]
> ztcl::vt feed $t "a\x1b\["
> ztcl::vt feed $t "1mb"
> set r [lindex [ztcl::vt cells $t 0] 0 1]
> ztcl::vt delete $t
> set r
b 1 {} {} bold

Errors

% ztcl::vt feed vt99 x
can not find terminal "vt99"
-errorcode ZTCL VT HANDLE

% ztcl::vt feed $vt
wrong # args: should be "ztcl::vt feed handle bytes"
-errorcode TCL WRONGARGS

Facts

Capability
None.
Tcl release
Tcl 9.1 and 8.6.
Since
ztcl 1.0.0-beta.1

See also