Term::VTerm - emulate a virtual terminal using libvterm
Term::VTerm
The following sets of constants are exported, with the given tag names.
Type constants for the types of VTermValue, as returned by get_attr_type and get_prop_type.
VTermValue
get_attr_type
get_prop_type
Attribute constants for pen attributes.
Property constants for terminal properties.
Keyboard modifier bitmask constants for keyboard_* and mouse_*.
keyboard_*
mouse_*
Size constants for VTermScreen damage merging.
VTermScreen
Key symbol constants for keyboard_key.
keyboard_key
$vterm = Term::VTerm->new( %args )
Constructs a new Term::VTerm instance of the initial size given by the arguments.
Gives the initial size of the terminal area.
( $rows, $cols ) = $vterm->get_size
Returns the current size of the terminal area.
$vterm->set_size( $rows, $cols )
Sets the new size of the terminal area.
$utf8 = $vterm->get_utf8 $vterm->set_utf8( $utf8 )
Return or set UTF-8 mode on the parser.
$len = $vterm->input_write( $str )
Writes the bytes of the given string into the terminal parser buffer.
$len = $vterm->output_read( $buf, $maxlen )
Reads bytes from the output buffer of the terminal into the given variable, up to the maximum length requested. Returns the number of bytes actually read.
$vterm->keyboard_unichar( $char, $mod )
Sends a keypress to the output buffer, encoding the given Unicode character number (i.e. not a string), with the optional modifier (as a bitmask of one or more of the MOD_* constants).
MOD_*
$vterm->keyboard_key( $key, $mod )
Sends a keypress to the output buffer, encoding the given key symbol (as a KEY_* constant), with the optional modifier (as a bitmask of one or more of the MOD_* constants).
KEY_*
$vterm->mouse_move( $row, $col, $mod )
Moves the mouse cursor to the given position, with optional modifier (as a bitmask of one or more of the MOD_* constants). It is OK to call this regardless of the current mouse mode; if the mode doesn't want move report events or drag events then no output will be generated.
$vterm->mouse_button( $button, $is_pressed, $mod )
Performs a mouse button report event on the given button, to either press or release it, with optional modifier (as a bitmask of one or more of the MOD_* constants). It is OK to call this regardless of the current mouse mode; if mouse reporting is disabled then no output will be generated.
$vterm->parser_set_callbacks( %cbs )
Sets the parser-layer callbacks. Takes the following named arguments:
$on_text->( $text )
$on_control->( $ctrl )
$ctrl is an integer giving a C0 or C1 control byte value.
$ctrl
$on_escape->( $str )
$on_csi->( $leader, $command, @args )
Where $leader may be undef, and each element of @args is an ARRAY reference containing sub-arguments. Each sub-argument may be undef.
$leader
undef
@args
$on_osc->( $command )
$on_dcs->( $str )
$on_resize->( $rows, $cols )
$state = $vterm->obtain_state
Returns a Term::VTerm::State object representing the terminal state layer, creating it if necessary. After calling this method, any parser callbacks will no longer work.
$screen = $vterm->obtain_screen
Returns a Term::VTerm::Screen object representing the terminal screen layer, creating it if necessary. After calling this method, any parser or state callbacks will no longer work.
A VTermColor instance can be constructed by
VTermColor
A VTermColor instance has the following field accessors:
True if the colour is a palette index.
True if the colour contains RGB values directly.
The palette index for indexed colours.
The components of the colour as an integer between 0 and 255 for RGB colours.
A 6-character string containing the three colour components, hex encoded.
True if the colour is the default colour for terminal foreground or background.
A VTermGlyphInfo instance has the following field accessors:
VTermGlyphInfo
A list of Unicode character numbers. This list does not include the terminating 0.
The width of this glyph in screen columns.
A Unicode string containing the characters.
A VTermPos instance can be constructed by
VTermPos
A VTermPos instance has the following field accessors:
The row and column number of the position, 0-indexed.
A VTermRect instance can be constructed by
VTermRect
A VTermRect instance has the following field accessors:
The row and column number of the top left corner of the rectangle.
The row and column number of the cell just after the bottom right corner of the rectangle; i.e. exclusive limit.
The following utility functions are also exported.
$type = get_attr_type( $attr )
Returns the type of the given pen attribute.
$type = get_prop_type( $prop )
Returns the type of the given terminal property.
Paul Evans <leonerd@leonerd.org.uk>
To install Term::VTerm, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Term::VTerm
CPAN shell
perl -MCPAN -e shell install Term::VTerm
For more information on module installation, please visit the detailed CPAN module installation guide.