NAME

    Tickit::Widget::Term - a widget containing a virtual terminal

SYNOPSIS

       use Tickit;
       use Tickit::Widget::Term;
    
       my $tickit = Tickit->new(
          root => my $term = Tickit::Widget::Term->new,
       );
    
       $term->set_on_output( sub {
          my ( $bytes ) = @_;
          ## some application logic here to handle the bytes
       });
    
       ## some application logic here to invoke $term->write_input
    
       $tickit->run;

DESCRIPTION

    This widget class uses Term::VTerm to provide a virtual terminal,
    receiving bytes containing terminal sequences which are used to draw
    the content to the screen.

    Typically this would be used connected to some external process via a
    PTY device. The "use_pty" method can be used to connect this PTY device
    to the widget. Alternatively, the application can perform this bytewise
    IO itself, via the "write_input" method and "set_on_output" event
    handler.

METHODS

 write_input

       $term->write_input( $bytes )

    Push more bytes into the terminal state.

 on_output

 set_on_output

       $on_output = $term->on_output
    
       $term->set_on_output( $on_output )
    
          $on_output->( $bytes )

    Accessors for the on_output event callback, which is invoked by the
    terminal engine when more bytes of response have been generated.

    Typically this is caused by keyboard or mouse events, but it can also
    be generated in response to some received query sequences.

 flush

       $term->flush

    Finishes a round of screen update events, ensuring that any pending
    screen damage is handled. Also flushes the output buffer, invoking the
    on_event handler if required.

 on_resize

 set_on_resize

       $on_resize = $term->on_resize
    
       $term->set_on_resize( $on_resize )
    
          $on_resize->( $lines, $cols )

    Accessors for the on_resize event callback, which is invoked after a
    resize of the displayed widget. This may be required to inform the
    appliction driving the terminal of its new output size.

 use_pty

       $term->use_pty( $pty )

    Takes an opened PTY device and sets up an IO watcher on it to receive
    bytes of input. Additionally, arranges for output bytes to be sent to
    the handle.

    This is a convenient alternative to feeding in bytes by calling
    "input_write" and receiving them with a callback set by
    "set_on_output".

    The $pty handle should be an IO::Pty instance; or at least,
    well-behaved as an IO handle and support the following methods:

       $pty->blocking( 0 );
       $pty->set_winsize( $lines, $cols );
       $pty->sysread( $buf, $len );
       $pty->syswrite( $buf );

AUTHOR

    Paul Evans <leonerd@leonerd.org.uk>

