]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_inset.C
swallow <Return> events in mathed. Should mimic 1.3.x behaviour.
[lyx.git] / src / mathed / math_inset.C
index 428a5297137a7db2bf08699341339bffa682d5ed..00f9c90124c2306a2641963cde4bc8d9b5e67311 100644 (file)
-/*
- *  File:        math_inset.C
- *  Purpose:     Implementation of insets for mathed
- *  Author:      Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
- *  Created:     January 1996
- *  Description:
+/**
+ * \file math_inset.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
- *  Dependencies: Xlib, XForms
+ * \author Alejandro Aguilar Sierra
+ * \author André Pönitz
  *
- *  Copyright: 1996, 1997 Alejandro Aguilar Sierra
- *
- *   Version: 0.8beta.
- *
- *   You are free to use and modify this code under the terms of
- *   the GNU General Public Licence version 2 or later.
+ * Full author contact details are available in file CREDITS.
  */
 
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
 #include <config.h>
 
-#include "Lsstream.h"
 #include "math_inset.h"
-#include "math_scriptinset.h"
-#include "math_charinset.h"
+#include "math_data.h"
 #include "math_mathmlstream.h"
-#include "math_cursor.h"
 #include "debug.h"
 
-#include "frontends/LyXView.h"
-#include "frontends/Dialogs.h"
-#include "BufferView.h"
-#include "formulabase.h"
-
-
+using std::string;
 using std::ostream;
-using std::vector;
-
-
-int MathInset::height() const
-{
-       return ascent() + descent();
-}
-
-
-ostream & operator<<(ostream & os, MathAtom const & at)
-{
-       if (at.nucleus())
-               os << *(at.nucleus());
-       else
-               os << "(nil)";
-       return os;
-}
-
+using std::endl;
 
-ostream & operator<<(ostream & os, MathInset const & inset)
-{
-       WriteStream wi(os, false, false);
-       inset.write(wi);
-       return os;
-}
-
-MathInset::size_type MathInset::nargs() const
-{
-       return 0;
-}
-
-
-void MathInset::dimensions(int & w, int & a, int & d) const
-{
-       w = width();
-       a = ascent();
-       d = descent();
-}
-
-
-MathXArray dummyCell;
-
-MathXArray & MathInset::xcell(idx_type)
-{
-       lyxerr << "I don't have a cell 1\n";
-       return dummyCell;
-}
-
-
-MathXArray const & MathInset::xcell(idx_type) const
-{
-       lyxerr << "I don't have a cell 2\n";
-       return dummyCell;
-}
 
+MathArray dummyCell;
 
 MathArray & MathInset::cell(idx_type)
 {
-       lyxerr << "I don't have a cell 3\n";
-       return dummyCell.data();
+       lyxerr << "I don't have a cell 1" << endl;
+       return dummyCell;
 }
 
 
 MathArray const & MathInset::cell(idx_type) const
 {
-       lyxerr << "I don't have a cell 4\n";
-       return dummyCell.data();
+       lyxerr << "I don't have a cell 2" << endl;
+       return dummyCell;
 }
 
 
-MathInset::idx_type MathInset::index(row_type row, col_type col) const
-{
-       if (row != 0)
-               lyxerr << "illegal row: " << row << "\n";
-       if (col != 0)
-               lyxerr << "illegal col: " << col << "\n";
-       return 0;
-}
-
 void MathInset::substitute(MathMacro const &)
 {}
 
 
-bool MathInset::idxNext(idx_type &, pos_type &) const
-{
-       return false;
-}
-
-
-bool MathInset::idxRight(idx_type &, pos_type &) const
-{
-       return false;
-}
-
-
-bool MathInset::idxPrev(idx_type &, pos_type &) const
-{
-       return false;
-}
-
-
-bool MathInset::idxLeft(idx_type &, pos_type &) const
-{
-       return false;
-}
-
-
-bool MathInset::idxUpDown(idx_type &, bool) const
-{
-       return false;
-}
-
-
-bool MathInset::idxFirst(idx_type &, pos_type &) const
-{
-       return false;
-}
-
-
-bool MathInset::idxLast(idx_type &, pos_type &) const
-{
-       return false;
-}
-
-
-bool MathInset::idxHome(idx_type &, pos_type &) const
-{
-       return false;
-}
-
-
-bool MathInset::idxEnd(idx_type &, pos_type &) const
-{
-       return false;
-}
-
-
-void MathInset::normalize(NormalStream & os) const
-{
-       os << "[unknown ";
-       WriteStream wi(os.os(), false, true);
-       write(wi);
-       os << "] ";
-}
-
 
 void MathInset::dump() const
 {
-       lyxerr << "---------------------------------------------\n";
+       lyxerr << "---------------------------------------------" << endl;
        WriteStream wi(lyxerr, false, true);
        write(wi);
-       lyxerr << "\n---------------------------------------------\n";
+       lyxerr << "\n---------------------------------------------" << endl;
 }
 
 
