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 ( fs_test( sr => "$base/$fn" ) ) {
$js->eval(slurp("$base/$_[0]"));
$relay->() if $relay;
}
elsif ( $onerror ) {
$onerror->();
lib/ChordPro/Files.pm view on Meta::CPAN
use File::Find qw(find);
my @files;
find sub {
if ( -d && $File::Find::name ne $folder ) {
$File::Find::prune = !$recurse;
$opts->{subfolders} = 1;
}
elsif ( -s _ && $_ =~ $filter ) {
my $i = 0;
my @st = stat(_);
push( @files,
{ name => decode_utf8($File::Find::name =~ s;^\Q$ufolder\E/?;;r),
map { $_ => $st[$i++] }
qw{ dev ino mode nlink uid gid rdev size
atime mtime ctime blksize blocks }
} );
}
}, $ufolder;
@files = sort { $a->{name} cmp $b->{name} } @files;
lib/ChordPro/Files.pm view on Meta::CPAN
my @files;
$dir->opendirL($path)
or die ("$path: $^E\n");
foreach my $file ( $dir->readdirL ) {
# Skip parent dir.
next if $file eq '..';
# Get file stats.
my $name = $file eq '.' ? $path : "$path/$file";
my $stat = Win32::LongPath::lstatL($name)
or die( "stat($name,", Win32::LongPath::getcwdL(), "): $^E\n" );
# Recurse if dir.
if ( ( $file ne '.' )
&& ( ($stat->{attribs}
& ( Win32::LongPath::FILE_ATTRIBUTE_DIRECTORY()
| Win32::LongPath::FILE_ATTRIBUTE_REPARSE_POINT() ) )
== Win32::LongPath::FILE_ATTRIBUTE_DIRECTORY() ) ) {
push( @files, @{ search_tree( $name, $opts, $folder ) } )
if $recurse;
$opts->{subfolders} = 1;
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.570 second using v1.01-cache-2.11-cpan-beeb90c9504 )