package matrix

Build not yet checked
  1. Overview
  2. Docs
On This Page
  1. Goldens
Fast, modern terminal toolkit for OCaml

Install

dune-project
 Dependency

Authors

Maintainers

Sources

mosaic-0.3.0.tbz
sha256=a92cbbcbe016fb19fb0a749222da0e459a9567aef3f4c7340d9bd6b71c53ed6f
sha512=6a7ab054605538bb31a2b73a1a6d093981a2704c9f0af5852221c05735290d74aca7c7282298c4d0f91e86a800e2ccd94b4918af883cd963449c758eb6b272b3

doc/matrix.test/Matrix_test/Screen/index.html

Module Matrix_test.ScreenSource

What a terminal shows at one moment.

Sourcetype t

The type for screens, the cells and the cursor of a terminal at one moment. A screen does not change. Rows and columns count from 0.

Sourcetype cursor = {
  1. row : int;
    (*

    The cursor's row.

    *)
  2. col : int;
    (*

    The cursor's column.

    *)
  3. shape : Matrix.Ansi.cursor_style;
    (*

    The cursor's shape.

    *)
  4. blinking : bool;
    (*

    Whether the cursor blinks.

    *)
}

The type for a visible cursor.

Sourceval rows : t -> int

rows s is the number of rows of s.

Sourceval cols : t -> int

cols s is the number of columns of s.

Sourceval row : t -> int -> string

row s y is the text of row y, a space for an empty cell, without the spaces that end it.

Raises Invalid_argument if y is not a row of s.

Sourceval cell : t -> row:int -> col:int -> string * Matrix.Ansi.Style.t

cell s ~row ~col is the grapheme and the style of that cell, "" for an empty cell or the second column of a wide character.

Raises Invalid_argument if the cell is not one of s.

Sourceval cursor : t -> cursor option

cursor s is the cursor, None when it is hidden.

Sourceval find : t -> string -> (int * int) list

find s text is the row and column of each occurrence of text within a row of row's text, top to bottom, then left to right.

Raises Invalid_argument if text is empty.

Goldens

A golden is a screen as text, which a test compares with an expected one, such as in an expect test. Its rows are numbered from 01 as "NN |text", with at least two digits, more when the last row's number needs them, and its last line is the cursor's, "cursor ROW,COL SHAPE" counted from 1, with blinking after the shape when it blinks, or "cursor hidden".

Sourceval text : t -> string

text s is the golden of s: each row's row text, then the cursor line, each ending with a newline.

Sourceval styled : t -> string

styled s is text where each row that holds a cell not in the default style is followed by a line of one key per column, under the row's prefix, naming that cell's style: a space for the default style (the terminal's default colors, no attribute, no hyperlink), and the same key for both columns of a wide character. After the cursor line comes one line for each key, the key and its style. Keys are letters, digits, then other characters, in the order in which styles first appear, left to right and top to bottom.

Sourceval diff : t -> t -> string option

diff a b is None when a and b show the same cells and cursor. Otherwise it is each row of b that differs from a's, as in a golden, followed by a line with a letter under each column that differs, by the first of these that holds, as Vim's screen dumps mark them: X another character, w another width, f another foreground, b another background, a other attributes or another hyperlink. Then come both cursor lines, if the cursors differ. Screens of different sizes give both sizes.