vt library
A small but strict terminal emulator used as the test oracle for the presenter. It knows nothing about the core's buffers: it only consumes bytes, like a real terminal, and models the behaviours that cause artifacts in practice:
- autowrap with a pending-wrap flag (a printed char after the last column wraps and may scroll the screen),
- background color erase (BCE) for EL/ECH/ED/SU/SD, switchable,
- DECSTBM scroll margins with SU/SD, IL/DL,
- optionally Konsole's lines (Vt.konsoleLines): each as long as what was written or erased on it, DCH filling the end of that instead of the right margin, ICH inserting blanks in the default colours,
- two-column glyphs: overwriting either half blanks the other half,
- optionally a normal screen: a scrollback that lines scrolled off the top go to (Vt.history), rows the application must not touch (Vt.guardRows) and a resize that keeps what the screen shows (Vt.resizeKeeping),
- configurable cluster widths, so a terminal that disagrees with the application can be simulated,
- images (Vt.images): kitty placements, which stay over the cells they were placed on while text is printed or erased there and move with them when they scroll, and sixel and iTerm2 images, whose pixels are those of their cells, taken away with what is printed or erased there; optionally Konsole's (Vt.konsoleImages), which a scroll up moves up all of, and a scroll down none of, wherever the scrolled rows are, and whose image data a deletion keeps.
Any byte sequence it doesn't understand is a test failure, as is any wrap or scroll caused by printing (the presenter must never rely on them).
Vt is the emulator, VtCell a cell of its screen and VtImage an image it shows.
Classes
- Vt
- A terminal emulator of width × height cells that fails on what a terminal would show wrong: feed gives it the bytes an application writes, and cell, lines and the cursor (cx, cy) read back what the screen shows.
- VtCell
- A cell of a Vt's screen: the text printed in it and the colors and attributes it was printed with.
- VtImage
- An image the terminal shows (Vt.images): placement placement of kitty image id, or a sixel or iTerm2 image, of bytes bytes of image data, over the cells cells it still has of the cols x rows from (x, y).