/[ttyrec]/jsttyplay/play.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /jsttyplay/play.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (show annotations)
Tue Feb 17 18:12:32 2009 UTC (15 years, 2 months ago) by dpavlin
File MIME type: text/plain
File size: 1257 byte(s)
import upstream from http://encryptio.com/code/jsttyplay

1 #!/usr/bin/perl
2 use warnings;
3 use strict;
4 $| = 1;
5
6 my $readsize = 1;
7 my $skipto = 0;
8 my $wait = 0.01;
9
10 use Term::TtyRec;
11 use Term::Emulator::Parser;
12 use FileHandle;
13 use Time::HiRes qw/ time sleep /;
14 use Carp;
15
16 $SIG{INT} = sub { confess };
17
18 sub openRec {
19 my ($fn) = @_;
20 my $fh = FileHandle->new($fn, "r") or die;
21 my $rec = Term::TtyRec->new($fh);
22 return $rec;
23 }
24
25 my $buf = '';
26 my $lasttime;
27 sub parseFrame {
28 my ($rec, $term) = @_;
29 if ( length $buf < $readsize ) {
30 my ($time, $data) = $rec->read_next;
31 return () if not defined $time and not length $buf;
32 if ( defined $time ) {
33 $buf .= $data;
34 $lasttime = $time;
35 }
36 }
37 if ( $lasttime < $skipto ) {
38 $term->parse($buf);
39 $buf = '';
40 goto &parseFrame;
41 } else {
42 $term->parse(substr $buf, 0, $readsize);
43 substr($buf, 0, $readsize) = '';
44 return $lasttime;
45 }
46 }
47
48 ###
49
50 my $width = 80;
51 my $height = 24;
52 my $term = Term::Emulator::Parser->new( width => $width, height => $height );
53 my $rec = openRec($ARGV[0]);
54
55 system("clear");
56 while ( defined(my $time = parseFrame($rec, $term)) ) {
57 print "\033[H".$term->as_termstring."--";
58 sleep $wait if $time >= $skipto and $wait;
59 }
60

Properties

Name Value
svn:executable

  ViewVC Help
Powered by ViewVC 1.1.26