#include <config.h>
#include "CommandInset.h"
-#include "MathArray.h"
+#include "MathData.h"
#include "MathStream.h"
#include "DispatchResult.h"
#include "FuncRequest.h"
#include <config.h>
#include "InsetMath.h"
-#include "MathArray.h"
+#include "MathData.h"
#include "MathStream.h"
#include "gettext.h"
#include "debug.h"
-MathArray & InsetMath::cell(idx_type)
+MathData & InsetMath::cell(idx_type)
{
- static MathArray dummyCell;
+ static MathData dummyCell;
lyxerr << BOOST_CURRENT_FUNCTION << ": I don't have any cell" << endl;
return dummyCell;
}
-MathArray const & InsetMath::cell(idx_type) const
+MathData const & InsetMath::cell(idx_type) const
{
- static MathArray dummyCell;
+ static MathData dummyCell;
lyxerr << BOOST_CURRENT_FUNCTION << ": I don't have any cell" << endl;
return dummyCell;
}
#ifndef MATH_INSET_H
#define MATH_INSET_H
-#include "MathArray.h"
+#include "MathData.h"
#include "insets/InsetBase.h"
virtual void drawT(TextPainter &, int x, int y) const;
/// return cell given its number
- virtual MathArray & cell(idx_type);
+ virtual MathData & cell(idx_type);
/// return cell given its number
- virtual MathArray const & cell(idx_type) const;
+ virtual MathData const & cell(idx_type) const;
/// identifies certain types of insets
virtual InsetMathAMSArray * asAMSArrayInset() { return 0; }
/// replace things by other things
virtual void replace(ReplaceData &) {}
/// do we contain a given subsequence?
- virtual bool contains(MathArray const &) const { return false; }
+ virtual bool contains(MathData const &) const { return false; }
/// access to the lock (only nest array have one)
virtual bool lock() const { return false; }
/// access to the lock (only nest array have one)
#include "LaTeXFeatures.h"
#include "InsetMathAMSArray.h"
-#include "MathArray.h"
+#include "MathData.h"
#include "MathStream.h"
#include "MathStream.h"
#include "MathSupport.h"
#include "LaTeXFeatures.h"
#include "InsetMathArray.h"
-#include "MathArray.h"
+#include "MathData.h"
#include "MathParser.h"
#include "MathStream.h"
#include <config.h>
#include "InsetMathBinom.h"
-#include "MathArray.h"
+#include "MathData.h"
#include "MathSupport.h"
#include "MathStream.h"
#include "InsetMathBoldSymbol.h"
#include "MathStream.h"
-#include "MathArray.h"
+#include "MathData.h"
#include "LaTeXFeatures.h"
#include "support/std_ostream.h"
#include <config.h>
#include "InsetMathBox.h"
-#include "MathArray.h"
+#include "MathData.h"
#include "MathStream.h"
#include "MathStream.h"
#include "support/std_ostream.h"
#include <config.h>
#include "InsetMathBoxed.h"
-#include "MathArray.h"
+#include "MathData.h"
#include "MathStream.h"
#include "LaTeXFeatures.h"
#include "LColor.h"
#include <config.h>
#include "InsetMathBrace.h"
-#include "MathArray.h"
+#include "MathData.h"
#include "MathStream.h"
#include "MathSupport.h"
#include "LColor.h"
{}
-InsetMathBrace::InsetMathBrace(MathArray const & ar)
+InsetMathBrace::InsetMathBrace(MathData const & ar)
: InsetMathNest(1)
{
cell(0) = ar;
///
InsetMathBrace();
///
- InsetMathBrace(MathArray const & ar);
+ InsetMathBrace(MathData const & ar);
///
InsetMathBrace const * asBraceInset() const { return this; }
/// we write extra braces in any case...
#include <config.h>
#include "InsetMathCases.h"
-#include "MathArray.h"
+#include "MathData.h"
#include "MathStream.h"
#include "MathSupport.h"
#include "FuncStatus.h"
#include <config.h>
#include "InsetMathColor.h"
-#include "MathArray.h"
+#include "MathData.h"
#include "MathStream.h"
#include "MathSupport.h"
#include "LaTeXFeatures.h"
#include <config.h>
#include "InsetMathComment.h"
-#include "MathArray.h"
+#include "MathData.h"
#include "MathStream.h"
#include "MathSupport.h"
#include "support/std_ostream.h"
#include <config.h>
#include "InsetMathDFrac.h"
-#include "MathArray.h"
+#include "MathData.h"
#include "MathStream.h"
#include "LaTeXFeatures.h"
#include "LColor.h"
#include <config.h>
#include "InsetMathDecoration.h"
-#include "MathArray.h"
+#include "MathData.h"
#include "MathParser.h"
#include "MathSupport.h"
#include "MathStream.h"
#include <config.h>
#include "InsetMathDelim.h"
-#include "MathArray.h"
+#include "MathData.h"
#include "MathStream.h"
#include "MathStream.h"
#include "MathSupport.h"
InsetMathDelim::InsetMathDelim
- (docstring const & l, docstring const & r, MathArray const & ar)
+ (docstring const & l, docstring const & r, MathData const & ar)
: InsetMathNest(1), left_(l), right_(r)
{
cell(0) = ar;
///
InsetMathDelim(docstring const & left, docstring const & right);
///
- InsetMathDelim(docstring const & left, docstring const & right, MathArray const &);
+ InsetMathDelim(docstring const & left, docstring const & right, MathData const &);
///
InsetMathDelim * asDelimInset() { return this; }
///
#include <config.h>
#include "InsetMathDiff.h"
-#include "MathArray.h"
+#include "MathData.h"
#include "MathStream.h"
#include "debug.h"
}
-void InsetMathDiff::addDer(MathArray const & der)
+void InsetMathDiff::addDer(MathData const & der)
{
cells_.push_back(der);
}
///
InsetMathDiff();
///
- void addDer(MathArray const & der);
+ void addDer(MathData const & der);
///
bool metrics(MetricsInfo & mi, Dimension & dim) const;
///
#include <config.h>
#include "InsetMathEnv.h"
-#include "MathArray.h"
+#include "MathData.h"
#include "MathStream.h"
#include "MathStream.h"
#include "support/std_ostream.h"
#include <config.h>
#include "InsetMathExFunc.h"
-#include "MathArray.h"
+#include "MathData.h"
#include "MathStream.h"
#include "MathStream.h"
#include "MathSupport.h"
{}
-InsetMathExFunc::InsetMathExFunc(docstring const & name, MathArray const & ar)
+InsetMathExFunc::InsetMathExFunc(docstring const & name, MathData const & ar)
: InsetMathNest(1), name_(name)
{
cell(0) = ar;
///
explicit InsetMathExFunc(docstring const & name);
///
- InsetMathExFunc(docstring const & name, MathArray const & ar);
+ InsetMathExFunc(docstring const & name, MathData const & ar);
///
bool metrics(MetricsInfo & mi, Dimension & dim) const;
///
#include <config.h>
#include "InsetMathExInt.h"
-#include "MathArray.h"
+#include "MathData.h"
#include "MathStream.h"
#include "MathStream.h"
#include "InsetMathSymbol.h"
#include <config.h>
#include "InsetMathFBox.h"
-#include "MathArray.h"
+#include "MathData.h"
#include "MathStream.h"
#include "LColor.h"
#include <config.h>
#include "InsetMathFont.h"
-#include "MathArray.h"
+#include "MathData.h"
#include "MathStream.h"
#include "MathParser.h"
#include "LaTeXFeatures.h"
#include <config.h>
#include "InsetMathFontOld.h"
-#include "MathArray.h"
+#include "MathData.h"
#include "MathStream.h"
#include "MathParser.h"
#include "MathStream.h"
#include <config.h>
#include "InsetMathFrac.h"
-#include "MathArray.h"
+#include "MathData.h"
#include "MathStream.h"
#include "TextPainter.h"
#include "LaTeXFeatures.h"
#include <config.h>
#include "InsetMathFracBase.h"
-#include "MathArray.h"
+#include "MathData.h"
#include "Cursor.h"
#include <config.h>
#include "InsetMathFrameBox.h"
-#include "MathArray.h"
+#include "MathData.h"
#include "MathStream.h"
#include "MathSupport.h"
#include "LColor.h"
#include <config.h>
#include "InsetMathGrid.h"
-#include "MathArray.h"
+#include "MathData.h"
#include "MathParser.h"
#include "MathStream.h"
int asc = 0;
int desc = 0;
for (col_type col = 0; col < ncols(); ++col) {
- MathArray const & c = cell(index(row, col));
+ MathData const & c = cell(index(row, col));
asc = max(asc, c.ascent());
desc = max(desc, c.descent());
}
int asc = 0;
int desc = 0;
for (col_type col = 0; col < ncols(); ++col) {
- MathArray const & c = cell(index(row, col));
+ MathData const & c = cell(index(row, col));
asc = max(asc, c.ascent());
desc = max(desc, c.descent());
}
// make sure an upcoming '[' does not break anything
if (row + 1 < nrows()) {
- MathArray const & c = cell(index(row + 1, 0));
+ MathData const & c = cell(index(row + 1, 0));
if (c.size() && c.front()->getChar() == '[')
//eol += "[0pt]";
eol += "{}";
{
rowinfo_.insert(rowinfo_.begin() + row + 1, RowInfo());
cells_.insert
- (cells_.begin() + (row + 1) * ncols(), ncols(), MathArray());
+ (cells_.begin() + (row + 1) * ncols(), ncols(), MathData());
cellinfo_.insert
(cellinfo_.begin() + (row + 1) * ncols(), ncols(), CellInfo());
}
void InsetMathGrid::appendRow()
{
rowinfo_.push_back(RowInfo());
- //cells_.insert(cells_.end(), ncols(), MathArray());
+ //cells_.insert(cells_.end(), ncols(), MathData());
for (col_type col = 0; col < ncols(); ++col) {
cells_.push_back(cells_type::value_type());
cellinfo_.push_back(CellInfo());
{
if (cur.idx() == cur.lastidx())
return;
- MathArray ar = cur.cell();
+ MathData ar = cur.cell();
ar.erase(0, cur.pos());
cur.cell().erase(cur.pos(), cur.lastpos());
++cur.idx();
#include "InsetMathArray.h"
#include "InsetMathChar.h"
#include "InsetMathColor.h"
-#include "MathArray.h"
+#include "MathData.h"
#include "InsetMathDelim.h"
#include "MathExtern.h"
#include "MathFactory.h"
// returns position of first relation operator in the array
// used for "intelligent splitting"
- size_t firstRelOp(MathArray const & ar)
+ size_t firstRelOp(MathData const & ar)
{
- for (MathArray::const_iterator it = ar.begin(); it != ar.end(); ++it)
+ for (MathData::const_iterator it = ar.begin(); it != ar.end(); ++it)
if ((*it)->isRelOp())
return it - ar.begin();
return ar.size();
void InsetMathHull::glueall()
{
- MathArray ar;
+ MathData ar;
for (idx_type i = 0; i < nargs(); ++i)
ar.append(cell(i));
*this = InsetMathHull(hullSimple);
for (row_type row = 0; row < nrows(); ++row) {
idx_type const i = 2 * row;
pos_type pos = firstRelOp(cell(i));
- cell(i + 1) = MathArray(cell(i).begin() + pos, cell(i).end());
+ cell(i + 1) = MathData(cell(i).begin() + pos, cell(i).end());
cell(i).erase(pos, cell(i).size());
}
}
for (row_type row = 0; row < nrows(); ++row) {
idx_type const i = 3 * row + 1;
if (cell(i).size()) {
- cell(i + 1) = MathArray(cell(i).begin() + 1, cell(i).end());
+ cell(i + 1) = MathData(cell(i).begin() + 1, cell(i).end());
cell(i).erase(1, cell(i).size());
}
}
#ifdef WITH_WARNINGS
#warning temporarily disabled
//if (cur.selection()) {
- // MathArray ar;
+ // MathData ar;
// selGet(cur.ar);
// lyxerr << "use selection: " << ar << endl;
// insert(pipeThroughExtern(lang, extra, ar));
//}
#endif
- MathArray eq;
+ MathData eq;
eq.push_back(MathAtom(new InsetMathChar('=')));
// go to first item in line
if (getType() == hullSimple) {
size_type pos = cur.cell().find_last(eq);
- MathArray ar;
+ MathData ar;
if (cur.inMathed() && cur.selection()) {
asArray(grabAndEraseSelection(cur), ar);
} else if (pos == cur.cell().size()) {
ar = cur.cell();
lyxerr << "use whole cell: " << ar << endl;
} else {
- ar = MathArray(cur.cell().begin() + pos + 1, cur.cell().end());
+ ar = MathData(cur.cell().begin() + pos + 1, cur.cell().end());
lyxerr << "use partial cell form pos: " << pos << endl;
}
cur.cell().append(eq);
if (getType() == hullEquation) {
lyxerr << "use equation inset" << endl;
mutate(hullEqnArray);
- MathArray & ar = cur.cell();
+ MathData & ar = cur.cell();
lyxerr << "use cell: " << ar << endl;
++cur.idx();
cur.cell() = eq;
lyxerr << "use eqnarray" << endl;
cur.idx() += 2 - cur.idx() % ncols();
cur.pos() = 0;
- MathArray ar = cur.cell();
+ MathData ar = cur.cell();
lyxerr << "use cell: " << ar << endl;
#ifdef WITH_WARNINGS
#warning temporarily disabled
#endif
static InsetMathHull * lastformula = 0;
static CursorBase current = DocIterator(ibegin(nucleus()));
- static MathArray ar;
+ static MathData ar;
static string laststr;
if (lastformula != this || laststr != str) {
for (DocIterator it = current; it != iend(nucleus()); increment(it)) {
CursorSlice & top = it.back();
- MathArray const & a = top.asInsetMath()->cell(top.idx_);
+ MathData const & a = top.asInsetMath()->cell(top.idx_);
if (a.matchpart(ar, top.pos_)) {
bv->cursor().setSelection(it, ar.size());
current = it;
#include <config.h>
#include "InsetMathLefteqn.h"
-#include "MathArray.h"
+#include "MathData.h"
#include "support/std_ostream.h"
#include <config.h>
#include "InsetMathLim.h"
-#include "MathArray.h"
+#include "MathData.h"
#include "MathStream.h"
#include "debug.h"
InsetMathLim::InsetMathLim
- (MathArray const & f, MathArray const & x, MathArray const & x0)
+ (MathData const & f, MathData const & x, MathData const & x0)
: InsetMathNest(3)
{
cell(0) = f;
class InsetMathLim : public InsetMathNest {
public:
///
- InsetMathLim(MathArray const & f, MathArray const & x, MathArray const & x0);
+ InsetMathLim(MathData const & f, MathData const & x, MathData const & x0);
///
bool metrics(MetricsInfo & mi, Dimension & dim) const;
///
#include <config.h>
#include "InsetMathMBox.h"
-#include "MathArray.h"
+#include "MathData.h"
#include "MathStream.h"
#include "BufferView.h"
#include <config.h>
#include "InsetMathMakebox.h"
-#include "MathArray.h"
+#include "MathData.h"
#include "MathStream.h"
#include "MathSupport.h"
#include <config.h>
#include "InsetMathMatrix.h"
-#include "MathArray.h"
+#include "MathData.h"
#include "MathStream.h"
#include "InsetMathBrace.h"
#include "InsetMathColor.h"
#include "InsetMathComment.h"
-#include "MathArray.h"
+#include "MathData.h"
#include "InsetMathDelim.h"
#include "MathFactory.h"
#include "InsetMathHull.h"
{
// FIXME: This is a hack. Ideally, the coord cache should not store
// absolute positions, but relative ones. This would mean to call
-// setXY() not in MathArray::draw(), but in the parent insets' draw()
+// setXY() not in MathData::draw(), but in the parent insets' draw()
// with the correctly adjusted x,y values. But this means that we'd have
// to touch all (math)inset's draw() methods. Right now, we'll store
// absolute value, and make them here relative, only to make them
// absolute again when actually drawing the cursor. What a mess.
BOOST_ASSERT(ptr_cmp(&sl.inset(), this));
- MathArray const & ar = sl.cell();
+ MathData const & ar = sl.cell();
CoordCache const & coord_cache = bv.coordCache();
if (!coord_cache.getArrays().has(&ar)) {
// this can (semi-)legally happen if we just created this cell
return;
}
Point const pt2 = coord_cache.getInsets().xy(this);
- //lyxerr << "retrieving position cache for MathArray "
+ //lyxerr << "retrieving position cache for MathData "
// << pt.x_ << ' ' << pt.y_ << std::endl;
x = pt.x_ - pt2.x_ + ar.pos2x(sl.pos());
y = pt.y_ - pt2.y_;
//lyxerr << "InsetMathNest::drawing selection: "
// << " s1: " << s1 << " s2: " << s2 << endl;
if (s1.idx() == s2.idx()) {
- MathArray const & c = cell(s1.idx());
+ MathData const & c = cell(s1.idx());
int x1 = c.xo(bv) + c.pos2x(s1.pos());
int y1 = c.yo(bv) - c.ascent();
int x2 = c.xo(bv) + c.pos2x(s2.pos());
} else {
for (idx_type i = 0; i < nargs(); ++i) {
if (idxBetween(i, s1.idx(), s2.idx())) {
- MathArray const & c = cell(i);
+ MathData const & c = cell(i);
int x1 = c.xo(bv);
int y1 = c.yo(bv) - c.ascent();
int x2 = c.xo(bv) + c.width();
}
-bool InsetMathNest::contains(MathArray const & ar) const
+bool InsetMathNest::contains(MathData const & ar) const
{
for (idx_type i = 0; i < nargs(); ++i)
if (cell(i).contains(ar))
}
-MathArray InsetMathNest::glue() const
+MathData InsetMathNest::glue() const
{
- MathArray ar;
+ MathData ar;
for (size_t i = 0; i < nargs(); ++i)
ar.append(cell(i));
return ar;
#warning look here
#endif
#if 0
- MathArray & ar = cur.cell();
+ MathData & ar = cur.cell();
// remove base-only "scripts"
for (pos_type i = 0; i + 1 < ar.size(); ++i) {
InsetMathScript * p = operator[](i).nucleus()->asScriptInset();
if (p && p->nargs() == 1) {
- MathArray ar = p->nuc();
+ MathData ar = p->nuc();
erase(i);
insert(i, ar);
cur.adjust(i, ar.size() - 1);
}
case LFUN_INSET_INSERT: {
- MathArray ar;
+ MathData ar;
if (createInsetMath_fromDialogStr(cmd.argument(), ar)) {
recordUndo(cur);
cur.insert(ar);
idx_min = i;
}
}
- MathArray & ar = cell(idx_min);
+ MathData & ar = cell(idx_min);
cur.push(*this);
cur.idx() = idx_min;
cur.pos() = ar.x2pos(x - ar.xo(cur.bv()));
// cur.result().update(): don't overwrite previously set flags.
cur.updateFlags(Update::Decoration | Update::FitCursor | cur.result().update());
} else if (cmd.button() == mouse_button::button2) {
- MathArray ar;
+ MathData ar;
if (cap::selection()) {
// See comment in LyXText::dispatch why we do this
cap::copySelectionToStack();
/// direct access to the cell.
/// inlined because shows in profile.
//@{
- MathArray & cell(idx_type i) { return cells_[i]; }
- MathArray const & cell(idx_type i) const { return cells_[i]; }
+ MathData & cell(idx_type i) { return cells_[i]; }
+ MathData const & cell(idx_type i) const { return cells_[i]; }
//@}
/// can we move into this cell (see macroarg.h)
/// replace in all cells
void replace(ReplaceData &);
/// do we contain a given pattern?
- bool contains(MathArray const &) const;
+ bool contains(MathData const &) const;
/// glue everything to a single cell
- MathArray glue() const;
+ MathData glue() const;
/// debug helper
void dump() const;
protected:
/// we store the cells in a vector
- typedef std::vector<MathArray> cells_type;
+ typedef std::vector<MathData> cells_type;
/// thusly:
cells_type cells_;
/// if the inset is locked, it can't be entered with the cursor
#include <config.h>
#include "InsetMathOverset.h"
-#include "MathArray.h"
+#include "MathData.h"
#include "MathStream.h"
#include "Cursor.h"
#include <config.h>
#include "InsetMathPar.h"
-#include "MathArray.h"
+#include "MathData.h"
#include "MathStream.h"
#include "support/std_ostream.h"
using std::auto_ptr;
-InsetMathPar::InsetMathPar(MathArray const & ar)
+InsetMathPar::InsetMathPar(MathData const & ar)
{
cells_[0] = ar;
}
///
InsetMathPar() {}
///
- InsetMathPar(MathArray const & ar);
+ InsetMathPar(MathData const & ar);
///
mode_type currentMode() const { return TEXT_MODE; }
///
#include "FuncRequest.h"
#include "FuncStatus.h"
#include "gettext.h"
-#include "MathArray.h"
+#include "MathData.h"
#include "MathFactory.h"
#include "MathSupport.h"
#include "OutputParams.h"
switch (cmd.action) {
case LFUN_INSET_MODIFY:
if (cmd.getArg(0) == "ref") {
- MathArray ar;
+ MathData ar;
if (createInsetMath_fromDialogStr(cmd.argument(), ar)) {
*this = *ar[0].nucleus()->asRefInset();
break;
#include <config.h>
#include "InsetMathRoot.h"
-#include "MathArray.h"
+#include "MathData.h"
#include "MathStream.h"
#include "Cursor.h"
#include "LColor.h"
#include <config.h>
#include "InsetMathScript.h"
-#include "MathArray.h"
+#include "MathData.h"
#include "MathStream.h"
#include "MathSupport.h"
#include "InsetMathSymbol.h"
}
-MathArray const & InsetMathScript::down() const
+MathData const & InsetMathScript::down() const
{
if (nargs() == 3)
return cell(2);
}
-MathArray & InsetMathScript::down()
+MathData & InsetMathScript::down()
{
if (nargs() == 3)
return cell(2);
}
-MathArray const & InsetMathScript::up() const
+MathData const & InsetMathScript::up() const
{
BOOST_ASSERT(nargs() > 1);
return cell(1);
}
-MathArray & InsetMathScript::up()
+MathData & InsetMathScript::up()
{
BOOST_ASSERT(nargs() > 1);
return cell(1);
{
if (nargs() == 1) {
// just nucleus so far
- cells_.push_back(MathArray());
+ cells_.push_back(MathData());
cell_1_is_up_ = up;
} else if (nargs() == 2 && !has(up)) {
if (up) {
cells_.push_back(cell(1));
cell(1).clear();
} else {
- cells_.push_back(MathArray());
+ cells_.push_back(MathData());
}
}
}
-MathArray const & InsetMathScript::nuc() const
+MathData const & InsetMathScript::nuc() const
{
return cell(0);
}
-MathArray & InsetMathScript::nuc()
+MathData & InsetMathScript::nuc()
{
return cell(0);
}
return true;
if (at->asFontInset()) {
- MathArray const & ar = at->asFontInset()->cell(0);
+ MathData const & ar = at->asFontInset()->cell(0);
for (size_t i = 0; i < ar.size(); ++i) {
if (!(ar[i]->asCharInset() ||
(ar[i]->asSymbolInset() &&
// invoke notifyCursorLeaves again and does not touch
// cur (since the top slice will be deleted
// afterwards))
- MathArray ar = cell(0);
+ MathData ar = cell(0);
Cursor tmpcur = cur;
tmpcur.pop();
tmpcur.cell().erase(tmpcur.pos());
/// get limits
int limits() const { return limits_; }
/// returns subscript. Always run 'hasDown' or 'has(false)' before!
- MathArray const & down() const;
+ MathData const & down() const;
/// returns subscript. Always run 'hasDown' or 'has(false)' before!
- MathArray & down();
+ MathData & down();
/// returns superscript. Always run 'hasUp' or 'has(true)' before!
- MathArray const & up() const;
+ MathData const & up() const;
/// returns superscript. Always run 'hasUp' or 'has(true)' before!
- MathArray & up();
+ MathData & up();
/// returns nucleus
- MathArray const & nuc() const;
+ MathData const & nuc() const;
/// returns nucleus
- MathArray & nuc();
+ MathData & nuc();
/// do we have a superscript?
bool hasUp() const;
/// do we have a subscript?
#include <config.h>
#include "InsetMathSize.h"
-#include "MathArray.h"
+#include "MathData.h"
#include "MathParser.h"
#include "MathStream.h"
#include <config.h>
#include "InsetMathSpace.h"
-#include "MathArray.h"
+#include "MathData.h"
#include "MathStream.h"
#include "LaTeXFeatures.h"
#include <config.h>
#include "InsetMathSplit.h"
-#include "MathArray.h"
+#include "MathData.h"
#include "MathStream.h"
#include "MathStream.h"
#include <config.h>
#include "InsetMathSqrt.h"
-#include "MathArray.h"
+#include "MathData.h"
#include "MathStream.h"
#include "TextPainter.h"
#include "LColor.h"
#include <config.h>
#include "InsetMathStackrel.h"
-#include "MathArray.h"
+#include "MathData.h"
#include "MathStream.h"
#include "LaTeXFeatures.h"
#include "InsetMathSubstack.h"
-#include "MathArray.h"
+#include "MathData.h"
#include "MathStream.h"
#include "support/std_ostream.h"
#include "InsetMathTFrac.h"
-#include "MathArray.h"
+#include "MathData.h"
#include "MathStream.h"
#include "LaTeXFeatures.h"
#include <config.h>
#include "InsetMathTabular.h"
-#include "MathArray.h"
+#include "MathData.h"
#include "MathStream.h"
#include "MathStream.h"
#include <config.h>
#include "InsetMathUnderset.h"
-#include "MathArray.h"
+#include "MathData.h"
#include "MathStream.h"
#include "Cursor.h"
#include <config.h>
#include "InsetMathXArrow.h"
-#include "MathArray.h"
+#include "MathData.h"
#include "MathStream.h"
#include "MathStream.h"
#include "MathSupport.h"
}
-MathArray const & InsetMathXYArrow::targetCell() const
+MathData const & InsetMathXYArrow::targetCell() const
{
#if 0
InsetMathXYMatrix const * p = targetMatrix();
int x = 0;
int y = 0;
- MathArray const & t = cell(0);
- for (MathArray::const_iterator it = t.begin(); it != t.end(); ++it) {
+ MathData const & t = cell(0);
+ for (MathData::const_iterator it = t.begin(); it != t.end(); ++it) {
switch ((*it)->getChar()) {
case 'l': --x; break;
case 'r': ++x; break;
}
return p->cell(n);
#else
- static MathArray dummy;
+ static MathData dummy;
return dummy;
#endif
}
-MathArray const & InsetMathXYArrow::sourceCell() const
+MathData const & InsetMathXYArrow::sourceCell() const
{
#if 0
return targetMatrix()->cell(mi_.idx);
#else
- static MathArray dummy;
+ static MathData dummy;
return dummy;
#endif
}
} else {
pi.pain.text(x, y, "X");
- MathArray const & s = sourceCell();
- MathArray const & t = targetCell();
+ MathData const & s = sourceCell();
+ MathData const & t = targetCell();
pi.pain.line(s.xm(), s.ym(), t.xm(), t.ym(), LColor::math);
cell(1).draw(pi, (s.xm() + t.xm())/2, (s.ym() + t.ym())/2);
///
InsetMathXYMatrix const * targetMatrix() const;
///
- MathArray const & targetCell() const;
+ MathData const & targetCell() const;
///
- MathArray const & sourceCell() const;
+ MathData const & sourceCell() const;
///
bool up_;
MathAtom.h \
MathAutoCorrect.cpp \
MathAutoCorrect.h \
- MathArray.cpp \
- MathArray.h \
+ MathData.cpp \
+ MathData.h \
MathExtern.cpp \
MathExtern.h \
MathFactory.cpp \
+++ /dev/null
-/**
- * \file MathArray.cpp
- * 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 <config.h>
-
-#include "MathArray.h"
-#include "InsetMathFont.h"
-#include "InsetMathScript.h"
-#include "MathMacro.h"
-#include "MathMacroTable.h"
-#include "MathStream.h"
-#include "MathSupport.h"
-#include "ReplaceData.h"
-
-#include "BufferView.h"
-#include "Buffer.h"
-#include "Cursor.h"
-#include "debug.h"
-#include "LColor.h"
-
-#include "frontends/FontMetrics.h"
-#include "frontends/Painter.h"
-
-#include <boost/assert.hpp>
-
-
-namespace lyx {
-
-using std::abs;
-using std::endl;
-using std::min;
-using std::ostringstream;
-using std::string;
-using std::vector;
-
-
-MathArray::MathArray(const_iterator from, const_iterator to)
- : base_type(from, to)
-{}
-
-
-MathAtom & MathArray::operator[](pos_type pos)
-{
- BOOST_ASSERT(pos < size());
- return base_type::operator[](pos);
-}
-
-
-MathAtom const & MathArray::operator[](pos_type pos) const
-{
- BOOST_ASSERT(pos < size());
- return base_type::operator[](pos);
-}
-
-
-void MathArray::insert(size_type pos, MathAtom const & t)
-{
- base_type::insert(begin() + pos, t);
-}
-
-
-void MathArray::insert(size_type pos, MathArray const & ar)
-{
- BOOST_ASSERT(pos <= size());
- base_type::insert(begin() + pos, ar.begin(), ar.end());
-}
-
-
-void MathArray::append(MathArray const & ar)
-{
- insert(size(), ar);
-}
-
-
-void MathArray::erase(size_type pos)
-{
- if (pos < size())
- erase(pos, pos + 1);
-}
-
-
-void MathArray::erase(iterator pos1, iterator pos2)
-{
- base_type::erase(pos1, pos2);
-}
-
-
-void MathArray::erase(iterator pos)
-{
- base_type::erase(pos);
-}
-
-
-void MathArray::erase(size_type pos1, size_type pos2)
-{
- base_type::erase(begin() + pos1, begin() + pos2);
-}
-
-
-void MathArray::dump2() const
-{
- odocstringstream os;
- NormalStream ns(os);
- for (const_iterator it = begin(); it != end(); ++it)
- ns << *it << ' ';
- lyxerr << to_utf8(os.str());
-}
-
-
-void MathArray::dump() const
-{
- odocstringstream os;
- NormalStream ns(os);
- for (const_iterator it = begin(); it != end(); ++it)
- ns << '<' << *it << '>';
- lyxerr << to_utf8(os.str());
-}
-
-
-void MathArray::validate(LaTeXFeatures & features) const
-{
- for (const_iterator it = begin(); it != end(); ++it)
- (*it)->validate(features);
-}
-
-
-bool MathArray::match(MathArray const & ar) const
-{
- return size() == ar.size() && matchpart(ar, 0);
-}
-
-
-bool MathArray::matchpart(MathArray const & ar, pos_type pos) const
-{
- if (size() < ar.size() + pos)
- return false;
- const_iterator it = begin() + pos;
- for (const_iterator jt = ar.begin(); jt != ar.end(); ++jt, ++it)
- if (asString(*it) != asString(*jt))
- return false;
- return true;
-}
-
-
-void MathArray::replace(ReplaceData & rep)
-{
- for (size_type i = 0; i < size(); ++i) {
- if (find1(rep.from, i)) {
- // match found
- lyxerr << "match found!" << endl;
- erase(i, i + rep.from.size());
- insert(i, rep.to);
- }
- }
-
-#ifdef WITH_WARNINGS
-#warning temporarily disabled
- // for (const_iterator it = begin(); it != end(); ++it)
- // it->nucleus()->replace(rep);
-#endif
-}
-
-
-bool MathArray::find1(MathArray const & ar, size_type pos) const
-{
- lyxerr << "finding '" << ar << "' in '" << *this << "'" << endl;
- for (size_type i = 0, n = ar.size(); i < n; ++i)
- if (asString(operator[](pos + i)) != asString(ar[i]))
- return false;
- return true;
-}
-
-
-MathArray::size_type MathArray::find(MathArray const & ar) const
-{
- for (int i = 0, last = size() - ar.size(); i < last; ++i)
- if (find1(ar, i))
- return i;
- return size();
-}
-
-
-MathArray::size_type MathArray::find_last(MathArray const & ar) const
-{
- for (int i = size() - ar.size(); i >= 0; --i)
- if (find1(ar, i))
- return i;
- return size();
-}
-
-
-bool MathArray::contains(MathArray const & ar) const
-{
- if (find(ar) != size())
- return true;
- for (const_iterator it = begin(); it != end(); ++it)
- if ((*it)->contains(ar))
- return true;
- return false;
-}
-
-
-void MathArray::touch() const
-{
-}
-
-
-bool MathArray::metrics(MetricsInfo & mi, Dimension & dim) const
-{
- dim = dim_;
- metrics(mi);
- if (dim_ == dim)
- return false;
- dim = dim_;
- return true;
-}
-
-
-namespace {
-
-bool isInside(DocIterator const & it, MathArray const & ar,
- pos_type p1, pos_type p2)
-{
- for (size_t i = 0; i != it.depth(); ++i) {
- CursorSlice const & sl = it[i];
- if (sl.inset().inMathed() && &sl.cell() == &ar)
- return p1 <= sl.pos() && sl.pos() < p2;
- }
- return false;
-}
-
-}
-
-
-
-void MathArray::metrics(MetricsInfo & mi) const
-{
- frontend::FontMetrics const & fm = theFontMetrics(mi.base.font);
- dim_ = fm.dimension('I');
- int xascent = fm.dimension('x').ascent();
- if (xascent >= dim_.asc)
- xascent = (2 * dim_.asc) / 3;
- minasc_ = xascent;
- mindes_ = (3 * xascent) / 4;
- slevel_ = (4 * xascent) / 5;
- sshift_ = xascent / 4;
- kerning_ = 0;
-
- if (empty())
- return;
-
- dim_.asc = 0;
- dim_.wid = 0;
- Dimension d;
- //BufferView & bv = *mi.base.bv;
- //Buffer const & buf = *bv.buffer();
- for (size_t i = 0, n = size(); i != n; ++i) {
- MathAtom const & at = operator[](i);
-#if 0
- MathMacro const * mac = at->asMacro();
- if (mac && buf.hasMacro(mac->name())) {
- MacroData const & tmpl = buf.getMacro(mac->name());
- int numargs = tmpl.numargs();
- if (i + numargs > n)
- numargs = n - i - 1;
- lyxerr << "metrics:found macro: " << mac->name()
- << " numargs: " << numargs << endl;
- if (!isInside(bv.cursor(), *this, i + 1, i + numargs + 1)) {
- MathArray args(begin() + i + 1, begin() + i + numargs + 1);
- MathArray exp;
- tmpl.expand(args, exp);
- mac->setExpansion(exp, args);
- mac->metricsExpanded(mi, d);
- dim_.wid += mac->widthExpanded();
- i += numargs;
- continue;
- }
- }
-#endif
- at->metrics(mi, d);
- dim_ += d;
- if (i == n - 1)
- kerning_ = at->kerning();
- }
-}
-
-
-void MathArray::draw(PainterInfo & pi, int x, int y) const
-{
- //lyxerr << "MathArray::draw: x: " << x << " y: " << y << endl;
- BufferView & bv = *pi.base.bv;
- setXY(bv, x, y);
-
- if (empty()) {
- pi.pain.rectangle(x, y - ascent(), width(), height(), LColor::mathline);
- return;
- }
-
- // don't draw outside the workarea
- if (y + descent() <= 0
- || y - ascent() >= bv.workHeight()
- || x + width() <= 0
- || x >= bv. workWidth())
- return;
-
- for (size_t i = 0, n = size(); i != n; ++i) {
- MathAtom const & at = operator[](i);
-#if 0
- Buffer const & buf = bv.buffer();
- // special macro handling
- MathMacro const * mac = at->asMacro();
- if (mac && buf.hasMacro(mac->name())) {
- MacroData const & tmpl = buf.getMacro(mac->name());
- int numargs = tmpl.numargs();
- if (i + numargs > n)
- numargs = n - i - 1;
- if (!isInside(bv.cursor(), *this, i + 1, i + numargs + 1)) {
- mac->drawExpanded(pi, x, y);
- x += mac->widthExpanded();
- i += numargs;
- continue;
- }
- }
-#endif
- bv.coordCache().insets().add(at.nucleus(), x, y);
- at->drawSelection(pi, x, y);
- at->draw(pi, x, y);
- x += at->width();
- }
-}
-
-
-void MathArray::metricsT(TextMetricsInfo const & mi, Dimension & dim) const
-{
- dim.clear();
- Dimension d;
- for (const_iterator it = begin(); it != end(); ++it) {
- (*it)->metricsT(mi, d);
- dim += d;
- }
-}
-
-
-void MathArray::drawT(TextPainter & pain, int x, int y) const
-{
- //lyxerr << "x: " << x << " y: " << y << ' ' << pain.workAreaHeight() << endl;
-
- // FIXME: Abdel 16/10/2006
- // This drawT() method is never used, this is dead code.
-
- for (const_iterator it = begin(), et = end(); it != et; ++it) {
- (*it)->drawT(pain, x, y);
- //x += (*it)->width_;
- x += 2;
- }
-}
-
-
-int MathArray::pos2x(size_type pos) const
-{
- return pos2x(pos, 0);
-}
-
-
-int MathArray::pos2x(size_type pos, int glue) const
-{
- int x = 0;
- size_type target = min(pos, size());
- for (size_type i = 0; i < target; ++i) {
- const_iterator it = begin() + i;
- if ((*it)->getChar() == ' ')
- x += glue;
- //lyxerr << "char: " << (*it)->getChar()
- // << "width: " << (*it)->width() << std::endl;
- x += (*it)->width();
- }
- return x;
-}
-
-
-MathArray::size_type MathArray::x2pos(int targetx) const
-{
- return x2pos(targetx, 0);
-}
-
-
-MathArray::size_type MathArray::x2pos(int targetx, int glue) const
-{
- const_iterator it = begin();
- int lastx = 0;
- int currx = 0;
- // find first position after targetx
- for (; currx < targetx && it < end(); ++it) {
- lastx = currx;
- if ((*it)->getChar() == ' ')
- currx += glue;
- currx += (*it)->width();
- }
-
- /**
- * If we are not at the beginning of the array, go to the left
- * of the inset if one of the following two condition holds:
- * - the current inset is editable (so that the cursor tip is
- * deeper than us): in this case, we want all intermediate
- * cursor slices to be before insets;
- * - the mouse is closer to the left side of the inset than to
- * the right one.
- * See bug 1918 for details.
- **/
- if (it != begin() && currx >= targetx
- && ((*boost::prior(it))->asNestInset()
- || abs(lastx - targetx) < abs(currx - targetx))) {
- --it;
- }
-
- return it - begin();
-}
-
-
-int MathArray::dist(BufferView const & bv, int x, int y) const
-{
- int xx = 0;
- int yy = 0;
-
- const int xo_ = xo(bv);
- const int yo_ = yo(bv);
-
- if (x < xo_)
- xx = xo_ - x;
- else if (x > xo_ + width())
- xx = x - xo_ - width();
-
- if (y < yo_ - ascent())
- yy = yo_ - ascent() - y;
- else if (y > yo_ + descent())
- yy = y - yo_ - descent();
-
- return xx + yy;
-}
-
-
-void MathArray::setXY(BufferView & bv, int x, int y) const
-{
- //lyxerr << "setting position cache for MathArray " << this << std::endl;
- bv.coordCache().arrays().add(this, x, y);
-}
-
-
-int MathArray::xo(BufferView const & bv) const
-{
- return bv.coordCache().getArrays().x(this);
-}
-
-
-int MathArray::yo(BufferView const & bv) const
-{
- return bv.coordCache().getArrays().y(this);
-}
-
-
-std::ostream & operator<<(std::ostream & os, MathArray const & ar)
-{
- odocstringstream oss;
- NormalStream ns(oss);
- ns << ar;
- return os << to_utf8(oss.str());
-}
-
-
-odocstream & operator<<(odocstream & os, MathArray const & ar)
-{
- NormalStream ns(os);
- ns << ar;
- return os;
-}
-
-
-} // namespace lyx
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file MathArray.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Alejandro Aguilar Sierra
- * \author André Pönitz
- * \author Lars Gullik Bjønnes
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef MATH_DATA_H
-#define MATH_DATA_H
-
-#include <vector>
-
-#include "MathAtom.h"
-#include "Dimension.h"
-
-#include "support/docstream.h"
-
-
-namespace lyx {
-
-class BufferView;
-class LaTeXFeatures;
-class ReplaceData;
-class MetricsInfo;
-class PainterInfo;
-class TextMetricsInfo;
-class TextPainter;
-
-
-class MathArray : private std::vector<MathAtom> {
-public:
- /// re-use inhertited stuff
- typedef std::vector<MathAtom> base_type;
- using base_type::const_iterator;
- using base_type::iterator;
- using base_type::size_type;
- using base_type::difference_type;
- using base_type::size;
- using base_type::empty;
- using base_type::clear;
- using base_type::begin;
- using base_type::end;
- using base_type::push_back;
- using base_type::pop_back;
- using base_type::back;
- using base_type::front;
- ///
- typedef size_type idx_type;
- typedef size_type pos_type;
-
-public:
- ///
- MathArray() {}
- ///
- MathArray(const_iterator from, const_iterator to);
- ///
- void append(MathArray const & ar);
-
- /// inserts single atom at position pos
- void insert(size_type pos, MathAtom const & at);
- /// inserts multiple atoms at position pos
- void insert(size_type pos, MathArray const & ar);
-
- /// erase range from pos1 to pos2
- void erase(iterator pos1, iterator pos2);
- /// erase single atom
- void erase(iterator pos);
- /// erase range from pos1 to pos2
- void erase(size_type pos1, size_type pos2);
- /// erase single atom
- void erase(size_type pos);
-
- ///
- void dump() const;
- ///
- void dump2() const;
- ///
- void replace(ReplaceData &);
- ///
- void substitute(MathArray const & m);
-
- /// looks for exact match
- bool match(MathArray const & ar) const;
- /// looks for inclusion match starting at pos
- bool matchpart(MathArray const & ar, pos_type pos) const;
- /// looks for containment, return == size mean not found
- size_type find(MathArray const & ar) const;
- /// looks for containment, return == size mean not found
- size_type find_last(MathArray const & ar) const;
- ///
- bool contains(MathArray const & ar) const;
- ///
- void validate(LaTeXFeatures &) const;
-
- /// checked write access
- MathAtom & operator[](pos_type);
- /// checked read access
- MathAtom const & operator[](pos_type) const;
- /// rebuild cached metrics information
- void metrics(MetricsInfo & mi) const;
- /// rebuild cached metrics information
- bool metrics(MetricsInfo & mi, Dimension & dim) const;
- /// redraw cell using cache metrics information
- void draw(PainterInfo & pi, int x, int y) const;
- /// rebuild cached metrics information
- void metricsT(TextMetricsInfo const & mi, Dimension & dim) const;
- /// redraw cell using cache metrics information
- void drawT(TextPainter & pi, int x, int y) const;
- /// mark cell for re-drawing
- void touch() const;
-
- /// access to cached x coordinate of last drawing
- int xo(BufferView const & bv) const;
- /// access to cached y coordinate of last drawing
- int yo(BufferView const & bv) const;
- /// access to cached x coordinate of mid point of last drawing
- int xm(BufferView const & bv) const { return xo(bv) + dim_.wid / 2; }
- /// access to cached y coordinate of mid point of last drawing
- int ym(BufferView const & bv) const { return yo(bv) + (dim_.des - dim_.asc) / 2; }
- /// write access to coordinate;
- void setXY(BufferView & bv, int x, int y) const;
- /// returns x coordinate of given position in the array
- int pos2x(size_type pos) const;
- /// returns position of given x coordinate
- int pos2x(size_type pos, int glue) const;
- /// returns position of given x coordinate
- size_type x2pos(int pos) const;
- /// returns position of given x coordinate fstarting from a certain pos
- size_type x2pos(int targetx, int glue) const;
- /// returns distance of this cell to the point given by x and y
- // assumes valid position and size cache
- int dist(BufferView const & bv, int x, int y) const;
-
- /// ascent of this cell above the baseline
- int ascent() const { return dim_.asc; }
- /// descent of this cell below the baseline
- int descent() const { return dim_.des; }
- /// height of the cell
- int height() const { return dim_.asc + dim_.des; }
- /// width of this cell
- int width() const { return dim_.wid; }
- /// dimensions of cell
- Dimension const & dim() const { return dim_; }
- /// dimensions of cell
- void setDim(Dimension const & d) const { dim_ = d; }
- /// minimum ascent offset for superscript
- int minasc() const { return minasc_; }
- /// minimum descent offset for subscript
- int mindes() const { return mindes_; }
- /// level above/below which super/subscript should extend
- int slevel() const { return slevel_; }
- /// additional super/subscript shift
- int sshift() const { return sshift_; }
- /// superscript kerning
- int kerning() const { return kerning_; }
- ///
- void swap(MathArray & ar) { base_type::swap(ar); }
-
-protected:
- /// cached dimensions of cell
- mutable Dimension dim_;
- /// cached values for super/subscript placement
- mutable int minasc_;
- mutable int mindes_;
- mutable int slevel_;
- mutable int sshift_;
- mutable int kerning_;
-
-private:
- /// is this an exact match at this position?
- bool find1(MathArray const & ar, size_type pos) const;
-};
-
-///
-std::ostream & operator<<(std::ostream & os, MathArray const & ar);
-///
-odocstream & operator<<(odocstream & os, MathArray const & ar);
-
-
-} // namespace lyx
-
-#endif
#include <config.h>
#include "MathAutoCorrect.h"
-#include "MathArray.h"
+#include "MathData.h"
#include "InsetMath.h"
#include "MathSupport.h"
#include "MathParser.h"
return false;
if (s2.size() != 1)
return false;
- MathArray ar1, ar3;
+ MathData ar1, ar3;
mathed_parse_cell(ar1, s1);
mathed_parse_cell(ar3, s3);
if (ar1.size() != 1 || ar3.size() != 1)
--- /dev/null
+/**
+ * \file MathData.cpp
+ * 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 <config.h>
+
+#include "MathData.h"
+#include "InsetMathFont.h"
+#include "InsetMathScript.h"
+#include "MathMacro.h"
+#include "MathMacroTable.h"
+#include "MathStream.h"
+#include "MathSupport.h"
+#include "ReplaceData.h"
+
+#include "BufferView.h"
+#include "Buffer.h"
+#include "Cursor.h"
+#include "debug.h"
+#include "LColor.h"
+
+#include "frontends/FontMetrics.h"
+#include "frontends/Painter.h"
+
+#include <boost/assert.hpp>
+
+
+namespace lyx {
+
+using std::abs;
+using std::endl;
+using std::min;
+using std::ostringstream;
+using std::string;
+using std::vector;
+
+
+MathData::MathData(const_iterator from, const_iterator to)
+ : base_type(from, to)
+{}
+
+
+MathAtom & MathData::operator[](pos_type pos)
+{
+ BOOST_ASSERT(pos < size());
+ return base_type::operator[](pos);
+}
+
+
+MathAtom const & MathData::operator[](pos_type pos) const
+{
+ BOOST_ASSERT(pos < size());
+ return base_type::operator[](pos);
+}
+
+
+void MathData::insert(size_type pos, MathAtom const & t)
+{
+ base_type::insert(begin() + pos, t);
+}
+
+
+void MathData::insert(size_type pos, MathData const & ar)
+{
+ BOOST_ASSERT(pos <= size());
+ base_type::insert(begin() + pos, ar.begin(), ar.end());
+}
+
+
+void MathData::append(MathData const & ar)
+{
+ insert(size(), ar);
+}
+
+
+void MathData::erase(size_type pos)
+{
+ if (pos < size())
+ erase(pos, pos + 1);
+}
+
+
+void MathData::erase(iterator pos1, iterator pos2)
+{
+ base_type::erase(pos1, pos2);
+}
+
+
+void MathData::erase(iterator pos)
+{
+ base_type::erase(pos);
+}
+
+
+void MathData::erase(size_type pos1, size_type pos2)
+{
+ base_type::erase(begin() + pos1, begin() + pos2);
+}
+
+
+void MathData::dump2() const
+{
+ odocstringstream os;
+ NormalStream ns(os);
+ for (const_iterator it = begin(); it != end(); ++it)
+ ns << *it << ' ';
+ lyxerr << to_utf8(os.str());
+}
+
+
+void MathData::dump() const
+{
+ odocstringstream os;
+ NormalStream ns(os);
+ for (const_iterator it = begin(); it != end(); ++it)
+ ns << '<' << *it << '>';
+ lyxerr << to_utf8(os.str());
+}
+
+
+void MathData::validate(LaTeXFeatures & features) const
+{
+ for (const_iterator it = begin(); it != end(); ++it)
+ (*it)->validate(features);
+}
+
+
+bool MathData::match(MathData const & ar) const
+{
+ return size() == ar.size() && matchpart(ar, 0);
+}
+
+
+bool MathData::matchpart(MathData const & ar, pos_type pos) const
+{
+ if (size() < ar.size() + pos)
+ return false;
+ const_iterator it = begin() + pos;
+ for (const_iterator jt = ar.begin(); jt != ar.end(); ++jt, ++it)
+ if (asString(*it) != asString(*jt))
+ return false;
+ return true;
+}
+
+
+void MathData::replace(ReplaceData & rep)
+{
+ for (size_type i = 0; i < size(); ++i) {
+ if (find1(rep.from, i)) {
+ // match found
+ lyxerr << "match found!" << endl;
+ erase(i, i + rep.from.size());
+ insert(i, rep.to);
+ }
+ }
+
+#ifdef WITH_WARNINGS
+#warning temporarily disabled
+ // for (const_iterator it = begin(); it != end(); ++it)
+ // it->nucleus()->replace(rep);
+#endif
+}
+
+
+bool MathData::find1(MathData const & ar, size_type pos) const
+{
+ lyxerr << "finding '" << ar << "' in '" << *this << "'" << endl;
+ for (size_type i = 0, n = ar.size(); i < n; ++i)
+ if (asString(operator[](pos + i)) != asString(ar[i]))
+ return false;
+ return true;
+}
+
+
+MathData::size_type MathData::find(MathData const & ar) const
+{
+ for (int i = 0, last = size() - ar.size(); i < last; ++i)
+ if (find1(ar, i))
+ return i;
+ return size();
+}
+
+
+MathData::size_type MathData::find_last(MathData const & ar) const
+{
+ for (int i = size() - ar.size(); i >= 0; --i)
+ if (find1(ar, i))
+ return i;
+ return size();
+}
+
+
+bool MathData::contains(MathData const & ar) const
+{
+ if (find(ar) != size())
+ return true;
+ for (const_iterator it = begin(); it != end(); ++it)
+ if ((*it)->contains(ar))
+ return true;
+ return false;
+}
+
+
+void MathData::touch() const
+{
+}
+
+
+bool MathData::metrics(MetricsInfo & mi, Dimension & dim) const
+{
+ dim = dim_;
+ metrics(mi);
+ if (dim_ == dim)
+ return false;
+ dim = dim_;
+ return true;
+}
+
+
+namespace {
+
+bool isInside(DocIterator const & it, MathData const & ar,
+ pos_type p1, pos_type p2)
+{
+ for (size_t i = 0; i != it.depth(); ++i) {
+ CursorSlice const & sl = it[i];
+ if (sl.inset().inMathed() && &sl.cell() == &ar)
+ return p1 <= sl.pos() && sl.pos() < p2;
+ }
+ return false;
+}
+
+}
+
+
+
+void MathData::metrics(MetricsInfo & mi) const
+{
+ frontend::FontMetrics const & fm = theFontMetrics(mi.base.font);
+ dim_ = fm.dimension('I');
+ int xascent = fm.dimension('x').ascent();
+ if (xascent >= dim_.asc)
+ xascent = (2 * dim_.asc) / 3;
+ minasc_ = xascent;
+ mindes_ = (3 * xascent) / 4;
+ slevel_ = (4 * xascent) / 5;
+ sshift_ = xascent / 4;
+ kerning_ = 0;
+
+ if (empty())
+ return;
+
+ dim_.asc = 0;
+ dim_.wid = 0;
+ Dimension d;
+ //BufferView & bv = *mi.base.bv;
+ //Buffer const & buf = *bv.buffer();
+ for (size_t i = 0, n = size(); i != n; ++i) {
+ MathAtom const & at = operator[](i);
+#if 0
+ MathMacro const * mac = at->asMacro();
+ if (mac && buf.hasMacro(mac->name())) {
+ MacroData const & tmpl = buf.getMacro(mac->name());
+ int numargs = tmpl.numargs();
+ if (i + numargs > n)
+ numargs = n - i - 1;
+ lyxerr << "metrics:found macro: " << mac->name()
+ << " numargs: " << numargs << endl;
+ if (!isInside(bv.cursor(), *this, i + 1, i + numargs + 1)) {
+ MathData args(begin() + i + 1, begin() + i + numargs + 1);
+ MathData exp;
+ tmpl.expand(args, exp);
+ mac->setExpansion(exp, args);
+ mac->metricsExpanded(mi, d);
+ dim_.wid += mac->widthExpanded();
+ i += numargs;
+ continue;
+ }
+ }
+#endif
+ at->metrics(mi, d);
+ dim_ += d;
+ if (i == n - 1)
+ kerning_ = at->kerning();
+ }
+}
+
+
+void MathData::draw(PainterInfo & pi, int x, int y) const
+{
+ //lyxerr << "MathData::draw: x: " << x << " y: " << y << endl;
+ BufferView & bv = *pi.base.bv;
+ setXY(bv, x, y);
+
+ if (empty()) {
+ pi.pain.rectangle(x, y - ascent(), width(), height(), LColor::mathline);
+ return;
+ }
+
+ // don't draw outside the workarea
+ if (y + descent() <= 0
+ || y - ascent() >= bv.workHeight()
+ || x + width() <= 0
+ || x >= bv. workWidth())
+ return;
+
+ for (size_t i = 0, n = size(); i != n; ++i) {
+ MathAtom const & at = operator[](i);
+#if 0
+ Buffer const & buf = bv.buffer();
+ // special macro handling
+ MathMacro const * mac = at->asMacro();
+ if (mac && buf.hasMacro(mac->name())) {
+ MacroData const & tmpl = buf.getMacro(mac->name());
+ int numargs = tmpl.numargs();
+ if (i + numargs > n)
+ numargs = n - i - 1;
+ if (!isInside(bv.cursor(), *this, i + 1, i + numargs + 1)) {
+ mac->drawExpanded(pi, x, y);
+ x += mac->widthExpanded();
+ i += numargs;
+ continue;
+ }
+ }
+#endif
+ bv.coordCache().insets().add(at.nucleus(), x, y);
+ at->drawSelection(pi, x, y);
+ at->draw(pi, x, y);
+ x += at->width();
+ }
+}
+
+
+void MathData::metricsT(TextMetricsInfo const & mi, Dimension & dim) const
+{
+ dim.clear();
+ Dimension d;
+ for (const_iterator it = begin(); it != end(); ++it) {
+ (*it)->metricsT(mi, d);
+ dim += d;
+ }
+}
+
+
+void MathData::drawT(TextPainter & pain, int x, int y) const
+{
+ //lyxerr << "x: " << x << " y: " << y << ' ' << pain.workAreaHeight() << endl;
+
+ // FIXME: Abdel 16/10/2006
+ // This drawT() method is never used, this is dead code.
+
+ for (const_iterator it = begin(), et = end(); it != et; ++it) {
+ (*it)->drawT(pain, x, y);
+ //x += (*it)->width_;
+ x += 2;
+ }
+}
+
+
+int MathData::pos2x(size_type pos) const
+{
+ return pos2x(pos, 0);
+}
+
+
+int MathData::pos2x(size_type pos, int glue) const
+{
+ int x = 0;
+ size_type target = min(pos, size());
+ for (size_type i = 0; i < target; ++i) {
+ const_iterator it = begin() + i;
+ if ((*it)->getChar() == ' ')
+ x += glue;
+ //lyxerr << "char: " << (*it)->getChar()
+ // << "width: " << (*it)->width() << std::endl;
+ x += (*it)->width();
+ }
+ return x;
+}
+
+
+MathData::size_type MathData::x2pos(int targetx) const
+{
+ return x2pos(targetx, 0);
+}
+
+
+MathData::size_type MathData::x2pos(int targetx, int glue) const
+{
+ const_iterator it = begin();
+ int lastx = 0;
+ int currx = 0;
+ // find first position after targetx
+ for (; currx < targetx && it < end(); ++it) {
+ lastx = currx;
+ if ((*it)->getChar() == ' ')
+ currx += glue;
+ currx += (*it)->width();
+ }
+
+ /**
+ * If we are not at the beginning of the array, go to the left
+ * of the inset if one of the following two condition holds:
+ * - the current inset is editable (so that the cursor tip is
+ * deeper than us): in this case, we want all intermediate
+ * cursor slices to be before insets;
+ * - the mouse is closer to the left side of the inset than to
+ * the right one.
+ * See bug 1918 for details.
+ **/
+ if (it != begin() && currx >= targetx
+ && ((*boost::prior(it))->asNestInset()
+ || abs(lastx - targetx) < abs(currx - targetx))) {
+ --it;
+ }
+
+ return it - begin();
+}
+
+
+int MathData::dist(BufferView const & bv, int x, int y) const
+{
+ int xx = 0;
+ int yy = 0;
+
+ const int xo_ = xo(bv);
+ const int yo_ = yo(bv);
+
+ if (x < xo_)
+ xx = xo_ - x;
+ else if (x > xo_ + width())
+ xx = x - xo_ - width();
+
+ if (y < yo_ - ascent())
+ yy = yo_ - ascent() - y;
+ else if (y > yo_ + descent())
+ yy = y - yo_ - descent();
+
+ return xx + yy;
+}
+
+
+void MathData::setXY(BufferView & bv, int x, int y) const
+{
+ //lyxerr << "setting position cache for MathData " << this << std::endl;
+ bv.coordCache().arrays().add(this, x, y);
+}
+
+
+int MathData::xo(BufferView const & bv) const
+{
+ return bv.coordCache().getArrays().x(this);
+}
+
+
+int MathData::yo(BufferView const & bv) const
+{
+ return bv.coordCache().getArrays().y(this);
+}
+
+
+std::ostream & operator<<(std::ostream & os, MathData const & ar)
+{
+ odocstringstream oss;
+ NormalStream ns(oss);
+ ns << ar;
+ return os << to_utf8(oss.str());
+}
+
+
+odocstream & operator<<(odocstream & os, MathData const & ar)
+{
+ NormalStream ns(os);
+ ns << ar;
+ return os;
+}
+
+
+} // namespace lyx
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file MathData.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Alejandro Aguilar Sierra
+ * \author André Pönitz
+ * \author Lars Gullik Bjønnes
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef MATH_DATA_H
+#define MATH_DATA_H
+
+#include <vector>
+
+#include "MathAtom.h"
+#include "Dimension.h"
+
+#include "support/docstream.h"
+
+
+namespace lyx {
+
+class BufferView;
+class LaTeXFeatures;
+class ReplaceData;
+class MetricsInfo;
+class PainterInfo;
+class TextMetricsInfo;
+class TextPainter;
+
+
+class MathData : private std::vector<MathAtom> {
+public:
+ /// re-use inhertited stuff
+ typedef std::vector<MathAtom> base_type;
+ using base_type::const_iterator;
+ using base_type::iterator;
+ using base_type::size_type;
+ using base_type::difference_type;
+ using base_type::size;
+ using base_type::empty;
+ using base_type::clear;
+ using base_type::begin;
+ using base_type::end;
+ using base_type::push_back;
+ using base_type::pop_back;
+ using base_type::back;
+ using base_type::front;
+ ///
+ typedef size_type idx_type;
+ typedef size_type pos_type;
+
+public:
+ ///
+ MathData() {}
+ ///
+ MathData(const_iterator from, const_iterator to);
+ ///
+ void append(MathData const & ar);
+
+ /// inserts single atom at position pos
+ void insert(size_type pos, MathAtom const & at);
+ /// inserts multiple atoms at position pos
+ void insert(size_type pos, MathData const & ar);
+
+ /// erase range from pos1 to pos2
+ void erase(iterator pos1, iterator pos2);
+ /// erase single atom
+ void erase(iterator pos);
+ /// erase range from pos1 to pos2
+ void erase(size_type pos1, size_type pos2);
+ /// erase single atom
+ void erase(size_type pos);
+
+ ///
+ void dump() const;
+ ///
+ void dump2() const;
+ ///
+ void replace(ReplaceData &);
+ ///
+ void substitute(MathData const & m);
+
+ /// looks for exact match
+ bool match(MathData const & ar) const;
+ /// looks for inclusion match starting at pos
+ bool matchpart(MathData const & ar, pos_type pos) const;
+ /// looks for containment, return == size mean not found
+ size_type find(MathData const & ar) const;
+ /// looks for containment, return == size mean not found
+ size_type find_last(MathData const & ar) const;
+ ///
+ bool contains(MathData const & ar) const;
+ ///
+ void validate(LaTeXFeatures &) const;
+
+ /// checked write access
+ MathAtom & operator[](pos_type);
+ /// checked read access
+ MathAtom const & operator[](pos_type) const;
+ /// rebuild cached metrics information
+ void metrics(MetricsInfo & mi) const;
+ /// rebuild cached metrics information
+ bool metrics(MetricsInfo & mi, Dimension & dim) const;
+ /// redraw cell using cache metrics information
+ void draw(PainterInfo & pi, int x, int y) const;
+ /// rebuild cached metrics information
+ void metricsT(TextMetricsInfo const & mi, Dimension & dim) const;
+ /// redraw cell using cache metrics information
+ void drawT(TextPainter & pi, int x, int y) const;
+ /// mark cell for re-drawing
+ void touch() const;
+
+ /// access to cached x coordinate of last drawing
+ int xo(BufferView const & bv) const;
+ /// access to cached y coordinate of last drawing
+ int yo(BufferView const & bv) const;
+ /// access to cached x coordinate of mid point of last drawing
+ int xm(BufferView const & bv) const { return xo(bv) + dim_.wid / 2; }
+ /// access to cached y coordinate of mid point of last drawing
+ int ym(BufferView const & bv) const { return yo(bv) + (dim_.des - dim_.asc) / 2; }
+ /// write access to coordinate;
+ void setXY(BufferView & bv, int x, int y) const;
+ /// returns x coordinate of given position in the array
+ int pos2x(size_type pos) const;
+ /// returns position of given x coordinate
+ int pos2x(size_type pos, int glue) const;
+ /// returns position of given x coordinate
+ size_type x2pos(int pos) const;
+ /// returns position of given x coordinate fstarting from a certain pos
+ size_type x2pos(int targetx, int glue) const;
+ /// returns distance of this cell to the point given by x and y
+ // assumes valid position and size cache
+ int dist(BufferView const & bv, int x, int y) const;
+
+ /// ascent of this cell above the baseline
+ int ascent() const { return dim_.asc; }
+ /// descent of this cell below the baseline
+ int descent() const { return dim_.des; }
+ /// height of the cell
+ int height() const { return dim_.asc + dim_.des; }
+ /// width of this cell
+ int width() const { return dim_.wid; }
+ /// dimensions of cell
+ Dimension const & dim() const { return dim_; }
+ /// dimensions of cell
+ void setDim(Dimension const & d) const { dim_ = d; }
+ /// minimum ascent offset for superscript
+ int minasc() const { return minasc_; }
+ /// minimum descent offset for subscript
+ int mindes() const { return mindes_; }
+ /// level above/below which super/subscript should extend
+ int slevel() const { return slevel_; }
+ /// additional super/subscript shift
+ int sshift() const { return sshift_; }
+ /// superscript kerning
+ int kerning() const { return kerning_; }
+ ///
+ void swap(MathData & ar) { base_type::swap(ar); }
+
+protected:
+ /// cached dimensions of cell
+ mutable Dimension dim_;
+ /// cached values for super/subscript placement
+ mutable int minasc_;
+ mutable int mindes_;
+ mutable int slevel_;
+ mutable int sshift_;
+ mutable int kerning_;
+
+private:
+ /// is this an exact match at this position?
+ bool find1(MathData const & ar, size_type pos) const;
+};
+
+///
+std::ostream & operator<<(std::ostream & os, MathData const & ar);
+///
+odocstream & operator<<(odocstream & os, MathData const & ar);
+
+
+} // namespace lyx
+
+#endif
// This file contains most of the magic that extracts "context
// information" from the unstructered layout-oriented stuff in an
-// MathArray.
+// MathData.
#include <config.h>
#include "InsetMathArray.h"
#include "InsetMathChar.h"
#include "InsetMathDelim.h"
-#include "MathArray.h"
+#include "MathData.h"
#include "InsetMathDiff.h"
#include "InsetMathExFunc.h"
#include "InsetMathExInt.h"
typedef bool TestItemFunc(MathAtom const &);
// define a function for replacing subexpressions
-typedef MathAtom ReplaceArgumentFunc(const MathArray & ar);
+typedef MathAtom ReplaceArgumentFunc(const MathData & ar);
// try to extract a super/subscript
// modify iterator position to point behind the thing
-bool extractScript(MathArray & ar,
- MathArray::iterator & pos, MathArray::iterator last, bool superscript)
+bool extractScript(MathData & ar,
+ MathData::iterator & pos, MathData::iterator last, bool superscript)
{
// nothing to get here
if (pos == last)
// try to extract an "argument" to some function.
// returns position behind the argument
-MathArray::iterator extractArgument(MathArray & ar,
- MathArray::iterator pos, MathArray::iterator last, bool function = false)
+MathData::iterator extractArgument(MathData & ar,
+ MathData::iterator pos, MathData::iterator last, bool function = false)
{
// nothing to get here
if (pos == last)
if ((*pos)->asDelimInset()) {
// leave out delimiters if this is a function argument
if (function) {
- MathArray const & arg = (*pos)->asDelimInset()->cell(0);
- MathArray::const_iterator cur = arg.begin();
- MathArray::const_iterator end = arg.end();
+ MathData const & arg = (*pos)->asDelimInset()->cell(0);
+ MathData::const_iterator cur = arg.begin();
+ MathData::const_iterator end = arg.end();
while (cur != end)
ar.push_back(*cur++);
} else
// but it might be more than that.
// FIXME: not implemented
- //for (MathArray::iterator it = pos + 1; it != last; ++it) {
+ //for (MathData::iterator it = pos + 1; it != last; ++it) {
// // always take the first thing, no matter
// if (it == pos) {
// ar.push_back(*it);
// returns sequence of char with same code starting at it up to end
// it might be less, though...
docstring charSequence
- (MathArray::const_iterator it, MathArray::const_iterator end)
+ (MathData::const_iterator it, MathData::const_iterator end)
{
docstring s;
for (; it != end && (*it)->asCharInset(); ++it)
}
-void extractStrings(MathArray & ar)
+void extractStrings(MathData & ar)
{
//lyxerr << "\nStrings from: " << ar << endl;
for (size_t i = 0; i < ar.size(); ++i) {
}
-void extractMatrices(MathArray & ar)
+void extractMatrices(MathData & ar)
{
//lyxerr << "\nMatrices from: " << ar << endl;
// first pass for explicitly delimited stuff
for (size_t i = 0; i < ar.size(); ++i) {
if (!ar[i]->asDelimInset())
continue;
- MathArray const & arr = ar[i]->asDelimInset()->cell(0);
+ MathData const & arr = ar[i]->asDelimInset()->cell(0);
if (arr.size() != 1)
continue;
if (!arr.front()->asGridInset())
}
if (at->asFontInset() && at->name() == "mathrm") {
// assume it is well known...
- MathArray const & ar = at->asFontInset()->cell(0);
+ MathData const & ar = at->asFontInset()->cell(0);
str = charSequence(ar.begin(), ar.end());
return ar.size() == str.size();
}
// convert this inset somehow to a number
-bool extractNumber(MathArray const & ar, int & i)
+bool extractNumber(MathData const & ar, int & i)
{
idocstringstream is(charSequence(ar.begin(), ar.end()));
is >> i;
}
-bool extractNumber(MathArray const & ar, double & d)
+bool extractNumber(MathData const & ar, double & d)
{
idocstringstream is(charSequence(ar.begin(), ar.end()));
is >> d;
}
// search end of nested sequence
-MathArray::iterator endNestSearch(
- MathArray::iterator it,
- MathArray::iterator last,
+MathData::iterator endNestSearch(
+ MathData::iterator it,
+ MathData::iterator last,
TestItemFunc testOpen,
TestItemFunc testClose
)
// replace nested sequences by a real Insets
void replaceNested(
- MathArray & ar,
+ MathData & ar,
TestItemFunc testOpen,
TestItemFunc testClose,
ReplaceArgumentFunc replaceArg
continue;
// search end of sequence
- MathArray::iterator it = ar.begin() + i;
- MathArray::iterator jt = endNestSearch(it, ar.end(), testOpen, testClose);
+ MathData::iterator it = ar.begin() + i;
+ MathData::iterator jt = endNestSearch(it, ar.end(), testOpen, testClose);
if (jt == ar.end())
continue;
// replace the original stuff by the new inset
- ar[i] = replaceArg(MathArray(it + 1, jt));
+ ar[i] = replaceArg(MathData(it + 1, jt));
ar.erase(it + 1, jt + 1);
}
}
// front of super...
//
-void splitScripts(MathArray & ar)
+void splitScripts(MathData & ar)
{
//lyxerr << "\nScripts from: " << ar << endl;
for (size_t i = 0; i < ar.size(); ++i) {
// if we don't have a subscript, get rid of the ScriptInset
if (!script->hasDown()) {
- MathArray arg(p->nuc());
- MathArray::const_iterator it = arg.begin();
- MathArray::const_iterator et = arg.end();
+ MathData arg(p->nuc());
+ MathData::const_iterator it = arg.begin();
+ MathData::const_iterator et = arg.end();
ar.erase(i);
while (it != et)
ar.insert(i++, *it++);
// extract exp(...)
//
-void extractExps(MathArray & ar)
+void extractExps(MathData & ar)
{
//lyxerr << "\nExps from: " << ar << endl;
for (size_t i = 0; i + 1 < ar.size(); ++i) {
//
// extract det(...) from |matrix|
//
-void extractDets(MathArray & ar)
+void extractDets(MathData & ar)
{
//lyxerr << "\ndet from: " << ar << endl;
- for (MathArray::iterator it = ar.begin(); it != ar.end(); ++it) {
+ for (MathData::iterator it = ar.begin(); it != ar.end(); ++it) {
InsetMathDelim const * del = (*it)->asDelimInset();
if (!del)
continue;
// returns sequence of digits
docstring digitSequence
- (MathArray::const_iterator it, MathArray::const_iterator end)
+ (MathData::const_iterator it, MathData::const_iterator end)
{
docstring s;
for (; it != end && (*it)->asCharInset(); ++it) {
}
-void extractNumbers(MathArray & ar)
+void extractNumbers(MathData & ar)
{
//lyxerr << "\nNumbers from: " << ar << endl;
for (size_t i = 0; i < ar.size(); ++i) {
}
-MathAtom replaceParenDelims(const MathArray & ar)
+MathAtom replaceParenDelims(const MathData & ar)
{
return MathAtom(new InsetMathDelim(from_ascii("("), from_ascii(")"), ar));
}
}
-MathAtom replaceBracketDelims(const MathArray & ar)
+MathAtom replaceBracketDelims(const MathData & ar)
{
return MathAtom(new InsetMathDelim(from_ascii("["), from_ascii("]"), ar));
}
// replace '('...')' and '['...']' sequences by a real InsetMathDelim
-void extractDelims(MathArray & ar)
+void extractDelims(MathData & ar)
{
//lyxerr << "\nDelims from: " << ar << endl;
replaceNested(ar, testOpenParen, testCloseParen, replaceParenDelims);
// replace 'f' '(...)' and 'f' '^n' '(...)' sequences by a real InsetMathExFunc
// assume 'extractDelims' ran before
-void extractFunctions(MathArray & ar)
+void extractFunctions(MathData & ar)
{
// we need at least two items...
if (ar.size() < 2)
//lyxerr << "\nFunctions from: " << ar << endl;
for (size_t i = 0; i + 1 < ar.size(); ++i) {
- MathArray::iterator it = ar.begin() + i;
- MathArray::iterator jt = it + 1;
+ MathData::iterator it = ar.begin() + i;
+ MathData::iterator jt = it + 1;
docstring name;
// is it a function?
// do we have an exponent like in
// 'sin' '^2' 'x' -> 'sin(x)' '^2'
- MathArray exp;
+ MathData exp;
extractScript(exp, jt, ar.end(), true);
// create a proper inset as replacement
auto_ptr<InsetMathExFunc> p(new InsetMathExFunc(name));
// jt points to the "argument". Get hold of this.
- MathArray::iterator st = extractArgument(p->cell(0), jt, ar.end(), true);
+ MathData::iterator st = extractArgument(p->cell(0), jt, ar.end(), true);
// replace the function name by a real function inset
*it = MathAtom(p.release());
// replace '\int' ['_^'] x 'd''x'(...)' sequences by a real InsetMathExInt
// assume 'extractDelims' ran before
-void extractIntegrals(MathArray & ar)
+void extractIntegrals(MathData & ar)
{
// we need at least three items...
if (ar.size() < 3)
//lyxerr << "\nIntegrals from: " << ar << endl;
for (size_t i = 0; i + 1 < ar.size(); ++i) {
- MathArray::iterator it = ar.begin() + i;
+ MathData::iterator it = ar.begin() + i;
// search 'd'
- MathArray::iterator jt =
+ MathData::iterator jt =
endNestSearch(it, ar.end(), testIntegral, testIntDiff);
// something sensible found?
p->cell(2) = (*it)->asScriptInset()->down();
p->cell(3) = (*it)->asScriptInset()->up();
}
- p->cell(0) = MathArray(it + 1, jt);
+ p->cell(0) = MathData(it + 1, jt);
// use the "thing" behind the 'd' as differential
- MathArray::iterator tt = extractArgument(p->cell(1), jt + 1, ar.end());
+ MathData::iterator tt = extractArgument(p->cell(1), jt + 1, ar.end());
// remove used parts
ar.erase(it + 1, tt);
// try to extract a "term", i.e., something delimited by '+' or '-'.
// returns position behind the term
-MathArray::iterator extractTerm(MathArray & ar,
- MathArray::iterator pos, MathArray::iterator last)
+MathData::iterator extractTerm(MathData & ar,
+ MathData::iterator pos, MathData::iterator last)
{
while (pos != last && !testTermDelimiter(*pos)) {
ar.push_back(*pos);
// replace '\sum' ['_^'] f(x) sequences by a real InsetMathExInt
// assume 'extractDelims' ran before
-void extractSums(MathArray & ar)
+void extractSums(MathData & ar)
{
// we need at least two items...
if (ar.size() < 2)
//lyxerr << "\nSums from: " << ar << endl;
for (size_t i = 0; i + 1 < ar.size(); ++i) {
- MathArray::iterator it = ar.begin() + i;
+ MathData::iterator it = ar.begin() + i;
// is this a sum name?
if (!testSum(ar[i]))
InsetMathScript const * sub = ar[i]->asScriptInset();
if (sub && sub->hasDown()) {
// try to figure out the summation index from the subscript
- MathArray const & ar = sub->down();
- MathArray::const_iterator xt =
+ MathData const & ar = sub->down();
+ MathData::const_iterator xt =
find_if(ar.begin(), ar.end(), &testEqualSign);
if (xt != ar.end()) {
// we found a '=', use everything in front of that as index,
// and everything behind as lower index
- p->cell(1) = MathArray(ar.begin(), xt);
- p->cell(2) = MathArray(xt + 1, ar.end());
+ p->cell(1) = MathData(ar.begin(), xt);
+ p->cell(2) = MathData(xt + 1, ar.end());
} else {
// use everything as summation index, don't use scripts.
p->cell(1) = ar;
p->cell(3) = sub->up();
// use something behind the script as core
- MathArray::iterator tt = extractTerm(p->cell(0), it + 1, ar.end());
+ MathData::iterator tt = extractTerm(p->cell(0), it + 1, ar.end());
// cleanup
ar.erase(it + 1, tt);
}
-bool testDiffArray(MathArray const & ar)
+bool testDiffArray(MathData const & ar)
{
return ar.size() && testDiffItem(ar.front());
}
}
-void extractDiff(MathArray & ar)
+void extractDiff(MathData & ar)
{
//lyxerr << "\nDiffs from: " << ar << endl;
for (size_t i = 0; i < ar.size(); ++i) {
- MathArray::iterator it = ar.begin() + i;
+ MathData::iterator it = ar.begin() + i;
// is this a "differential fraction"?
if (!testDiffFrac(*it))
auto_ptr<InsetMathDiff> diff(new InsetMathDiff);
// collect function, let jt point behind last used item
- MathArray::iterator jt = it + 1;
+ MathData::iterator jt = it + 1;
//int n = 1;
- MathArray numer(f->cell(0));
+ MathData numer(f->cell(0));
splitScripts(numer);
if (numer.size() > 1 && numer[1]->asScriptInset()) {
// this is something like d^n f(x) / d... or d^n / d...
// FIXME
//n = 1;
if (numer.size() > 2)
- diff->cell(0) = MathArray(numer.begin() + 2, numer.end());
+ diff->cell(0) = MathData(numer.begin() + 2, numer.end());
else
jt = extractTerm(diff->cell(0), jt, ar.end());
} else {
// simply d f(x) / d... or d/d...
if (numer.size() > 1)
- diff->cell(0) = MathArray(numer.begin() + 1, numer.end());
+ diff->cell(0) = MathData(numer.begin() + 1, numer.end());
else
jt = extractTerm(diff->cell(0), jt, ar.end());
}
// collect denominator parts
- MathArray denom(f->cell(1));
+ MathData denom(f->cell(1));
splitScripts(denom);
- for (MathArray::iterator dt = denom.begin(); dt != denom.end();) {
+ for (MathData::iterator dt = denom.begin(); dt != denom.end();) {
// find the next 'd'
- MathArray::iterator et
+ MathData::iterator et
= find_if(dt + 1, denom.end(), &testDiffItem);
// point before this
- MathArray::iterator st = et - 1;
+ MathData::iterator st = et - 1;
InsetMathScript const * script = (*st)->asScriptInset();
if (script && script->hasUp()) {
// things like d.../dx^n
if (extractNumber(script->up(), mult)) {
//lyxerr << "mult: " << mult << endl;
for (int i = 0; i < mult; ++i)
- diff->addDer(MathArray(dt + 1, st));
+ diff->addDer(MathData(dt + 1, st));
}
} else {
// just d.../dx
- diff->addDer(MathArray(dt + 1, et));
+ diff->addDer(MathData(dt + 1, et));
}
dt = et;
}
// replace '\lim_{x->x0} f(x)' sequences by a real InsetMathLim
// assume 'extractDelims' ran before
-void extractLims(MathArray & ar)
+void extractLims(MathData & ar)
{
//lyxerr << "\nLimits from: " << ar << endl;
for (size_t i = 0; i < ar.size(); ++i) {
- MathArray::iterator it = ar.begin() + i;
+ MathData::iterator it = ar.begin() + i;
// must be a script inset with a subscript (without superscript)
InsetMathScript const * sub = (*it)->asScriptInset();
continue;
// subscript must contain a -> symbol
- MathArray const & s = sub->down();
- MathArray::const_iterator st = find_if(s.begin(), s.end(), &testRightArrow);
+ MathData const & s = sub->down();
+ MathData::const_iterator st = find_if(s.begin(), s.end(), &testRightArrow);
if (st == s.end())
continue;
// the -> splits the subscript int x and x0
- MathArray x = MathArray(s.begin(), st);
- MathArray x0 = MathArray(st + 1, s.end());
+ MathData x = MathData(s.begin(), st);
+ MathData x0 = MathData(st + 1, s.end());
// use something behind the script as core
- MathArray f;
- MathArray::iterator tt = extractTerm(f, it + 1, ar.end());
+ MathData f;
+ MathData::iterator tt = extractTerm(f, it + 1, ar.end());
// cleanup
ar.erase(it + 1, tt);
// combine searches
//
-void extractStructure(MathArray & ar)
+void extractStructure(MathData & ar)
{
//lyxerr << "\nStructure from: " << ar << endl;
splitScripts(ar);
}
-void write(MathArray const & dat, WriteStream & wi)
+void write(MathData const & dat, WriteStream & wi)
{
- MathArray ar = dat;
+ MathData ar = dat;
extractStrings(ar);
wi.firstitem() = true;
- for (MathArray::const_iterator it = ar.begin(); it != ar.end(); ++it) {
+ for (MathData::const_iterator it = ar.begin(); it != ar.end(); ++it) {
(*it)->write(wi);
wi.firstitem() = false;
}
}
-void normalize(MathArray const & ar, NormalStream & os)
+void normalize(MathData const & ar, NormalStream & os)
{
- for (MathArray::const_iterator it = ar.begin(); it != ar.end(); ++it)
+ for (MathData::const_iterator it = ar.begin(); it != ar.end(); ++it)
(*it)->normalize(os);
}
-void octave(MathArray const & dat, OctaveStream & os)
+void octave(MathData const & dat, OctaveStream & os)
{
- MathArray ar = dat;
+ MathData ar = dat;
extractStructure(ar);
- for (MathArray::const_iterator it = ar.begin(); it != ar.end(); ++it)
+ for (MathData::const_iterator it = ar.begin(); it != ar.end(); ++it)
(*it)->octave(os);
}
-void maple(MathArray const & dat, MapleStream & os)
+void maple(MathData const & dat, MapleStream & os)
{
- MathArray ar = dat;
+ MathData ar = dat;
extractStructure(ar);
- for (MathArray::const_iterator it = ar.begin(); it != ar.end(); ++it)
+ for (MathData::const_iterator it = ar.begin(); it != ar.end(); ++it)
(*it)->maple(os);
}
-void maxima(MathArray const & dat, MaximaStream & os)
+void maxima(MathData const & dat, MaximaStream & os)
{
- MathArray ar = dat;
+ MathData ar = dat;
extractStructure(ar);
- for (MathArray::const_iterator it = ar.begin(); it != ar.end(); ++it)
+ for (MathData::const_iterator it = ar.begin(); it != ar.end(); ++it)
(*it)->maxima(os);
}
-void mathematica(MathArray const & dat, MathematicaStream & os)
+void mathematica(MathData const & dat, MathematicaStream & os)
{
- MathArray ar = dat;
+ MathData ar = dat;
extractStructure(ar);
- for (MathArray::const_iterator it = ar.begin(); it != ar.end(); ++it)
+ for (MathData::const_iterator it = ar.begin(); it != ar.end(); ++it)
(*it)->mathematica(os);
}
-void mathmlize(MathArray const & dat, MathStream & os)
+void mathmlize(MathData const & dat, MathStream & os)
{
- MathArray ar = dat;
+ MathData ar = dat;
extractStructure(ar);
if (ar.size() == 0)
os << "<mrow/>";
os << ar.front();
else {
os << MTag("mrow");
- for (MathArray::const_iterator it = ar.begin(); it != ar.end(); ++it)
+ for (MathData::const_iterator it = ar.begin(); it != ar.end(); ++it)
(*it)->mathmlize(os);
os << ETag("mrow");
}
return npos;
}
- MathArray pipeThroughMaxima(docstring const &, MathArray const & ar)
+ MathData pipeThroughMaxima(docstring const &, MathData const & ar)
{
odocstringstream os;
MaximaStream ms(os);
vector<std::string> tmp = getVectorFromString(out, "$$");
if (tmp.size() < 2)
- return MathArray();
+ return MathData();
out = subst(tmp[1], "\\>", std::string());
lyxerr << "output: '" << out << "'" << endl;
//lyxerr << "output: " << out << endl;
i = out.find("\\over", i + 4);
}
- MathArray res;
+ MathData res;
mathed_parse_cell(res, from_utf8(out));
return res;
}
- MathArray pipeThroughMaple(docstring const & extra, MathArray const & ar)
+ MathData pipeThroughMaple(docstring const & extra, MathData const & ar)
{
std::string header = "readlib(latex):\n";
// change \_ into _
//
- MathArray res;
+ MathData res;
mathed_parse_cell(res, from_utf8(out));
return res;
}
- MathArray pipeThroughOctave(docstring const &, MathArray const & ar)
+ MathData pipeThroughOctave(docstring const &, MathData const & ar)
{
odocstringstream os;
OctaveStream vs(os);
// ansi control sequence before, such as '\033[?1034hans = '
size_t i = out.find("ans = ");
if (i == string::npos)
- return MathArray();
+ return MathData();
out = out.substr(i + 6);
// parse output as matrix or single number
MathAtom at(new InsetMathArray(from_ascii("array"), from_utf8(out)));
InsetMathArray const * mat = at->asArrayInset();
- MathArray res;
+ MathData res;
if (mat->ncols() == 1 && mat->nrows() == 1)
res.append(mat->cell(0));
else {
}
- MathArray pipeThroughMathematica(docstring const &, MathArray const & ar)
+ MathData pipeThroughMathematica(docstring const &, MathData const & ar)
{
odocstringstream os;
MathematicaStream ms(os);
size_t pos2 = out.find("In[2]:=");
if (pos1 == string::npos || pos2 == string::npos)
- return MathArray();
+ return MathData();
// get everything from pos1+17 to pos2
out = out.substr(pos1 + 17, pos2 - pos1 - 17);
prettifyMathematicaOutput(out, "Muserfunction", true, false);
prettifyMathematicaOutput(out, "Mvariable", false, false);
- MathArray res;
+ MathData res;
mathed_parse_cell(res, from_utf8(out));
return res;
}
}
-MathArray pipeThroughExtern(string const & lang, docstring const & extra,
- MathArray const & ar)
+MathData pipeThroughExtern(string const & lang, docstring const & extra,
+ MathData const & ar)
{
if (lang == "octave")
return pipeThroughOctave(extra, ar);
support::FileName const file = libFileSearch("mathed", "extern_" + lang);
if (file.empty()) {
lyxerr << "converter to '" << lang << "' not found" << endl;
- return MathArray();
+ return MathData();
}
// run external sript
string out = captureOutput(file.absFilename(), data);
- MathArray res;
+ MathData res;
mathed_parse_cell(res, from_utf8(out));
return res;
}
class MathStream;
class OctaveStream;
class WriteStream;
-class MathArray;
+class MathData;
-void write(MathArray const &, WriteStream &);
-void normalize(MathArray const &, NormalStream &);
-void maple(MathArray const &, MapleStream &);
-void maxima(MathArray const &, MaximaStream &);
-void mathematica(MathArray const &, MathematicaStream &);
-void mathmlize(MathArray const &, MathStream &);
-void octave(MathArray const &, OctaveStream &);
+void write(MathData const &, WriteStream &);
+void normalize(MathData const &, NormalStream &);
+void maple(MathData const &, MapleStream &);
+void maxima(MathData const &, MaximaStream &);
+void mathematica(MathData const &, MathematicaStream &);
+void mathmlize(MathData const &, MathStream &);
+void octave(MathData const &, OctaveStream &);
-bool extractNumber(MathArray const & ar, int & i);
-bool extractNumber(MathArray const & ar, double & i);
+bool extractNumber(MathData const & ar, int & i);
+bool extractNumber(MathData const & ar, double & i);
-MathArray pipeThroughExtern(std::string const & language,
- docstring const & extra, MathArray const & ar);
+MathData pipeThroughExtern(std::string const & language,
+ docstring const & extra, MathData const & ar);
} // namespace lyx
}
-bool createInsetMath_fromDialogStr(docstring const & str, MathArray & ar)
+bool createInsetMath_fromDialogStr(docstring const & str, MathData & ar)
{
// An example str:
// "ref LatexCommand ref\nreference \"sec:Title\"\n\\end_inset\n\n";
namespace lyx {
class MathAtom;
-class MathArray;
+class MathData;
MathAtom createInsetMath(docstring const &);
* str is created by the frontend dialog's and returned to the LyX core.
* The function returns true if successful.
*/
-bool createInsetMath_fromDialogStr(docstring const &, MathArray &);
+bool createInsetMath_fromDialogStr(docstring const &, MathData &);
} // namespace lyx
class MathMacroArgumentValue : public InsetMathDim {
public:
///
- MathMacroArgumentValue(MathArray const * value, docstring const & macroName)
+ MathMacroArgumentValue(MathData const * value, docstring const & macroName)
: value_(value), macroName_(macroName) {}
///
bool metrics(MetricsInfo & mi, Dimension & dim) const;
private:
std::auto_ptr<InsetBase> doClone() const;
- MathArray const * value_;
+ MathData const * value_;
docstring macroName_;
};
MacroData const & macro = MacroTable::globalMacros().get(name());
if (macro.locked()) {
mathed_string_dim(mi.base.font, "Self reference: " + name(), dim);
- expanded_ = MathArray();
+ expanded_ = MathData();
} else if (editing(mi.base.bv)) {
// FIXME UNICODE
asArray(macro.def(), tmpl_);
// FIXME UNICODE
int ww = mathed_string_width(font, from_ascii("#1: "));
for (idx_type i = 0; i < nargs(); ++i) {
- MathArray const & c = cell(i);
+ MathData const & c = cell(i);
c.metrics(mi);
dim.wid = max(dim.wid, c.width() + ww);
dim.des += c.height() + 10;
} else {
// create MathMacroArgumentValue object pointing to the cells of the macro
MacroData const & macro = MacroTable::globalMacros().get(name());
- vector<MathArray> values(nargs());
+ vector<MathData> values(nargs());
for (size_t i = 0; i != nargs(); ++i)
values[i].insert(0, MathAtom(new MathMacroArgumentValue(&cells_[i], name())));
macro.expand(values, expanded_);
docstring t = from_ascii("#1: ");
mathed_string_dim(font, t, ldim);
for (idx_type i = 0; i < nargs(); ++i) {
- MathArray const & c = cell(i);
+ MathData const & c = cell(i);
h += max(c.ascent(), ldim.asc) + 5;
c.draw(pi, x + ldim.wid, h);
char_type str[] = { '#', '1', ':', '\0' };
#define MATH_MACRO_H
#include "InsetMathNest.h"
-#include "MathArray.h"
+#include "MathData.h"
#include "InsetMathNest.h"
#include "MathMacroTable.h"
///
docstring name() const;
///
- void setExpansion(MathArray const & exp, MathArray const & args) const;
+ void setExpansion(MathData const & exp, MathData const & args) const;
///
void validate(LaTeXFeatures &) const;
/// name of macro
docstring name_;
/// the unexpanded macro defintition
- mutable MathArray tmpl_;
+ mutable MathData tmpl_;
/// the macro substituted with our args
- mutable MathArray expanded_;
+ mutable MathData expanded_;
};
{}
-void MacroData::expand(vector<MathArray> const & args, MathArray & to) const
+void MacroData::expand(vector<MathData> const & args, MathData & to) const
{
InsetMathSqrt inset; // Hack. Any inset with a cell would do.
// FIXME UNICODE
namespace lyx {
-class MathArray;
+class MathData;
///
class MacroData {
///
int numargs() const { return numargs_; }
/// replace #1,#2,... by given MathAtom 0,1,..
- void expand(std::vector<MathArray> const & from, MathArray & to) const;
+ void expand(std::vector<MathData> const & from, MathData & to) const;
///
std::string requires() const { return requires_; }
///
MathMacroTemplate::MathMacroTemplate(docstring const & name, int numargs,
- docstring const & type, MathArray const & ar1, MathArray const & ar2)
+ docstring const & type, MathData const & ar1, MathData const & ar2)
: InsetMathNest(2), numargs_(numargs), name_(name), type_(type)
{
initMath();
{
initMath();
- MathArray ar;
+ MathData ar;
mathed_parse_cell(ar, str);
if (ar.size() != 1 || !ar[0]->asMacroTemplate()) {
lyxerr << "Cannot read macro from '" << ar << "'" << endl;
void MathMacroTemplate::read(Buffer const &, Lexer & lex)
{
- MathArray ar;
+ MathData ar;
mathed_parse_cell(ar, lex.getStream());
if (ar.size() != 1 || !ar[0]->asMacroTemplate()) {
lyxerr << "Cannot read macro from '" << ar << "'" << endl;
#ifndef MATH_MACROTEMPLATE_H
#define MATH_MACROTEMPLATE_H
-#include "MathArray.h"
+#include "MathData.h"
#include "MathMacroTable.h"
#include "InsetMathNest.h"
///
MathMacroTemplate(docstring const & name, int nargs,
docstring const & type,
- MathArray const & = MathArray(),
- MathArray const & = MathArray());
+ MathData const & = MathData(),
+ MathData const & = MathData());
///
explicit MathMacroTemplate(const docstring & str);
///
///
bool parse(MathAtom & at);
///
- void parse(MathArray & array, unsigned flags, mode_type mode);
+ void parse(MathData & array, unsigned flags, mode_type mode);
///
void parse1(InsetMathGrid & grid, unsigned flags, mode_type mode,
bool numbered);
///
- MathArray parse(unsigned flags, mode_type mode);
+ MathData parse(unsigned flags, mode_type mode);
///
int lineno() const { return lineno_; }
///
bool Parser::parse(MathAtom & at)
{
skipSpaces();
- MathArray ar;
+ MathData ar;
parse(ar, false, InsetMath::UNDECIDED_MODE);
if (ar.size() != 1 || ar.front()->getType() == hullNone) {
lyxerr << "unusual contents found: " << ar << endl;
}
-MathArray Parser::parse(unsigned flags, mode_type mode)
+MathData Parser::parse(unsigned flags, mode_type mode)
{
- MathArray ar;
+ MathData ar;
parse(ar, flags, mode);
return ar;
}
-void Parser::parse(MathArray & array, unsigned flags, mode_type mode)
+void Parser::parse(MathData & array, unsigned flags, mode_type mode)
{
InsetMathGrid grid(1, 1);
parse1(grid, flags, mode, false);
int limits = 0;
InsetMathGrid::row_type cellrow = 0;
InsetMathGrid::col_type cellcol = 0;
- MathArray * cell = &grid.cell(grid.index(cellrow, cellcol));
+ MathData * cell = &grid.cell(grid.index(cellrow, cellcol));
if (grid.asHullInset())
grid.asHullInset()->numbered(cellrow, numbered);
if (flags & FLAG_OPTION) {
if (t.cat() == catOther && t.character() == '[') {
- MathArray ar;
+ MathData ar;
parse(ar, FLAG_BRACK_LAST, mode);
cell->append(ar);
} else {
cell->push_back(MathAtom(new InsetMathChar(t.character())));
else if (t.cat() == catBegin) {
- MathArray ar;
+ MathData ar;
parse(ar, FLAG_BRACE_LAST, mode);
// do not create a BraceInset if they were written by LyX
// this helps to keep the annoyance of "a choose b" to a minimum
}
- MathArray ar1;
+ MathData ar1;
parse(ar1, FLAG_ITEM, InsetMath::UNDECIDED_MODE);
// we cannot handle recursive stuff at all
- //MathArray test;
+ //MathData test;
//test.push_back(createInsetMath(name));
//if (ar1.contains(test)) {
// error("we cannot handle recursive macros at all.");
// is a version for display attached?
skipSpaces();
- MathArray ar2;
+ MathData ar2;
if (nextToken().cat() == catBegin)
parse(ar2, FLAG_ITEM, InsetMath::MATH_MODE);
#if 0
else if (t.cs() == "multicolumn") {
// extract column count and insert dummy cells
- MathArray count;
+ MathData count;
parse(count, FLAG_ITEM, mode);
int cols = 1;
if (!extractNumber(count, cols)) {
grid.cellinfo(grid.index(cellrow, cellcol)).dummy_ = false;
// read special alignment
- MathArray align;
+ MathData align;
parse(align, FLAG_ITEM, mode);
//grid.cellinfo(grid.index(cellrow, cellcol)).align_ = extractString(align);
}
else if (t.cs() == "sqrt") {
- MathArray ar;
+ MathData ar;
parse(ar, FLAG_OPTION, mode);
if (ar.size()) {
cell->push_back(MathAtom(new InsetMathRoot));
// can't handle \|
// FIXME: fix this in InsetMathDelim itself!
docstring const l = tl.cs() == "|" ? from_ascii("Vert") : tl.asString();
- MathArray ar;
+ MathData ar;
parse(ar, FLAG_RIGHT, mode);
if (!good())
break;
else if (t.cs() == "label") {
// FIXME: This is swallowed in inline formulas
docstring label = parse_verbatim_item();
- MathArray ar;
+ MathData ar;
asArray(label, ar);
if (grid.asHullInset()) {
grid.asHullInset()->label(cellrow, label);
#if 0
else if (t.cs() == "infer") {
- MathArray ar;
+ MathData ar;
parse(ar, FLAG_OPTION, mode);
cell->push_back(createInsetMath(t.cs()));
parse2(cell->back(), FLAG_ITEM, mode, false);
//lyxerr << "default creation: m2: " << m << endl;
InsetMath::idx_type start = 0;
// this fails on \bigg[...\bigg]
- //MathArray opt;
+ //MathData opt;
//parse(opt, FLAG_OPTION, InsetMath::VERBATIM_MODE);
//if (opt.size()) {
// start = 1;
} // anonymous namespace
-void mathed_parse_cell(MathArray & ar, docstring const & str)
+void mathed_parse_cell(MathData & ar, docstring const & str)
{
Parser(str).parse(ar, 0, InsetMath::MATH_MODE);
}
-void mathed_parse_cell(MathArray & ar, istream & is)
+void mathed_parse_cell(MathData & ar, istream & is)
{
Parser(is).parse(ar, 0, InsetMath::MATH_MODE);
}
class MathAtom;
-class MathArray;
+class MathData;
class InsetMathGrid;
class Lexer;
void mathed_parse_normal(InsetMathGrid &, docstring const &);
/// parse a single cell from a string
-void mathed_parse_cell(MathArray & ar, docstring const &);
+void mathed_parse_cell(MathData & ar, docstring const &);
/// parse a single cell from a stream. Only use this for reading from .lyx
/// file format, for the reason see Parser::tokenize(std::istream &).
-void mathed_parse_cell(MathArray & ar, std::istream &);
+void mathed_parse_cell(MathData & ar, std::istream &);
void initParser();
#include <config.h>
#include "InsetMath.h"
-#include "MathArray.h"
+#include "MathData.h"
#include "MathExtern.h"
#include "MathStream.h"
}
-NormalStream & operator<<(NormalStream & ns, MathArray const & ar)
+NormalStream & operator<<(NormalStream & ns, MathData const & ar)
{
normalize(ar, ns);
return ns;
}
-WriteStream & operator<<(WriteStream & ws, MathArray const & ar)
+WriteStream & operator<<(WriteStream & ws, MathData const & ar)
{
write(ar, ws);
return ws;
}
-MathStream & operator<<(MathStream & ms, MathArray const & ar)
+MathStream & operator<<(MathStream & ms, MathData const & ar)
{
mathmlize(ar, ms);
return ms;
}
-MapleStream & operator<<(MapleStream & ms, MathArray const & ar)
+MapleStream & operator<<(MapleStream & ms, MathData const & ar)
{
maple(ar, ms);
return ms;
}
-MaximaStream & operator<<(MaximaStream & ms, MathArray const & ar)
+MaximaStream & operator<<(MaximaStream & ms, MathData const & ar)
{
maxima(ar, ms);
return ms;
}
-MathematicaStream & operator<<(MathematicaStream & ms, MathArray const & ar)
+MathematicaStream & operator<<(MathematicaStream & ms, MathData const & ar)
{
mathematica(ar, ms);
return ms;
}
-OctaveStream & operator<<(OctaveStream & ns, MathArray const & ar)
+OctaveStream & operator<<(OctaveStream & ns, MathData const & ar)
{
octave(ar, ns);
return ns;
namespace lyx {
-class MathArray;
+class MathData;
class InsetMath;
class MathAtom;
odocstream & os_;
/// do we have to write \\protect sometimes
bool fragile_;
- /// are we at the beginning of an MathArray?
+ /// are we at the beginning of an MathData?
bool firstitem_;
/// are we writing to .tex?
int latex_;
///
WriteStream & operator<<(WriteStream &, MathAtom const &);
///
-WriteStream & operator<<(WriteStream &, MathArray const &);
+WriteStream & operator<<(WriteStream &, MathData const &);
///
WriteStream & operator<<(WriteStream &, docstring const &);
///
///
MathStream & operator<<(MathStream &, MathAtom const &);
///
-MathStream & operator<<(MathStream &, MathArray const &);
+MathStream & operator<<(MathStream &, MathData const &);
///
MathStream & operator<<(MathStream &, docstring const &);
///
///
NormalStream & operator<<(NormalStream &, MathAtom const &);
///
-NormalStream & operator<<(NormalStream &, MathArray const &);
+NormalStream & operator<<(NormalStream &, MathData const &);
///
NormalStream & operator<<(NormalStream &, docstring const &);
///
///
MapleStream & operator<<(MapleStream &, MathAtom const &);
///
-MapleStream & operator<<(MapleStream &, MathArray const &);
+MapleStream & operator<<(MapleStream &, MathData const &);
///
MapleStream & operator<<(MapleStream &, docstring const &);
///
///
MaximaStream & operator<<(MaximaStream &, MathAtom const &);
///
-MaximaStream & operator<<(MaximaStream &, MathArray const &);
+MaximaStream & operator<<(MaximaStream &, MathData const &);
///
MaximaStream & operator<<(MaximaStream &, docstring const &);
///
///
MathematicaStream & operator<<(MathematicaStream &, MathAtom const &);
///
-MathematicaStream & operator<<(MathematicaStream &, MathArray const &);
+MathematicaStream & operator<<(MathematicaStream &, MathData const &);
///
MathematicaStream & operator<<(MathematicaStream &, docstring const &);
///
///
OctaveStream & operator<<(OctaveStream &, MathAtom const &);
///
-OctaveStream & operator<<(OctaveStream &, MathArray const &);
+OctaveStream & operator<<(OctaveStream &, MathData const &);
///
OctaveStream & operator<<(OctaveStream &, docstring const &);
///
#include <config.h>
#include "MathSupport.h"
-#include "MathArray.h"
+#include "MathData.h"
#include "InsetMath.h"
#include "MathStream.h"
#include "MathParser.h"
}
-docstring asString(MathArray const & ar)
+docstring asString(MathData const & ar)
{
odocstringstream os;
WriteStream ws(os);
}
-void asArray(docstring const & str, MathArray & ar)
+void asArray(docstring const & str, MathData & ar)
{
mathed_parse_cell(ar, str);
}
class PainterInfo;
class LyXFont;
class Dimension;
-class MathArray;
+class MathData;
class MathAtom;
class InsetMath;
bool isFontName(docstring const & name);
// converts single cell to string
-docstring asString(MathArray const & ar);
+docstring asString(MathData const & ar);
// converts single inset to string
docstring asString(InsetMath const &);
docstring asString(MathAtom const &);
// converts string to single cell
-void asArray(docstring const & str, MathArray & ar);
+void asArray(docstring const & str, MathData & ar);
} // namespace lyx
#define MATH_REPLACE_H
-#include "MathArray.h"
+#include "MathData.h"
namespace lyx {
class ReplaceData {
public:
///
- MathArray from;
+ MathData from;
///
- MathArray to;
+ MathData to;
};