summaryrefslogtreecommitdiff
path: root/support/gregoriotex/tex/luatex/gregoriotex-common.tex
blob: 4821ef47448993f960d9edc2c06e33cf113906f4 (plain)
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
%GregorioTeX common file (stuff needed by both gregoriotex and gregoriosyms)
%
% Copyright (C) 2007-2021 The Gregorio Project (see CONTRIBUTORS.md)
%
% This file is part of Gregorio.
%
% Gregorio is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% Gregorio is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with Gregorio.  If not, see <http://www.gnu.org/licenses/>.

\gre@declarefileversion{gregoriotex-common.tex}{6.0.0-beta2}% GREGORIO_VERSION

\ifnum\luatexversion<76%
	\gre@error{Error: this document must be compiled with LuaTeX (lualatex) 0.76 or later}%
\fi%

%%%%%%%%%
%% Debugging
%%%%%%%%%

\def\gre@debugmsg#1#2{%
	\IfStrEq{\gre@debug}{}{}%
		%false
		{\IfStrEq{#1}{all}%
			%true
			{\gre@error{Debug error: ‘all’ is not a permitted keyword}}%
			%false
			{\IfStrEq{\gre@debug}{,all,}%
				%true
				{\gre@typeout{GregorioTeX debug: (#1) #2}}%
				%false
				{\IfSubStr{\gre@debug}{,#1,}%
					%true
					{\gre@typeout{GregorioTeX debug: (#1) #2}}%
					%false
					{\relax}%
				}%
			}%
		}%
}%

\def\gre@fixdebug{%
	{% we're starting a group in order to localize \exploregroups
		\exploregroups%
		\StrRemoveBraces{\gre@debug}[\gre@debug]%
		\xdef\gre@debug{,\gre@debug,}%
	}%
}%

\IfStrEq{\gre@debug}{}{% then
}{% else
	\typeout{GregorioTeX is in debug mode}%
	\typeout{\gre@debug\space messages will be printed to the log.}%
	\gre@fixdebug\relax %
}%

%%%%%%%%%%%%%
% Macros to handle deprecation path.
%%%%%%%%%%%%%

% #1 - the deprecated macro
% #2 - the correct macro to use
\def\gre@deprecated#1#2{%
	\ifgre@allowdeprecated%
		\ifx&#2&%
			\gre@warning{#1\space is deprecated and marked for removal}%
		\else%
			\gre@warning{#1\space is deprecated.\MessageBreak Use #2\space instead}%
		\fi%
	\else%
		\ifx&#2&%
			\gre@error{#1\space is deprecated and marked for removal}%
		\else%
			\gre@error{#1\space is deprecated.\MessageBreak Use #2\space instead}%
		\fi%
	\fi%
	\relax%
}%

\def\gre@obsolete#1#2{%
	\ifx&#2&%
		\gre@error{#1\space is obsolete and no longer has any effect}%
	\else%
		\gre@error{#1\space is obsolete.\MessageBreak Use #2\space instead}%
	\fi%
	\relax%
}%

%%%%%%%%%%%%%
% Internal function tracing
%%%%%%%%%%%%%

% Each function in the internal name space (\gre@...) should have an invocation of
% \gre@trace as its first line with the argument being the name of the function (without
% the backslash) and the list of arguments.
% The last line of these functions should be \gre@trace@end.
% Macros which merely store a value are not considered to be functions and thus not
% included in the trace stack.
% We also exempt the internal aliases for functions defined elsewhere.
% The tracing messages are turned on via the debug interface, keyword: trace.

\def\gre@trace@prefix{GreTrace: }
\def\gre@trace#1{%
	\IfSubStr{\gre@debug}{,trace,}%
		{%print tracing messages and increase indent
			\gre@typeout{\gre@trace@prefix \unexpanded{#1}}%
			\edef\gre@trace@prefix{\gre@trace@prefix| }%
		}{}%do nothing if not tracing
}%
\def\gre@trace@end{%
	\IfSubStr{\gre@debug}{,trace,}%
		{%dedent trace messages and mark end
			\StrGobbleRight{\gre@trace@prefix}{2}[\gre@trace@prefix]%
			\gre@typeout{\gre@trace@prefix -----}%
		}{}%do nothing if not tracing
}