Debian Codegraph @

lib/ChordPro/res/abc/chordproabc.js

raw symbols SCIP
1 // QuickJS script for ChordPro ABC to SVG.
2 //
3 // Based on the script 'abcqjs', part of the abc2svg package.
4
5 // Copy of the command line arguments.
6 var args = scriptArgs
7
8 // 1st argument is this script.
9 var script = args.shift()
10
11 // 2nd argument is the path where the scripts reside.
12 var path = args.shift() + "/"
13
14 // 3rd is the output file, so we do not need redirection and a shell.
15 var output = args.shift()
16
17 // Interpreter specific functions.
18 function load(fn) {
19 return std.loadScript(fn)
20 }
21
22 // The abc2svg glue.
23 var abc2svg = {
24 print: print,
25 printErr: function(str) {
26 std.err.printf("%s\n", str)
27 },
28 quit: function() {
29 std.exit(1)
30 },
31 readFile: std.loadFile,
32 get_mtime: function(fn) {
33 return new Date(os.stat(fn)[0].mtime)
34 },
35 loadjs: function(fn, relay, onerror) {
36 try {
37 load(fn[0] == "/" ? fn : (path + fn))
38 if (relay)
39 relay()
40 }
41 catch(e) {
42 if (onerror)
43 onerror()
44 else
45 abc2svg.printErr("Cannot read file " + fn +
46 "\n " + e.name + ": " + e.message)
47 return
48 }
49 } // loadjs()
50 } // abc2svg
51
52 // --- main ---
53
54 if ( std.getenv("CHORDPRO_ABC_DEBUG") ) {
55 std.out.printf( "script = %s\n", script )
56 std.out.printf( "output = %s\n", output )
57 std.out.printf( "path = %s\n", path )
58 }
59
60 console.log = abc2svg.printErr
61
62 // Create output file and redirect output.
63 var out = std.open( output, "w" )
64 abc2svg.print = function(line) {
65 out.puts( line + '\n' )
66 }
67
68 // Load the abc2svg core.
69 load( path + "abc2svg-1.js" )
70 load( path + "../hooks.js" )
71 load( path + "cmdline.js" )
72
73 // Run the generator with the remaining arguments.
74 if ( os.open( path + "tohtml.js", 0, 0 ) >= 0 ) {
75 args.unshift("tohtml.js")
76 }
77 else {
78 args.unshift("toxhtml.js")
79 }
80 abc_cmd( "chordproabc", args, "QuickJS" )
81