]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/formulabase.C
use stream-like syntax for LaTeX output
[lyx.git] / src / mathed / formulabase.C
index 38dda883f567c7c6d605a367f9413192947b800c..f7b9e49b3364d2f59e9e25fda2dc6df101c3324c 100644 (file)
@@ -16,6 +16,7 @@
 #include <fstream>
 
 #include "Lsstream.h"
+#include "support/LAssert.h"
 
 #ifdef __GNUG__
 #pragma implementation
@@ -103,6 +104,7 @@ MathArrayInset * matrixpar(MathInset::idx_type & idx)
 
 
 InsetFormulaBase::InsetFormulaBase()
+       : view_(0), font_(0)
 {
        // This is needed as long the math parser is not re-entrant
        MathMacroTable::builtinMacros();
@@ -115,6 +117,17 @@ void InsetFormulaBase::validate(LaTeXFeatures &) const
 {}
 
 
+void InsetFormulaBase::metrics(BufferView * bv, LyXFont const * f) const 
+{
+       if (bv)
+               view_ = bv;
+       if (f)
+               font_ = f;
+       MathMetricsInfo mi(view_, font_, display() ? LM_ST_DISPLAY : LM_ST_TEXT);
+       par()->metrics(mi);
+}
+
+
 string const InsetFormulaBase::editMessage() const
 {
        return _("Math editor mode");
@@ -127,7 +140,7 @@ void InsetFormulaBase::edit(BufferView * bv, int x, int /*y*/, unsigned int)
                lyxerr[Debug::MATHED] << "Cannot lock inset!!!" << endl;
 
        mathcursor = new MathCursor(this, x == 0);
-       metrics();
+       metrics(bv);
        // if that is removed, we won't get the magenta box when entering an
        // inset for the first time
        bv->updateInset(this, false);
@@ -232,7 +245,7 @@ vector<string> const InsetFormulaBase::getLabelList() const
 
 void InsetFormulaBase::updateLocal(BufferView * bv, bool dirty)
 {
-       metrics();
+       metrics(bv);
        bv->updateInset(this, dirty);
 }
 
@@ -641,10 +654,11 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
                result = UNDISPATCHED;
        }
 
+       lyx::Assert(mathcursor);
        //mathcursor->normalize();
 
-       if (was_macro != mathcursor->inMacroMode()
-                               && action >= 0 && action != LFUN_BACKSPACE) 
+       if (//was_macro != mathcursor->inMacroMode() &&
+                               action >= 0 && action != LFUN_BACKSPACE) 
                updateLocal(bv, true);
        
        if (mathcursor->selection() || was_selection)
@@ -675,8 +689,7 @@ void mathDispatchCreation(BufferView * bv, string const & arg, bool display)
                //      sel = "";
                //else
 
-               string sel = bv->getLyXText()->selectionAsString(bv->buffer(),
-                                                                false);
+               string sel = bv->getLyXText()->selectionAsString(bv->buffer(), false);
 
                InsetFormulaBase * f;
                if (sel.empty()) {