NAME
Tickit::Term
- terminal formatting abstraction
SYNOPSIS
DESCRIPTION
Provides terminal control primatives for Tickit; a number of methods that control the terminal by writing control strings. This object itself performs no acutal IO work; it writes bytes to a delegated object given to the constructor called the writer.
This object is not normally constructed directly by the containing application; instead it is used indirectly by other parts of the Tickit
distribution.
CONSTRUCTOR
$term = Tickit::Term->find_for_term( %params )
Attempts to load and construct a subclass determined by the current terminal type (as given by $ENV{TERM}
). If this fails, returns a normal Tickit::Term
instead.
$term = Tickit::Term->new( %params )
Constructs a new Tickit::Term
object.
Takes the following named arguments at construction time:
- encoding => STRING
-
Optional. If supplied, applies the named encoding to the Unicode string supplied to the
print
method. - writer => OBJECT
-
An object delegated to for sending strings of terminal control bytes to the terminal itself. This object must support a single method,
write
, taking a string of bytes.$writer->write( $data )
Such an interface is supported by an
IO::Handle
object.
METHODS
$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.
$success = $term->scrollrect( $top, $left, $lines, $cols, $downward, $rightward )
Attempt to scroll the rectangle of the screen defined by the first four parameters by an amount given by the latter two. Since most terminals cannot perform arbitrary rectangle scrolling, this method returns a boolean to indicate if it was successful. The caller should test this return value and fall back to another drawing strategy if the attempt was unsuccessful.
The cursor may move as a result of calling this method; its location is undefined if this method returns successful.
$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 defined but false, the cursor will remain where it is. If undefined, the terminal will perform whichever of these behaviours is more efficient, and the cursor will end at some undefined location.
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
$term->mode_mouse( $on )
Set or clear the mouse tracking mode
TODO
Track cursor position, and optimise (or eliminate entirely)
goto
calls.
AUTHOR
Paul Evans <leonerd@leonerd.org.uk>