NAME

Term::Fabulous::Terminal::Termbox::Cells - Cell target that paints into the terminal through termbox2

SYNOPSIS

# Created and placed by Term::Fabulous::Terminal::Termbox:
my $cells = $terminal->cell_target;
$cells->place_region( $top, $rows );    # inline mode
$cells->place_region( undef, undef );   # full screen

DESCRIPTION

Most programs never use this module directly. It is the cell target (see "CELL TARGET" in Term::Fabulous::Render) of Term::Fabulous::Terminal::Termbox: it writes the painted cells into termbox2's back buffer and shows the frame with tb_present, which sends only the cells that changed since the last frame. It builds on Term::Fabulous::Render::Target::Mask, so it also provides begin_frame, end_frame, release_rect, set_cell, extend_cell and fill_row.

In inline mode, row 0 of a frame is the first row of the region, and the hidden cursor is left at the start of that row after every frame. The terminal must be open (tb_init or tf_init_inline); otherwise termbox2 ignores the drawing.

METHODS

place_region

$cells->place_region( $top, $rows );

Paints into the $rows rows of an inline region starting at the terminal row $top (from 0); with undef for both, into the whole screen, which is the default. Dies when only one of them is given.

region_top, region_rows

The values of the last "place_region": undef for the full screen.

clear_cells

Primitive for Term::Fabulous::Render::Target::Mask. Without kept rectangles, clears the back buffer (tb_clear); otherwise overwrites every cell of the screen (or region) outside them with a space in the default colors, so that the kept cells hold what the previous frame painted.

present_cells

Primitive: tb_present, then the sixel pictures that must be sent (see "show_sixels"), each after a cursor move to its top left cell; then in inline mode the cursor goes to the start of the region.

put_cell, put_extension, put_row

Primitives: tb_set_cell, tb_extend_cell and tb_print of spaces, at the terminal row of the frame row.

painted_cell

my ( $glyph, $fg, $bg ) = $cells->painted_cell( $x, $y );

Reads a cell back from termbox2's back buffer (tb_get_cell). See "painted_cell" in Term::Fabulous::Render.

set_sixel_cell_size

$cells->set_sixel_cell_size( 10, 20 );
$cells->set_sixel_cell_size;

Called by Term::Fabulous::Terminal::Termbox: the terminal shows sixel graphics with cells of the given width and height in pixels, whole numbers of at least 1; without arguments, it shows none. Anything else dies.

sixel_cell_size

my ( $width, $height ) = $cells->sixel_cell_size;

From Term::Fabulous::Render::Target::Sixel: the last "set_sixel_cell_size", empty at first.

sixel_area

my $rect = $cells->sixel_area( $width, $height );

From Term::Fabulous::Render::Target::Sixel: the frame without the terminal's last row. A picture that reaches it makes the terminal scroll the screen up, as the cursor moves below the picture.

show_sixels

$cells->show_sixels(@placements);

From Term::Fabulous::Render::Target::Sixel: the pictures of the frame being painted, which "present_cells" shows. termbox2 sends only the cells that changed since the last frame, and knows nothing of the pictures, so "present_cells":

  • makes termbox2 draw the cells of a picture of the last frame that is not shown again at the same place with the same data (tf_invalidate_cells), which erases it;

  • sends a picture that is new, moved or changed, or whose cells termbox2 draws in this frame (tf_cells_differ), since drawing a cell erases the picture's pixels there.

forget_sixels

$cells->forget_sixels;

Forgets the pictures on the screen and those of the frame being painted, for a new termbox2 session, which starts with a clear screen.

SEE ALSO

Term::Fabulous::Terminal::Termbox, "CELL TARGET" in Term::Fabulous::Render, Term::Fabulous::Render::Target::Mask, Term::Fabulous::Termbox.