]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_macrotable.h
Fix to bug 2362: Deleting superscript also deletes subscript.
[lyx.git] / src / mathed / math_macrotable.h
index d500b74645a26e963844cc3499f98fc022f3215c..4deb1cfde193d0d48cde40648d339865a61fe1ba 100644 (file)
 #define MATH_MACROTABLE_H
 
 #include <map>
-#include "support/std_string.h"
-#include "math_atom.h"
+#include <string>
+#include <vector>
 
+class MathArray;
 
-class MathMacroTable {
+
+///
+class MacroData {
 public:
        ///
-       static void create(MathAtom const &);
+       MacroData();
+       ///
+       MacroData(std::string const & def, int nargs, std::string const & disp);
        ///
-       static MathAtom & provide(string const & name);
+       std::string def() const { return def_; }
        ///
-       static bool has(string const & name);
+       std::string disp() const { return disp_; }
        ///
-       static void dump();
+       int numargs() const { return numargs_; }
+       /// replace #1,#2,... by given MathAtom 0,1,..
+       void expand(std::vector<MathArray> const & from, MathArray & to) const;
+
 private:
        ///
-       typedef std::map<string, MathAtom> table_type;
-       //
-       static table_type macro_table;
+       std::string def_;
+       ///
+       int numargs_;
+       ///
+       std::string disp_;
+};
+
+
+// This contains a table of "global" macros that are always accessible,
+// either because they implement a feature of standard LaTeX or some
+// hack to display certain contents nicely.
+
+class MacroTable : public std::map<std::string, MacroData>
+{
+public:
+       /// Parse full "\def..." or "\newcommand..." or ...
+       void insert(std::string const & definition);
+       /// Insert pre-digested macro definition
+       void insert(std::string const & name, MacroData const & data);
+       /// Do we have a macro by that name?
+       bool has(std::string const & name) const;
+       ///
+       MacroData const & get(std::string const & name) const;
+       ///
+       void dump();
+
+       /// the global list
+       static MacroTable & globalMacros();
+       /// the local list hack
+       //static MacroTable & localMacros();
 };
 
 #endif