App-Music-ChordPro

 view release on metacpan or  search on metacpan

lib/ChordPro/res/abc/abc2svg/nns-1.js  view on Meta::CPAN

		C = abc2svg.C
		tsfirst = this.get_tsfirst()
		fmt = tsfirst.fmt
		voice_tb = this.get_voice_tb()
		p_v = voice_tb[this.get_top_v()]
		s = {
			type: C.BLOCK,
			subtype: 'nns',
			dur: 0,
			time: 0,
			p_v: p_v,
			v: p_v.v,
			st: p_v.st
		}

		build_chords(s)			// build the array of the chords

		// and insert it in the tune
		if (!s.chords) {		// if no chord
			;
		} else if (nns.nomusic) {	// if just the chords
			this.set_tsfirst(s)
		} else if (nns.n < 0) {		// below
			for (s2 = tsfirst; s2.ts_next; s2 = s2.ts_next)
				;
			s.time = s2.time
			s.prev = p_v.last_sym.prev // before the last symbol
			s.prev.next = s
			s.next = p_v.last_sym
			p_v.last_sym.prev = s

			s.ts_prev = s2.ts_prev
			s.ts_prev.ts_next = s
			s.ts_next = s2
			s2.ts_prev = s
			if (s2.seqst) {
				s.seqst = true
				s2.seqst = false
			}
		} else {			// above
			s.next = p_v.sym
			s.ts_next = tsfirst
			tsfirst.ts_prev = s
			this.set_tsfirst(s)
			p_v.sym.prev = s
			p_v.sym = s
		}
		s.fmt = s.prev ? s.prev.fmt : fmt
	}
	of()
    }, // set_stems()

    set_fmt: function(of, cmd, parm) {
	if (cmd == "nns") {
		if (!parm)
			parm = "1"
		parm = parm.split(/\s+/)
	    var	nns = {
			n: Number(parm.shift())
		}
		if (isNaN(nns.n)) {
			if (parm.length) {
				this.syntax(1, this.errs.bad_val, "%%nns")
				return
			}
			nns.n = 1
		}
		while (parm.length) {
			var item = parm.shift()
			if (item == "nomusic")
				nns.nomusic = true
			else if (item == "roman")
				nns.roman = 1
			else if (item == "repbrk")
				nns.repbrk = true
			else if (item.slice(0, 8) == "include=")
				nns.ls = item.slice(8).split(',')
			else if (item.slice(0, -1) == "roman=")
				nns.roman = item.slice(-1) == "1" ? 1 : 2
		}
		this.cfmt().nns = nns
		return
	}
	of(cmd, parm)
    },

    set_hooks: function(abc) {
	abc.block_gen = abc2svg.nns.block_gen.bind(abc, abc.block_gen)
	abc.set_stems = abc2svg.nns.set_stems.bind(abc, abc.set_stems)
	abc.set_format = abc2svg.nns.set_fmt.bind(abc, abc.set_format)
    }
} // nns

if (!abc2svg.mhooks)
	abc2svg.mhooks = {}
abc2svg.mhooks.nns = abc2svg.nns.set_hooks



( run in 3.202 seconds using v1.01-cache-2.11-cpan-354807fb38d )