beetlebug▾
/

ztcl::vt new

Makes a terminal and gives its handle.

ztcl::vt new ?-size {COLS ROWS}? ?-scrollback LINES?

Description

Makes a terminal with an empty screen and gives its handle, vt0 for the first one. The cursor starts at row 0, column 0, with the steady block cursor (style 2). Grapheme clusters (mode 2027) are on, also after a reset, so a cluster of UAX #29 is one cell or one wide cell, as in modern terminals; ESC [?2027l turns them off. The OSC queries 10 and 11 report black on white. An option that comes again keeps its last value.

Options

OptionTypeDefaultDescription
-sizelist of two integers80 24Gives the count of columns and of rows.
-scrollbackinteger1,000Gives the most lines of the scrollback.

-size {COLS ROWS}

Gives the count of columns and of rows.

A list of the count of columns and the count of rows, each 1 to 4,096.

% set t [ztcl::vt new -size {20 4}]
> set r [ztcl::vt size $t]
> ztcl::vt delete $t
> set r
20 4
% ztcl::vt new -size {0 5}
the size 0 is outside 1 to 4096
-errorcode ZTCL VT SIZE

% ztcl::vt new -size {5000 5}
the size 5000 is outside 1 to 4096
-errorcode ZTCL VT SIZE

% ztcl::vt new -size 5
the size must be a list of cols and rows
-errorcode ZTCL VT SIZE

% ztcl::vt new -size {a b}
expected integer but got "a"
-errorcode TCL VALUE NUMBER

% ztcl::vt new -size
wrong # args: should be "ztcl::vt new ?-size {cols rows}? ?-scrollback lines?"
-errorcode TCL WRONGARGS

-scrollback LINES

Gives the most lines of the scrollback.

The most lines that the scrollback keeps, 0 to 1,000,000. libghostty-vt keeps whole pages of rows, so the scrollback can hold more lines than LINES.

% set t [ztcl::vt new -size {3 1} -scrollback 0]
> ztcl::vt feed $t "a\r\nb"
> set r [ztcl::vt rows $t]
> ztcl::vt delete $t
> set r
b
% ztcl::vt new -scrollback -1
the scrollback -1 is outside 0 to 1000000
-errorcode ZTCL VT SCROLLBACK

% ztcl::vt new -scrollback 1000001
the scrollback 1000001 is outside 0 to 1000000
-errorcode ZTCL VT SCROLLBACK

% ztcl::vt new -scrollback x
expected integer but got "x"
-errorcode TCL VALUE NUMBER

Returns

The handle of the terminal.

Examples

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

% set t [ztcl::vt new]
> set r [list [string match vt* $t] [ztcl::vt size $t] [ztcl::vt cursor $t]]
> ztcl::vt delete $t
> set r
1 {80 24} {0 0}

Errors

% ztcl::vt new extra
wrong # args: should be "ztcl::vt new ?-size {cols rows}? ?-scrollback lines?"
-errorcode TCL WRONGARGS

% ztcl::vt new -bogus 1
bad option "-bogus": must be -size or -scrollback
-errorcode TCL LOOKUP OPTION

% ztcl::vt new -s {3 3}
bad option "-s": must be -size or -scrollback
-errorcode TCL LOOKUP OPTION

Facts

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

See also