-void MathInset::validate(LaTeXFeatures &) const
-{}
-
-
-vector<MathInset::idx_type>
-       MathInset::idxBetween(idx_type from, idx_type to) const
-{
-       vector<idx_type> res;
-       for (idx_type i = from; i <= to; ++i)
-               res.push_back(i);
-       return res;
-}
-
-
-void MathInset::metrics(MathMetricsInfo &) const
-{
-       lyxerr << "MathInset::metrics() called directly!\n";
-}
-
-
-void MathInset::draw(MathPainterInfo &, int, int) const
-{
-       lyxerr << "MathInset::draw() called directly!\n";
-}
-
-
-void MathInset::metricsT(TextMetricsInfo const &) const
+void MathInset::metricsT(TextMetricsInfo const &, Dimension &) const
 {
 #ifdef WITH_WARNINGS
-       lyxerr << "MathInset::metricsT(Text) called directly!\n";
+       lyxerr << "MathInset::metricsT(Text) called directly!" << endl;
 #endif
 }
 
@@ -228,109 +62,76 @@ void MathInset::metricsT(TextMetricsInfo const &) const
 void MathInset::drawT(TextPainter &, int, int) const
 {
 #ifdef WITH_WARNINGS
-       lyxerr << "MathInset::drawT(Text) called directly!\n";
+       lyxerr << "MathInset::drawT(Text) called directly!" << endl;
 #endif
 }
 
 
 
-void MathInset::write(WriteStream &) const
+void MathInset::write(WriteStream & os) const
 {
-       lyxerr << "MathInset::write() called directly!\n";
+       os << '\\' << name().c_str();
+       os.pendingSpace(true);
 }
 
 
-void MathInset::octavize(OctaveStream & os) const
-{
-       NormalStream ns(os.os());
-       normalize(ns);
-}
-
-
-void MathInset::maplize(MapleStream & os) const
+void MathInset::normalize(NormalStream & os) const
 {
-       NormalStream ns(os.os());
-       normalize(ns);
+       os << '[' << name().c_str() << "] ";
 }
 
 
-void MathInset::mathematicize(MathematicaStream & os) const
+void MathInset::octave(OctaveStream & os) const
 {
        NormalStream ns(os.os());
        normalize(ns);
 }
 
 
-void MathInset::mathmlize(MathMLStream & os) const
+void MathInset::maple(MapleStream & os) const
 {
        NormalStream ns(os.os());
        normalize(ns);
 }
 
 
-int MathInset::ascii(std::ostream &, int) const
-{
-       return 0;
-}
-
-
-int MathInset::linuxdoc(std::ostream &) const
-{
-       return 0;
-}
-
-
-int MathInset::docbook(std::ostream &, bool) const
+void MathInset::maxima(MaximaStream & os) const
 {
-       return 0;
+       MapleStream ns(os.os());
+       maple(ns);
 }
 
 
-int MathInset::dispatch(string const &, idx_type, pos_type) 
+void MathInset::mathematica(MathematicaStream & os) const
 {
-       return 0; // undispatched
+       NormalStream ns(os.os());
+       normalize(ns);
 }
 
 
-std::vector<string> MathInset::getLabelList() const
+void MathInset::mathmlize(MathMLStream & os) const
 {
-       return std::vector<string>();
+       NormalStream ns(os.os());
+       normalize(ns);
 }
 
 
 string const & MathInset::getType() const
 {
-       static string t("none");
+       static string const t("none");
        return t;
 }
 
 
-string asString(MathArray const & ar)
-{
-       string res;
-       for (MathArray::const_iterator it = ar.begin(); it != ar.end(); ++it)
-               if ((*it)->getChar())
-                       res += (*it)->getChar();
-       return res;
-}
-
-
-MathArray asArray(string const & str)
-{
-       MathArray ar;
-       for (string::const_iterator it = str.begin(); it != str.end(); ++it)
-               ar.push_back(MathAtom(new MathCharInset(*it)));
-       return ar;
-}
-
-
-Dialogs * getDialogs()
+string MathInset::name() const
 {
-       return mathcursor->formula()->view()->owner()->getDialogs();
+       return "unknown";
 }
 
 
-LyXFunc * getLyXFunc()
+ostream & operator<<(ostream & os, MathAtom const & at)
 {
-       return mathcursor->formula()->view()->owner()->getLyXFunc();
+       WriteStream wi(os, false, false);
+       at->write(wi);
+       return os;
 }