9 #include "math_macrotable.h"
10 #include "math_macro.h"
11 #include "math_macrotemplate.h"
12 #include "math_parser.h"
13 #include "math_mathmlstream.h"
15 #include "math_support.h" // math_font_available
18 MathMacroTable::table_type MathMacroTable::macro_table;
21 void MathMacroTable::dump()
24 lyxerr << "\n------------------------------------------\n";
25 table_type::const_iterator it;
26 for (it = macro_table.begin(); it != macro_table.end(); ++it)
28 << " [" << it->second->asMacroTemplate()->nargs() << "] : "
29 << it->second->cell(0) << "\n";
30 lyxerr << "------------------------------------------\n";
35 MathAtom & MathMacroTable::provide(string const & name)
39 table_type::iterator pos = macro_table.find(name);
41 if (pos == macro_table.end()) {
42 lyxerr << "MathMacroTable::provideTemplate: no template with name '"
43 << name << "' available.\n";
50 void MathMacroTable::create(string const & name, int na)
52 macro_table[name] = MathAtom(new MathMacroTemplate(name, na));
56 void MathMacroTable::create
57 (string const & name, int na, MathArray const & ar1, MathArray const & ar2)
59 MathAtom t(new MathMacroTemplate(name, na));
62 macro_table[name] = t;
66 void MathMacroTable::define(string const & display)
69 mathed_parse_macro(name, display);
73 bool MathMacroTable::has(string const & name)
76 return macro_table.find(name) != macro_table.end();
80 void MathMacroTable::builtinMacros()
82 static bool built = false;
88 //lyxerr[Debug::MATHED] << "Building macros\n";
89 //define("\\def\\emptyset{\\not0}");
90 define("\\def\\notin{\\not\\in}");
91 define("\\def\\slash{/}");
92 //define("\\def\\mathcircumflex{\\^}");
96 define("\\def\\lnot{\\neg}");
97 define("\\def\\land{\\wedge}");
98 define("\\def\\lor{\\vee}");
99 define("\\def\\ne{\\neq}");
100 define("\\def\\le{\\leq}");
101 define("\\def\\ge{\\geq}");
102 define("\\def\\owns{\\ni}");
103 define("\\def\\gets{\\leftarrow}");
104 define("\\def\\to{\\rightarrow}");
105 define("\\def\\|{\\Vert}");
107 define("\\def\\longleftrightarrow{\\leftarrow\\kern-8mu\\rightarrow}");
108 define("\\def\\Longleftrightarrow{\\Leftarrow\\kern-8mu\\Rightarrow}");
109 define("\\def\\doteq{\\stackrel{\\cdot}{\\=}}");
111 if (math_font_available(LM_TC_CMSY)) {
112 define("\\def\\longrightarrow{\\lyxbar\\kern-6mu\\rightarrow}");
113 define("\\def\\longleftarrow{\\leftarrow\\kern-6mu\\lyxbar}");
114 define("\\def\\mapsto{\\mapstochar\\kern-4mu\\rightarrow}");
115 define("\\def\\longmapsto{\\mapstochar\\kern-3mu\\lyxbar\\kern-6mu\\rightarrow}");
118 if (math_font_available(LM_TC_CMR) && math_font_available(LM_TC_CMSY)) {
119 define("\\def\\Longrightarrow{\\lyxeq\\kern-5mu\\Rightarrow}");
120 define("\\def\\Longleftarrow{\\Leftarrow\\kern-5mu\\lyxeq}");
121 define("\\def\\models{\\vert\\kern-3mu\\lyxeq}");
124 if (math_font_available(LM_TC_CMM)) {
125 define("\\def\\hookrightarrow{\\lhook\\kern-8mu\\rightarrow}");
126 define("\\def\\hookleftarrow{\\leftarrow\\kern-8mu\\rhook}");
127 define("\\def\\bowtie{\\triangleright\\kern-2mu\\triangleleft}");
130 if (math_font_available(LM_TC_MSA)) {
133 define("\\def\\dashrightarrow{\\lyxdabar\\lyxdabar\\lyxright}");
134 define("\\def\\dashleftarrow{\\lyxleft\\lyxdabar\\lyxdabar}");
135 define("\\def\\dasharrow{\\dashrightarrow}");
136 define("\\def\\Box{\\square}");
137 define("\\def\\Diamond{\\lozenge}");
138 define("\\def\\leadsto{\\rightsquigarrow}");
142 define("\\def\\restriction{\\upharpoonright}");
143 define("\\def\\Doteq{\\doteqdot}");
144 define("\\def\\doublecup{\\Cup}");
145 define("\\def\\doublecap{\\Cap}");
146 define("\\def\\llless{\\lll}");
147 define("\\def\\gggtr{\\ggg}");
150 if (math_font_available(LM_TC_MSB)) {
151 define("\\def\\Join{\\ltimes\\kern-12mu\\rtimes}");
155 define("\\def\\mathcircumflex{\\mbox{\\^{}}}\n" "{\\hat{}}");
157 //define("\def\lint", 4, "\\int_#1^#2#3 d#4}");
158 //define("\\def\\silentmult{\\cdot}");
159 //define("\def\binom", 2, "\\left(\\frac#1#2\\right)}");