]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/formulamacro.C
use stream-like syntax for LaTeX output
[lyx.git] / src / mathed / formulamacro.C
index d98c7b05309aad3d324d927eccb5b3086a491e76..b0188770d3f9e68a99085877f71b190e4da2b00a 100644 (file)
@@ -36,6 +36,7 @@
 #include "support/LOstream.h"
 #include "debug.h"
 #include "lyxlex.h"
+#include "lyxtext.h"
 #include "lyxfont.h"
 
 using std::ostream;
@@ -60,7 +61,10 @@ InsetFormulaMacro::InsetFormulaMacro(string const & s)
 {
        string name = mathed_parse_macro(s);
        setInsetName(name);
-       metrics();
+#ifdef WITH_WARNINGS
+#warning "metrics disabled"
+#endif
+       //metrics();
 }
 
 
@@ -70,23 +74,27 @@ Inset * InsetFormulaMacro::clone(Buffer const &, bool) const
 }
 
 
-void InsetFormulaMacro::write(Buffer const *, ostream & os) const
+void InsetFormulaMacro::write(Buffer const * buf, ostream & os) const
 {
        os << "FormulaMacro ";
-       par()->write(os, false);
+       MathWriteInfo wi(buf, os, false);
+       par()->write(wi);
 }
 
 
-int InsetFormulaMacro::latex(Buffer const *, ostream & os, bool fragile, 
+int InsetFormulaMacro::latex(Buffer const * buf, ostream & os, bool fragile, 
                             bool /*free_spacing*/) const
 {
-       par()->write(os, fragile);
+       MathWriteInfo wi(buf, os, fragile);
+       par()->write(wi);
        return 2;
 }
 
-int InsetFormulaMacro::ascii(Buffer const *, ostream & os, int) const
+
+int InsetFormulaMacro::ascii(Buffer const * buf, ostream & os, int) const
 {
-       par()->write(os, false);
+       MathWriteInfo wi(buf, os, false);
+       par()->write(wi);
        return 0;
 }
 
@@ -107,6 +115,7 @@ void InsetFormulaMacro::read(Buffer const *, LyXLex & lex)
 {
        string name = mathed_parse_macro(lex);
        setInsetName(name);
+       lyxerr << "metrics disabled";
        metrics();
 }
 
@@ -129,9 +138,9 @@ int InsetFormulaMacro::descent(BufferView *, LyXFont const &) const
 }
 
 
-int InsetFormulaMacro::width(BufferView *, LyXFont const & f) const
+int InsetFormulaMacro::width(BufferView * bv, LyXFont const & f) const
 {
-       metrics();
+       metrics(bv, &f);
        return 10 + lyxfont::width(prefix(), f) + par()->width();
 }
 
@@ -155,8 +164,14 @@ InsetFormulaMacro::localDispatch(BufferView * bv,
                        break;
                }
                
-               default:
+               default: {
                        result = InsetFormulaBase::localDispatch(bv, action, arg);
+                       // force redraw if anything happened
+                       if (result != UNDISPATCHED) {
+                               bv->text->status(bv, LyXText::NEED_MORE_REFRESH);
+                               bv->updateInset(this, false);
+                       }
+               }
        }
        return result;
 }
@@ -186,12 +201,6 @@ MathInsetTypes InsetFormulaMacro::getType() const
 }
 
 
-void InsetFormulaMacro::metrics() const
-{
-       par()->metrics(LM_ST_TEXT);
-}
-
-
 void InsetFormulaMacro::draw(BufferView * bv, LyXFont const & f,
                             int baseline, float & x, bool /*cleared*/) const
 {