]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_macrotable.h
Fix math cursor positioning bug
[lyx.git] / src / mathed / math_macrotable.h
index 5da3a0940c2d10e3655004e2f3f846035c101e65..4deb1cfde193d0d48cde40648d339865a61fe1ba 100644 (file)
@@ -1,40 +1,72 @@
 // -*- C++ -*-
-#ifndef MATHMACROTABLE
-#define MATHMACROTABLE
+/**
+ * \file math_macrotable.h
+ * 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.
+ */
 
-#include <map>
-#include "LString.h"
+#ifndef MATH_MACROTABLE_H
+#define MATH_MACROTABLE_H
 
-#include <boost/utility.hpp>
-#include <boost/smart_ptr.hpp>
+#include <map>
+#include <string>
+#include <vector>
 
-#ifdef __GNUG__
-#pragma interface
-#endif
+class MathArray;
 
-class MathMacroTemplate;
-class MathMacro;
 
 ///
-class MathMacroTable : boost::noncopyable {
+class MacroData {
 public:
        ///
-       void addTemplate(boost::shared_ptr<MathMacroTemplate> const &);
-       ///
-       MathMacro * createMacro(string const &) const;
+       MacroData();
        ///
-       boost::shared_ptr<MathMacroTemplate> const
-       getTemplate(string const &) const;
+       MacroData(std::string const & def, int nargs, std::string const & disp);
        ///
-       void builtinMacros();
+       std::string def() const { return def_; }
        ///
-       static MathMacroTable mathMTable;
+       std::string disp() const { return disp_; }
        ///
-       static bool built;
+       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, boost::shared_ptr<MathMacroTemplate> > table_type;
+       std::string def_;
+       ///
+       int numargs_;
        ///
-       table_type macro_table;
+       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