]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_macrotable.C
Add In nsetOld * argument to updateInset to rebreak the correct par.
[lyx.git] / src / mathed / math_macrotable.C
index 4b948fecaab685abff3bc023f6f7279f04db9526..885bd5b3b3738e00df1d4d466397937c7348cea7 100644 (file)
@@ -1,10 +1,14 @@
-#include <config.h>
-
-#include <iostream>
+/**
+ * \file math_macrotable.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author André Pönitz
+ *
+ * Full author contact details are available in file CREDITS.
+ */
 
-#ifdef __GNUG__
-#pragma implementation
-#endif
+#include <config.h>
 
 #include "math_macrotable.h"
 #include "math_macro.h"
 #include "debug.h"
 #include "math_support.h" // math_font_available
 
+#include <iostream>
+
+using std::endl;
+
 
 MathMacroTable::table_type MathMacroTable::macro_table;
 
@@ -21,140 +29,35 @@ MathMacroTable::table_type MathMacroTable::macro_table;
 void MathMacroTable::dump()
 {
 /*
-       lyxerr << "\n------------------------------------------\n";
+       lyxerr << "\n------------------------------------------" << endl;
        table_type::const_iterator it;
        for (it = macro_table.begin(); it != macro_table.end(); ++it)
                lyxerr << it->first
                        << " [" << it->second->asMacroTemplate()->nargs() << "] : "
-                       << it->second->cell(0) << "\n";
-       lyxerr << "------------------------------------------\n";
+                       << it->second->cell(0) << endl;
+       lyxerr << "------------------------------------------" << endl;
 */
 }
 
 
 MathAtom & MathMacroTable::provide(string const & name)
 {
-       builtinMacros();
-
        table_type::iterator pos = macro_table.find(name);
-
        if (pos == macro_table.end()) {
                lyxerr << "MathMacroTable::provideTemplate: no template with name '"
-                      << name << "' available.\n";
+                      << name << "' available." << endl;
        }
-
        return pos->second;
 }
 
 
-void MathMacroTable::create(string const & name, int na)
-{
-       macro_table[name] = MathAtom(new MathMacroTemplate(name, na));
-}
-
-
-void MathMacroTable::create(string const & name, int na, string const & text)
+void MathMacroTable::create(MathAtom const & at)
 {
-       MathAtom t(new MathMacroTemplate(name, na));
-       mathed_parse_cell(t->cell(0), name);
-       mathed_parse_cell(t->cell(1), text);
-       macro_table[name] = t;
+       macro_table[at->asMacroTemplate()->name()] = at;
 }
 
 
-
-void MathMacroTable::create
-       (string const & name, int na, MathArray const & ar1, MathArray const & ar2)
-{
-       MathAtom t(new MathMacroTemplate(name, na));
-       t->cell(0) = ar1;
-       t->cell(1) = ar2;
-       macro_table[name] = t;
-}
-
-
-
 bool MathMacroTable::has(string const & name)
 {
-       builtinMacros();
        return macro_table.find(name) != macro_table.end();
 }
-
-
-void MathMacroTable::builtinMacros()
-{
-       static bool built = false;
-
-       if (built)
-               return;
-
-       built = true;
-       //lyxerr[Debug::MATHED] << "Building macros\n";
-       //create("emptyset",     0, "\\not0");
-       create("notin",        0, "\\not\\in");
-       create("slash",        0, "/");
-
-       // fontmath.ltx
-
-       create("lnot",         0, "\\neg");
-       create("land",         0, "\\wedge");
-       create("lor",          0, "\\vee");
-       create("ne",           0, "\\neq");
-       create("le",           0, "\\leq");
-       create("ge",           0, "\\geq");
-       create("owns",         0, "\\ni");
-       create("gets",         0, "\\leftarrow");
-       create("to",           0, "\\rightarrow");
-       create("|",            0, "\\Vert");
-
-       create("longleftrightarrow", 0, "\\leftarrow\\kern-8mu\\rightarrow");
-       create("Longleftrightarrow", 0, "\\Leftarrow\\kern-8mu\\Rightarrow");
-       create("doteq", 0, "\\stackrel{\\cdot}{=}");
-
-       if (math_font_available(LM_TC_CMSY)) {
-               create("longrightarrow", 0, "\\lyxbar\\kern-6mu\\rightarrow");
-               create("longleftarrow",  0, "\\leftarrow\\kern-6mu\\lyxbar");
-               create("mapsto",  0, "\\mapstochar\\kern-4mu\\rightarrow");
-               create("longmapsto",  0, "\\mapstochar\\kern-3mu\\lyxbar\\kern-6mu\\rightarrow");
-       }
-
-       if (math_font_available(LM_TC_CMR) && math_font_available(LM_TC_CMSY)) {
-               create("Longrightarrow", 0, "\\lyxeq\\kern-5mu\\Rightarrow");
-               create("Longleftarrow",  0, "\\Leftarrow\\kern-5mu\\lyxeq");
-               create("models",         0, "\\vert\\kern-3mu\\lyxeq");
-       }
-
-       if (math_font_available(LM_TC_CMM)) {
-               create("hookrightarrow", 0, "\\lhook\\kern-8mu\\rightarrow");
-               create("hookleftarrow",  0, "\\leftarrow\\kern-8mu\\rhook");
-               create("bowtie",         0, "\\triangleright\\kern-2mu\\triangleleft");
-       }
-
-       if (math_font_available(LM_TC_MSA)) {
-               //amsfonts.sty
-
-               create("dashrightarrow", 0, "\\lyxdabar\\lyxdabar\\lyxright");
-               create("dashleftarrow", 0, "\\lyxleft\\lyxdabar\\lyxdabar");
-               create("dasharrow",    0, "\\dashrightarrow");
-               create("Box",          0, "\\square");
-               create("Diamond",      0, "\\lozenge");
-               create("leadsto",      0, "\\rightsquigarrow");
-
-               // amssymb.sty
-
-               create("restriction",  0, "\\upharpoonright");
-               create("Doteq",        0, "\\doteqdot");
-               create("doublecup",    0, "\\Cup");
-               create("doublecap",    0, "\\Cap");
-               create("llless",       0, "\\lll");
-               create("gggtr",        0, "\\ggg");
-       }
-
-       if (math_font_available(LM_TC_MSB)) {
-               create("Join",         0, "\\ltimes\\kern-12mu\\rtimes");
-       }
-
-       //create("lint",       4, "\\int_#1^#2#3 d#4");
-       //create("silentmult", 0, "\\cdot");
-       //create("binom",        2, "\\left(\\frac#1#2\\right)");
-}