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(string const & name, int na, string const & text)
58 MathAtom t(new MathMacroTemplate(name, na));
59 mathed_parse_cell(t->cell(0), name);
60 mathed_parse_cell(t->cell(1), text);
61 macro_table[name] = t;
66 void MathMacroTable::create
67 (string const & name, int na, MathArray const & ar1, MathArray const & ar2)
69 MathAtom t(new MathMacroTemplate(name, na));
72 macro_table[name] = t;
77 bool MathMacroTable::has(string const & name)
80 return macro_table.find(name) != macro_table.end();
84 void MathMacroTable::builtinMacros()
86 static bool built = false;
92 //lyxerr[Debug::MATHED] << "Building macros\n";
93 //create("emptyset", 0, "\\not0");
94 create("notin", 0, "\\not\\in");
95 create("slash", 0, "/");
99 create("lnot", 0, "\\neg");
100 create("land", 0, "\\wedge");
101 create("lor", 0, "\\vee");
102 create("ne", 0, "\\neq");
103 create("le", 0, "\\leq");
104 create("ge", 0, "\\geq");
105 create("owns", 0, "\\ni");
106 create("gets", 0, "\\leftarrow");
107 create("to", 0, "\\rightarrow");
108 create("|", 0, "\\Vert");
110 create("longleftrightarrow", 0, "\\leftarrow\\kern-8mu\\rightarrow");
111 create("Longleftrightarrow", 0, "\\Leftarrow\\kern-8mu\\Rightarrow");
112 create("doteq", 0, "\\stackrel{\\cdot}{=}");
114 if (math_font_available(LM_TC_CMSY)) {
115 create("longrightarrow", 0, "\\lyxbar\\kern-6mu\\rightarrow");
116 create("longleftarrow", 0, "\\leftarrow\\kern-6mu\\lyxbar");
117 create("mapsto", 0, "\\mapstochar\\kern-4mu\\rightarrow");
118 create("longmapsto", 0, "\\mapstochar\\kern-3mu\\lyxbar\\kern-6mu\\rightarrow");
121 if (math_font_available(LM_TC_CMR) && math_font_available(LM_TC_CMSY)) {
122 create("Longrightarrow", 0, "\\lyxeq\\kern-5mu\\Rightarrow");
123 create("Longleftarrow", 0, "\\Leftarrow\\kern-5mu\\lyxeq");
124 create("models", 0, "\\vert\\kern-3mu\\lyxeq");
127 if (math_font_available(LM_TC_CMM)) {
128 create("hookrightarrow", 0, "\\lhook\\kern-8mu\\rightarrow");
129 create("hookleftarrow", 0, "\\leftarrow\\kern-8mu\\rhook");
130 create("bowtie", 0, "\\triangleright\\kern-2mu\\triangleleft");
133 if (math_font_available(LM_TC_MSA)) {
136 create("dashrightarrow", 0, "\\lyxdabar\\lyxdabar\\lyxright");
137 create("dashleftarrow", 0, "\\lyxleft\\lyxdabar\\lyxdabar");
138 create("dasharrow", 0, "\\dashrightarrow");
139 create("Box", 0, "\\square");
140 create("Diamond", 0, "\\lozenge");
141 create("leadsto", 0, "\\rightsquigarrow");
145 create("restriction", 0, "\\upharpoonright");
146 create("Doteq", 0, "\\doteqdot");
147 create("doublecup", 0, "\\Cup");
148 create("doublecap", 0, "\\Cap");
149 create("llless", 0, "\\lll");
150 create("gggtr", 0, "\\ggg");
153 if (math_font_available(LM_TC_MSB)) {
154 create("Join", 0, "\\ltimes\\kern-12mu\\rtimes");
157 //create("lint", 4, "\\int_#1^#2#3 d#4");
158 //create("silentmult", 0, "\\cdot");
159 //create("binom", 2, "\\left(\\frac#1#2\\right)");