-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathsibmei4_extension_test.plg
88 lines (76 loc) · 2.96 KB
/
sibmei4_extension_test.plg
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
{
SibmeiExtensionAPIVersion "2.0.0"
Initialize "() {
AddToPluginsMenu('Sibmei extension test', 'Run');
}"
Run "() {
// The plugin will be listed in the menu, but it is not runnable. Give some
// instructions instead of showing no response when users try to run it.
Sibelius.MessageBox(
'This plug-in is an extension of the sibmei MEI export plug-in. To use it, run MEI export.'
);
}"
InitSibmeiExtension "(api) {
Self._property:MySymbolTemplate = @Element('Symbol', @Attrs(
'fontfam', 'myCustomFont',
'glyph.name', 'mySymbolGlyph'
));
api.RegisterSymbolHandlers('Name', 'HandleMySymbol', CreateDictionary(
'My symbol', null
));
api.RegisterSymbolHandlers('Name', 'ModifierTemplateHandler', CreateDictionary(
'My soft accent', @Element('Artic', @Attrs(
'artic', 'acc',
'glyph.auth', 'smufl',
'glyph.name', 'articSoftAccentAbove',
'glyph.num', 'U+ED40'
))
));
api.RegisterTextHandlers('StyleAsText', 'HandleXPathTest', CreateDictionary(
// Example of a text generated by means of a custom text handler
'XPath test', null
));
api.RegisterTextHandlers('StyleAsText', 'ControlEventTemplateHandler', CreateDictionary(
// Example of a text generated by template
'My text', @Element('AnchoredText', @Attrs(), api.FormattedText)
));
api.RegisterTextHandlers('StyleId', 'ControlEventTemplateHandler', CreateDictionary(
// Example of a overridden built-in style
'text.staff.plain', @Element('AnchoredText', @Attrs(), api.UnformattedText)
));
api.RegisterLineHandlers('StyleAsText', 'ControlEventTemplateHandler', CreateDictionary(
'My line', @Element('Line', @Attrs(
'type', 'myline', 'endid', 'PreciseMatch'
))
));
api.RegisterLyricHandlers('StyleAsText', 'LyricTemplateHandler', CreateDictionary(
'My italic lyrics', @Element('Verse', null,
@Element('Syl', null,
@Element('Rend', @Attrs('rend', 'italic'), api.LyricText)
)
)
));
}"
HandleMySymbol "(api, obj) {
symbolElement = api.GenerateControlEvent(obj, api.MeiFactory(MySymbolTemplate, obj));
if (obj.ColorRed = 255) {
api.libmei.AddAttribute(symbolElement, 'type', 'myRedType');
}
return symbolElement;
}"
HandleXPathTest "(api, textObj) {
// This text style is used by the sibmei test suite
annotElement = api.GenerateControlEvent(textObj, api.libmei.Annot());
api.libmei.AddAttribute(annotElement, 'type', 'xpath-test');
textWithFormatting = textObj.TextWithFormatting;
for i = 0 to textWithFormatting.NumChildren {
if (CharAt(textWithFormatting[i], 0) = '\\') {
// Remove formatting and newlines. fontoxpath will complain if there is
// additional whitespace in XPath expressions.
textWithFormatting[i] = '';
}
}
api.libmei.SetText(annotElement, JoinStrings(textWithFormatting, ''));
return annotElement;
}"
}