jump to current position in subtitle.srt.yaml
authorDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 16 Dec 2009 19:39:55 +0000 (20:39 +0100)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 16 Dec 2009 19:39:55 +0000 (20:39 +0100)
bin/mplayer.pl

index cfebbd8..7f476dd 100755 (executable)
@@ -557,7 +557,14 @@ sub load_subtitles {
 sub edit_subtitles {
        print $to_mplayer qq|pause\n|;
        focus_term;
-       system( qq|vi "$subtitles.yaml"| ) == 0 and load_subtitles;
+       my $line = 1;
+       open( my $fh, '<', "$subtitles.yaml" ) || die $1;
+       while(<$fh>) {
+               last if /^-\s([\d\.]+)/ && $1 > $pos;
+               $line++;
+       }
+       close($fh);
+       system( qq|vi +$line "$subtitles.yaml"| ) == 0 and load_subtitles;
        focus_mplayer;
 }