]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/MathSupport.cpp
Move some Cursor methods to CursorData
[lyx.git] / src / mathed / MathSupport.cpp
index 222807bba4a40b303d92492a913af6f68932e5df..bb6a21c74d74ce9e302b18c5982a51f1cadfc63b 100644 (file)
 #include "InsetMathSymbol.h"
 #include "Length.h"
 #include "MathData.h"
+#include "MathFactory.h"
 #include "MathParser.h"
 #include "MathStream.h"
 
+#include "LaTeXFeatures.h"
 #include "MetricsInfo.h"
 
 #include "frontends/FontLoader.h"
@@ -503,7 +505,7 @@ deco_struct const * search_deco(docstring const & name)
 }
 
 
-} // namespace anon
+} // namespace
 
 
 int mathed_font_em(FontInfo const & font)
@@ -554,7 +556,7 @@ int mathed_char_width(FontInfo const & font, char_type c)
 int mathed_char_kerning(FontInfo const & font, char_type c)
 {
        frontend::FontMetrics const & fm = theFontMetrics(font);
-       return fm.rbearing(c) - fm.width(c);
+       return max(0, fm.rbearing(c) - fm.width(c));
 }
 
 
@@ -959,8 +961,13 @@ docstring asString(MathData const & ar)
 
 void asArray(docstring const & str, MathData & ar, Parse::flags pf)
 {
+       // If the QUIET flag is set, we are going to parse for either
+       // a paste operation or a macro definition. We try to do the
+       // right thing in all cases.
+
        bool quiet = pf & Parse::QUIET;
-       if ((str.size() == 1 && quiet) || (!mathed_parse_cell(ar, str, pf) && quiet))
+       bool macro = pf & Parse::MACRODEF;
+       if ((str.size() == 1 && quiet) || (!mathed_parse_cell(ar, str, pf) && quiet && !macro))
                mathed_parse_cell(ar, str, pf | Parse::VERBATIM);
 }
 
@@ -985,4 +992,23 @@ docstring asString(MathAtom const & at)
 }
 
 
+int axis_height(MetricsBase & mb)
+{
+       Changer dummy = mb.changeFontSet("mathnormal");
+       return theFontMetrics(mb.font).ascent('-') - 1;
+}
+
+
+void validate_math_word(LaTeXFeatures & features, docstring const & word)
+{
+       MathWordList const & words = mathedWordList();
+       MathWordList::const_iterator it = words.find(word);
+       if (it != words.end()) {
+               string const req = it->second.requires;
+               if (!req.empty())
+                       features.require(req);
+       }
+}
+
+
 } // namespace lyx