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\\longleftrightarrow{\\leftarrow\\kern-8mu\\rightarrow}");
97 define("\\def\\Longleftrightarrow{\\Leftarrow\\kern-8mu\\Rightarrow}");
98 define("\\def\\doteq{\\stackrel{\\cdot}{\\=}}");
100 //if (math_font_available(LM_TC_CMSY)) {
101 define("\\def\\longrightarrow{\\lyxbar\\kern-6mu\\rightarrow}");
102 define("\\def\\longleftarrow{\\leftarrow\\kern-6mu\\lyxbar}");
103 define("\\def\\mapsto{\\mapstochar\\kern-4mu\\rightarrow}");
104 define("\\def\\longmapsto{\\mapstochar\\kern-3mu\\lyxbar\\kern-6mu\\rightarrow}");
107 //if (math_font_available(LM_TC_CMR) && math_font_available(LM_TC_CMSY)) {
108 define("\\def\\Longrightarrow{\\lyxeq\\kern-5mu\\Rightarrow}");
109 define("\\def\\Longleftarrow{\\Leftarrow\\kern-5mu\\lyxeq}");
110 define("\\def\\models{\\vert\\kern-3mu\\lyxeq}");
113 //if (math_font_available(LM_TC_CMM)) {
114 define("\\def\\hookrightarrow{\\lhook\\kern-8mu\\rightarrow}");
115 define("\\def\\hookleftarrow{\\leftarrow\\kern-8mu\\rhook}");
116 define("\\def\\bowtie{\\triangleright\\kern-2mu\\triangleleft}");
119 //if (math_font_available(LM_TC_MSA)) {
122 define("\\def\\dashrightarrow{\\lyxdabar\\lyxdabar\\lyxright}");
123 define("\\def\\dashleftarrow{\\lyxleft\\lyxdabar\\lyxdabar}");
124 define("\\def\\dasharrow{\\dashrightarrow}");
125 define("\\def\\leadsto{\\rightsquigarrow}");
129 define("\\def\\restriction{\\upharpoonright}");
130 define("\\def\\Doteq{\\doteqdot}");
131 define("\\def\\doublecup{\\Cup}");
132 define("\\def\\doublecap{\\Cap}");
135 //if (math_font_available(LM_TC_MSB)) {
136 define("\\def\\Join{\\ltimes\\kern-12mu\\rtimes}");
140 define("\\def\\mathcircumflex{\\mbox{\\^{}}}\n" "{\\hat{}}");
142 //define("\def\lint", 4, "\\int_#1^#2#3 d#4}");
143 //define("\\def\\silentmult{\\cdot}");
144 //define("\def\binom", 2, "\\left(\\frac#1#2\\right)}");