From 8271443ede82a71447486b1819ffb0f15eb63d8e Mon Sep 17 00:00:00 2001 From: etienne Date: Thu, 28 Jun 2007 08:48:34 +0000 Subject: accepte en entree plusieurs fichiers --- src/ivyreplay | 85 ++++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 52 insertions(+), 33 deletions(-) (limited to 'src') diff --git a/src/ivyreplay b/src/ivyreplay index cc6f905..da71b6d 100755 --- a/src/ivyreplay +++ b/src/ivyreplay @@ -84,7 +84,7 @@ if (not GetOptions('-help', '-b=s', '-bus=s', '-light', print " [-repeat] [-timegranularity float>0]\n"; print " [-startregexp regexp] [-stopregexp regexp]\n"; print " [standard X11 options...]\n"; - print " inputfile\n"; + print " inputfile [... inpufileN]\n"; print "\n"; print "Options :\n"; print " -b <[addr]:port> Ivy bus (\$IVYBUS by default)\n"; @@ -196,24 +196,36 @@ $ivy->start; &build(); # load input files -my $file = $ARGV[0]; +my @files = @ARGV; -if (not $file) { +my $lines = 0; +my $steps = 0; +if (@files == 0) { $mw->Tk::Error("Error : an input file is expected"); -} elsif (not open(IN, $file)) { - $mw->Tk::Error("Can't open file '$file' ($!)"); } else { &showProgressbar(); - my ($step, $timefound) = &stepsnumber; - if ($timefound) { - &loadfileForReplay($step); - } else { - $mw->Tk::Error("No time information in file '$file'. ". - "Can't be replayed."); + for my $file (@files) { + if (not open(IN, $file)) { + $mw->Tk::Error("Can't open file '$file' ($!)"); + next; + } else { + my ($l, $timefound) = &stepsnumber; + $lines += $l; + if ($timefound) { + &loadfileForReplay(); + } else { + $mw->Tk::Error("No time information in file '$file'. ". + "Can't be replayed."); + next; + } + } + close(IN); } - &replayStart() if $opt_autostart; + $steps = int($lines/10); + $progressbar->configure(-to => 10); + &displayMessages() unless $opt_light; &hideProgressbar(); - close(IN); + &replayStart() if $opt_autostart; } MainLoop; @@ -246,8 +258,7 @@ sub stepsnumber { } $lc++; } - $step = int($lc/10); - $progressbar->configure(-to => $step*10); + $step = $lc; seek(IN, 0, 0); return ($step, $timefound); @@ -373,8 +384,6 @@ sub build { sub loadfileForReplay { - my $step = shift; - my $line = 0; # display messsages to replay my ($sender, $time, $message); @@ -409,12 +418,31 @@ sub loadfileForReplay { } else { $replay_min_time = $time; } - $line++; $message =~ s/^\"//; $message =~ s/\"$//; push(@{$replay_msg{$time}}, $message); - if ($replay_text) { + } + $mw->raise; + $replay_time = $replay_min_time; + # ivy bindings + $ivy->bindRegexp($opt_startregexp, [\&replayStart]) if $opt_startregexp; + $ivy->bindRegexp($opt_stopregexp, [\&replayStop]) if $opt_stopregexp; + + +} # end loadfileForReplay + + +sub displayMessages { + + my $line = 0; + for my $time (sort {$a <=> $b} keys(%replay_msg)) { + #print "time=$time\n"; + + for my $message (@{$replay_msg{$time}}) { + $replay_text->insert('end', &replayTime($time)." ".$message."\n", $time); + $line++; + &setProgressbar($line/$steps) if $line % $steps == 0; # when user click on a message the begin time changes. $replay_text->tagBind($time, '<1>', [sub { my $ti = $_[1]; @@ -437,19 +465,11 @@ sub loadfileForReplay { &replayStart if $replay_was_running; }, $time]); } - &setProgressbar($line, $step); } $replay_text->configure(-state => 'disabled') if $replay_text; - $mw->raise; - $replay_time = $replay_min_time; - # ivy bindings - $ivy->bindRegexp($opt_startregexp, [\&replayStart]) if $opt_startregexp; - $ivy->bindRegexp($opt_stopregexp, [\&replayStop]) if $opt_stopregexp; - - -} # end loadfileForReplay - - + + +} sub showProgressbar { @@ -469,11 +489,10 @@ sub hideProgressbar { sub setProgressbar { - my ($line, $step) = @_; + my ($line) = @_; $progressbar->value($line); $progressbar->toplevel->raise($mw); - return unless defined $step; - $progressbar->update if ($step == 0 or $line % $step == 0); + $progressbar->update; } # end setProgressbar -- cgit v1.1