The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Tickit::Term - terminal IO handler

SYNOPSIS

DESCRIPTION

Provides terminal IO primatives for Tickit. Split into two primary sections:

  • Output

    Methods to provide terminal output; writing text, changing pen attributes, moving the cursor, etc.

  • Input

    Event callbacks for keypress events.

CONSTRUCTOR

$term = Tickit::Term->new( %params )

As well as the configuration named parameters, takes the following named arguments at construction time:

term_in => IO

IO handle for terminal input. Will default to STDIN.

term_out => IO

IO handle for terminal output. Will default to STDOUT.

EVENTS

The following events are invoked, either using subclass methods or CODE references in parameters:

on_resize

The terminal window has been resized.

on_key $type, $str, $key

A key was pressed. $type will be text for normal unmodified Unicode, or key for special keys or modified Unicode. $str will be the UTF-8 string for text events, or the textual description of the key as rendered by Term::TermKey for key events. $key will be the underlying Term::TermKey::Key event structure.

PARAMETERS

The following named parameters may be passed to new or configure:

on_resize => CODE
on_key => CODE

CODE references for event handlers.

METHODS

$cols = $term->cols

$lines = $term->lines

Query the current size of the terminal. Will be cached and updated on receipt of SIGWINCH signals.

$term->print( $text )

Print the given text to the terminal at the current cursor position

$term->goto( $line, $col )

Move the cursor to the given position on the screen. If only one parameter is defined, does not alter the other. Both $line and $col are 0-based.

$term->move( $downward, $rightward )

Move the cursor relative to where it currently is.

$term->scroll( $from, $to, $by )

Scroll the region of the screen that starts on line $from until (and including) line $to down, $by lines (upwards if negative).

$term->chpen( %attrs )

Changes the current pen attributes to those given. Any attribute whose value is given as undef is reset. Any attributes not named are unchanged.

For details of the supported pen attributes, see Tickit::Pen.

$term->setpen( %attrs )

Similar to chpen, but completely defines the state of the terminal pen. Any attribute not given will be reset to its default value.

$term->clear

Erase the entire screen

$term->eraseinline

Clear the current line from the cursor onwards.

$term->erasech( $count, $moveend )

Erase $count characters forwards. If $moveend is true, the cursor is moved to the end of the erased region. If false, the cursor will remain where it is.

Using $moveend may be more efficient than separate erasech and goto calls on terminals that do not have an erase function, as it will be implemented by printing spaces. This removes the need for two cursor jumps.

$term->insertch( $count )

Insert $count blank characters, shifting following text to the right.

$term->deletech( $count )

Delete the following $count characters, shifting the remaining text to the left. The terminal will fill the empty region with blanks.

$term->mode_altscreen( $on )

Set or clear the DEC Alternate Screen mode

$term->mode_cursorvis( $on )

Set or clear the cursor visible mode

AUTHOR

Paul Evans <leonerd@leonerd.org.uk>