Spaces:
Sleeping
Sleeping
File size: 805 Bytes
d605f27 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
import {BaseTerm} from "./lilyTerms";
// eslint-disable-next-line
import LilyDocument from "./lilyDocument";
type MeasureLocationTable = {[key: number]: {[key: number]: number}};
const assignMeasures = (doc: LilyDocument, locationTable: MeasureLocationTable) => {
doc.root.forEachTerm(BaseTerm, term => {
if (term._location) {
for (let line = term._location.lines[0]; line <= term._location.lines[1]; ++line) {
const lineTable = locationTable[line];
if (lineTable) {
const item = Object.entries(lineTable).find(([key]) => {
const column = Number(key);
return column >= term._location.columns[0] && column < term._location.columns[1];
});
if (item) {
term._measure = item[1];
break;
}
}
}
}
});
};
export {
assignMeasures,
};
|