App-Music-ChordPro

 view release on metacpan or  search on metacpan

lib/ChordPro/Delegate/ABC.pm  view on Meta::CPAN

	my $base = $abc2svg->{abclib} . "/abc2svg";
	$js->set_module_base($base);

	my $qjsdata =
	  {
	   print     => sub { push( @lines, split(/\n/, $_) ) for @_ },
	   printErr  => sub { print STDERR @_ },
	   quit      => sub { exit 66 },
	   readFile  => sub { slurp($_[0]) },
	   get_mtime => sub {
	       my @stat = stat($_[0]);
	       return @stat ? 1000*$stat[9] : undef;
	   },
	   loadjs    => sub {
	       my ( $fn, $relay, $onerror ) = @_;
	       if ( -s -r "$base/$fn" ) {
		   $js->eval(slurp("$base/$_[0]"));
		   $relay->() if $relay;
	       }
	       elsif ( $onerror ) {
		   $onerror->();

lib/ChordPro/Wx/EditorPanel.pm  view on Meta::CPAN

    $self->alert( 0, "No external editor specified" ), return unless $editor;
    my $e = $self->{t_editor};
    my $pos = $e->GetCurrentPos;
    my $mod = $e->IsModified;

    # Save in temp file and call editor.
    use File::Temp qw(tempfile);
    ( undef, my $file ) = tempfile( SUFFIX => $preferences{chordproext},
				    OPEN => 0 );
    $e->SaveFile($file);
    my @st = stat($file);
    $self->log( 'I', "Running $editor on $file (" .
		plural( $e->GetLineCount, " line" ) . ", " .
		plural( $st[7], " byte" ) . ")" );
    ::sys( $editor, $file );

    if ( (stat($file))[7] == $st[7] && (stat(_))[9] == $st[9] ) {
	$self->log( 'I', "Running $editor did not make changes" );
	$self->alert( 0, "No changes from external editor" );
    }
    else {
	$e->LoadFile($file);
	$self->log( 'I', "Updated editor from $file (" .
		    plural( $e->GetLineCount, " line" ) . ", " .
		    plural( (stat(_))[7], " byte" ) . ")" );
	$mod = 1;
	# Clear selection and set insertion point.
	$e->SetSelection( $pos, $pos );
	$e->EmptyUndoBuffer;
    }
    unlink($file);

    $e->SetModified($mod);
    $e->SetFocus;
}

lib/ChordPro/res/abc/chordproabc.js  view on Meta::CPAN

var abc2svg = {
    print: print,
    printErr: function(str) {
	std.err.printf("%s\n", str)
    },
    quit: function() {
	std.exit(1)
    },
    readFile: std.loadFile,
    get_mtime: function(fn) {
	return new Date(os.stat(fn)[0].mtime)
    },
    loadjs: function(fn, relay, onerror) {
	try {
	    load(fn[0] == "/" ? fn : (path + fn))
	    if (relay)
		relay()
	}
	catch(e) {
	    if (onerror)
		onerror()



( run in 0.983 second using v1.01-cache-2.11-cpan-49f99fa48dc )