ztcl::vt cells
Gives the cells of the rows of a terminal.
ztcl::vt cells HANDLE ?FIRST? ?LAST?
Description
Gives one list for each row from FIRST to LAST, with the same indexes as rows. Each row is a list of COLS cells, and a cell is the list TEXT WIDTH FG BG ATTRS:
- TEXT is the grapheme cluster of the cell, such as
ewith U+0301 or an emoji ZWJ sequence, or empty for a cell with no character. A cell keeps the first 8 code points of a cluster. - WIDTH is 1, 2 for a wide character, or 0 for the cell after a wide character.
- FG and BG are empty for the default color, an index of the 256-color palette, or
#rrggbb. - ATTRS lists
bold,dim,italic,underline,blink,inverse,hidden, andstrike.
Arguments
| Argument | Type | Default | Description |
|---|---|---|---|
| HANDLE | handle | required | A handle from new. |
| FIRST | integer | none | The first row. |
| LAST | integer | none | The last row. |
Returns
A list of rows, each a list of cells.
Examples
Each example of this page runs after package require ztcl::vt; set vt [ztcl::vt new].
% set t [ztcl::vt new -size {4 1}]
> ztcl::vt feed $t "\x1b\[1;31mA\x1b\[0m\x1b\[48;2;0;128;255mB\x1b\[0m中"
> set r [lindex [ztcl::vt cells $t 0] 0]
> ztcl::vt delete $t
> lrange $r 0 1
{A 1 1 {} bold} {B 1 {} #0080ff {}}
% set t [ztcl::vt new -size {4 1}]
> ztcl::vt feed $t "ab中"
> set r [lindex [ztcl::vt cells $t 0] 0]
> ztcl::vt delete $t
> list [lindex $r 2 1] [lindex $r 3]
2 {{} 0 {} {} {}}
% set t [ztcl::vt new -size {3 1}]
> ztcl::vt feed $t "\x1b\[38;5;200;2;3;4;5;7;8;9mq"
> set r [lindex [ztcl::vt cells $t 0] 0 0]
> ztcl::vt delete $t
> set r
q 1 200 {} {dim italic underline blink inverse hidden strike}
Errors
% ztcl::vt cells vt99
can not find terminal "vt99"
-errorcode ZTCL VT HANDLE
% ztcl::vt cells $vt 0 0 0
wrong # args: should be "ztcl::vt rows|cells handle ?first? ?last?"
-errorcode TCL WRONGARGS
Facts
- Capability
- None.
- Tcl release
- Tcl 9.1 and 8.6.
- Since
- ztcl 1.0.0-beta.1