App-Textcast
view release on metacpan or search on metacpan
lib/App/Textcast.pm view on Meta::CPAN
$eof = 1 if ((defined $bytes_read) && ($bytes_read == 0));
if ((defined $bytes_read) && ($bytes_read > 0))
{
$vt->process ($cmdbuf);
syswrite STDERR, $cmdbuf if (! -t STDERR);
}
}
# End processing if we've gone 1 round after command died with no output.
$eof = 1 if ($vt_process->{DIED} && $cmdbuf eq $EMPTY_STRING);
# Do your stuff here - use $vt->row_plaintext() to see what's on various
# rows of the screen, for instance, or before this main loop you could set
# up a ROWCHANGE callback which checks the changed row, or whatever.
# In this example, we just pass standard input to the SSH command, and we
# take the data coming back from SSH and pass it to the Term::VT102 object,
# and then we repeatedly dump the Term::VT102 screen.
# Read key presses from standard input and pass them to the command
# running in the child process.
if (vec ($rout, $vt_process->{IOT}->fileno, 1))
{
my $stdinbuf = $EMPTY_STRING ;
my $bytes_read = $vt_process->{IOT}->sysread ($stdinbuf, $BUFFER_READ_SIZE );
$eof = 1 if ((defined $bytes_read) && ($bytes_read == 0));
$vt_process->{PTY}->syswrite ($stdinbuf, $bytes_read) if ((defined $bytes_read) && ($bytes_read > 0));
}
# Dump what Term::VT102 thinks is on the screen. We only output rows
# we know have changed, to avoid generating too much output.
my $didout = 0;
foreach my $row (sort keys %{ $vt_process->{TERMINAL_CHANGE_BUFFER} })
{
printf "\e[%dH%s\r", $row, $vt->row_sgrtext ($row);
$screen_data .= sprintf "\e[%dH%s\r", $row, $vt->row_sgrtext ($row);
delete $vt_process->{TERMINAL_CHANGE_BUFFER}{$row};
$didout ++;
}
if (($didout > 0) || ($vt_process->{PREVXY} ne $EMPTY_STRING . $vt->x . q{,} . $vt->y))
{
printf "\e[%d;%dH", $vt->y, ($vt->x > $vt->cols ? $vt->cols : $vt->x);
$screen_data .= sprintf "\e[%d;%dH", $vt->y, ($vt->x > $vt->cols ? $vt->cols : $vt->x);
#todo: shouldn't prevxy be updated here?
}
# Make sure the child process has not died.
$vt_process->{DIED} = 1 if (waitpid ($vt_process->{PID}, WNOHANG) > 0);
return($eof, $screen_data, $vt->x(), $vt->y()) ;
}
#---------------------------------------------------------------------------------------------------------
1 ;
=head1 BUGS AND LIMITATIONS
None so far.
=head1 AUTHOR
Nadim ibn hamouda el Khemir
CPAN ID: NH
mailto: nadim@cpan.org
=head1 LICENSE AND COPYRIGHT
This program is free software; you can redistribute
it and/or modify it under the same terms as Perl itself.
=head1 SUPPORT
You can find documentation for this module with the perldoc command.
perldoc App::Textcast
You can also look for information at:
=over 4
=item * AnnoCPAN: Annotated CPAN documentation
L<http://annocpan.org/dist/App-Textcast>
=item * RT: CPAN's request tracker
Please report any bugs or feature requests to L <bug-app-textcast@rt.cpan.org>.
We will be notified, and then you'll automatically be notified of progress on
your bug as we make changes.
=item * Search CPAN
L<http://search.cpan.org/dist/App-Textcast>
=back
=head1 SEE ALSO
screen (1), script(1), aewan, vte(1), evilvte(1).
=cut
( run in 3.547 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )