9 #include "math_macrotable.h"
10 #include "math_macro.h"
11 #include "math_macrotemplate.h"
12 #include "math_parser.h"
14 #include "support.h" // math_font_available
17 MathMacroTable::table_type MathMacroTable::macro_table;
20 void MathMacroTable::dump()
22 lyxerr << "\n------------------------------------------\n";
23 table_type::const_iterator it;
24 for (it = macro_table.begin(); it != macro_table.end(); ++it)
26 << " [" << it->second->asMacroTemplate()->nargs() << "] : "
27 << it->second->cell(0) << "\n";
28 lyxerr << "------------------------------------------\n";
32 MathAtom & MathMacroTable::provide(string const & name)
36 table_type::iterator pos = macro_table.find(name);
38 if (pos == macro_table.end()) {
39 lyxerr << "MathMacroTable::provideTemplate: no template with name '"
40 << name << "' available.\n";
47 void MathMacroTable::create(string const & name, int na, string const & text)
49 MathAtom t(new MathMacroTemplate(name, na));
50 mathed_parse_cell(t->cell(0), text);
51 macro_table[name] = t;
55 void MathMacroTable::create(string const & name, int na, MathArray const & ar)
57 MathAtom t(new MathMacroTemplate(name, na));
59 macro_table[name] = t;
64 bool MathMacroTable::has(string const & name)
67 return macro_table.find(name) != macro_table.end();
71 void MathMacroTable::builtinMacros()
73 static bool built = false;
79 //lyxerr[Debug::MATHED] << "Building macros\n";
81 //create("emptyset", 0, "\\not0");
82 create("notin", 0, "\\not\\in");
83 create("slash", 0, "/");
87 create("lnot", 0, "\\neg");
88 create("land", 0, "\\wedge");
89 create("lor", 0, "\\vee");
90 create("ne", 0, "\\neq");
91 create("le", 0, "\\leq");
92 create("ge", 0, "\\geq");
93 create("owns", 0, "\\ni");
94 create("gets", 0, "\\leftarrow");
95 create("to", 0, "\\rightarrow");
96 create("|", 0, "\\parallel");
98 create("longleftrightarrow", 0, "\\leftarrow\\kern-6mu\\rightarrow");
99 create("Longleftrightarrow", 0, "\\Leftarrow\\kern-6mu\\Rightarrow");
100 create("doteq", 0, "\\stackrel{\\cdot}{=}");
102 //create("models", 0, "|\\kern-9mu=");
104 if (math_font_available(LM_TC_CMSY)) {
105 create("longrightarrow", 0, "\\lyxbar\\kern-5mu\\rightarrow");
106 create("longleftarrow", 0, "\\leftarrow\\kern-5mu\\lyxbar");
107 create("mapsto", 0, "\\mapstochar\\rightarrow");
108 create("longmapsto", 0, "\\mapstochar\\lyxbar\\kern-5mu\\rightarrow");
111 if (math_font_available(LM_TC_CMR)) {
112 create("Longrightarrow", 0, "\\lyxeq\\kern-3mu\\Rightarrow");
113 create("Longleftarrow", 0, "\\Leftarrow\\kern-9mu\\lyxeq");
116 if (math_font_available(LM_TC_CMM)) {
117 create("hookrightarrow", 0, "\\lhook\\kern-5mu\\rightarrow");
118 create("hookleftarrow", 0, "\\leftarrow\\kern-5mu\\rhook");
119 create("bowtie", 0, "\\triangleright\\kern-3mu\\triangleleft");
122 if (math_font_available(LM_TC_MSA)) {
125 create("dashrightarrow", 0, "\\lyxdabar\\lyxdabar\\lyxright");
126 create("dashleftarrow", 0, "\\lyxleft\\lyxdabar\\lyxdabar");
127 create("dasharrow", 0, "\\dashrightarrow");
128 create("Box", 0, "\\square");
129 create("Diamond", 0, "\\lozenge");
130 create("leadsto", 0, "\\rightsquigarrow");
134 create("restriction", 0, "\\upharpoonright");
135 create("Doteq", 0, "\\doteqdot");
136 create("doublecup", 0, "\\Cup");
137 create("doublecap", 0, "\\Cap");
138 create("llless", 0, "\\lll");
139 create("gggtr", 0, "\\ggg");
142 //create("lint", 4, "\\int_#1^#2#3 d#4");
143 //create("silentmult", 0, "\\cdot");
144 //create("binom", 2, "\\left(\\frac#1#2\\right)");