lyxerr << "calling: " << full << "\n";
Systemcalls dummy(Systemcalls::System, full, 0);
string out = GetFileContents(outfile);
+ lyx::unlink(outfile);
lyxerr << "result: '" << out << "'\n";
return out;
}
void MathAtom::operator=(MathAtom const & p)
{
- if (this != &p) {
- done();
- copy(p);
- }
+ if (this == &p)
+ return;
+ done();
+ copy(p);
}
}
-bool MathAtom::hasNucleus() const
-{
- return nucleus_;
-}
-
-
MathInset * MathAtom::operator->() const
{
return nucleus();
///
void reset(MathInset * p);
///
- bool hasNucleus() const;
- ///
MathInset * nucleus() const;
///
MathInset * operator->() const;
selHandle(sel);
if (!selection_) {
- // check whether we could move into a superscript
- if (hasPrevAtom()) {
- MathAtom & p = prevAtom();
- if (p->asScriptInset() && p->asScriptInset()->hasUp()) {
- pushRight(p);
- idx() = 1;
- pos() = size();
- return true;
- }
+ MathInset::idx_type i = 0;
+ MathInset::pos_type p = 0;
+
+ // check whether we could move into the inset
+ if (hasPrevAtom() && prevAtom()->idxLastUp(i, p)) {
+ pushRight(prevAtom());
+ idx() = i;
+ pos() = p;
+ return true;
}
- if (hasNextAtom()) {
- MathAtom & n = nextAtom();
- if (n->asScriptInset() && n->asScriptInset()->hasUp()) {
- pushLeft(n);
- idx() = 1;
- pos() = 0;
- return true;
- }
+ if (hasNextAtom() && nextAtom()->idxFirstUp(i, p)) {
+ pushLeft(nextAtom());
+ idx() = i;
+ pos() = p;
+ return true;
}
}
selHandle(sel);
if (!selection_) {
- // check whether we could move into a subscript
- if (hasPrevAtom()) {
- MathAtom & p = prevAtom();
- if (p->asScriptInset() && p->asScriptInset()->hasDown()) {
- pushRight(p);
- idx() = 0;
- pos() = size();
- return true;
- }
+ MathInset::idx_type i = 0;
+ MathInset::pos_type p = 0;
+
+ // check whether we could move into the inset
+ if (hasPrevAtom() && prevAtom()->idxLastDown(i, p)) {
+ pushRight(prevAtom());
+ idx() = i;
+ pos() = p;
+ return true;
}
- if (hasNextAtom()) {
- MathAtom & n = nextAtom();
- if (n->asScriptInset() && n->asScriptInset()->hasDown()) {
- pushLeft(n);
- idx() = 0;
- pos() = 0;
- return true;
- }
+ if (hasNextAtom() && nextAtom()->idxFirstDown(i, p)) {
+ pushLeft(nextAtom());
+ idx() = i;
+ pos() = p;
+ return true;
}
}
return true;
}
+ // does the inset know
+
// if not, apply brute force.
int x0;
int y0;
MathExIntInset::MathExIntInset(string const & name)
- : MathNestInset(2), symbol_(name)
+ : MathNestInset(2), symbol_(name), scripts_(new MathScriptInset)
{}
bool MathExIntInset::hasScripts() const
{
- return scripts_.hasNucleus();
+ // take empty upper bound as "no scripts"
+ return !scripts_->asScriptInset()->up().data_.empty();
}
{
os << '[' << symbol_.c_str() << ' ' << cell(0) << ' ' << cell(1);
if (hasScripts())
- os << scripts_.nucleus();
+ os << ' ' << scripts_.nucleus();
os << ']';
}
return;
lyxerr << "\nFunctions from: " << ar << "\n";
- for (MathArray::size_type i = 0; i < ar.size() - 1; ++i) {
+ for (MathArray::size_type i = 0; i + 1 < ar.size(); ++i) {
MathArray::iterator it = ar.begin() + i;
- // is this a function name?
+ // is this a well known function name?
MathFuncInset * func = (*it)->asFuncInset();
- if (!func)
+ string name;
+ if (func)
+ name = func->name();
+ else {
+ // is this a user defined function?
+ // guess so, if this is a "string" and it is followed by
+ // a DelimInset
+ //name = extractString((*it)->nucleus());
+ //if (name.size() && it + 1
+ //if ((*it
+ // FIXME
continue;
+ }
// do we have an exponent?
// simply skippping the postion does the right thing:
}
// create a proper inset as replacement
- MathExFuncInset * p = new MathExFuncInset(func->name());
+ MathExFuncInset * p = new MathExFuncInset(name);
// jt points to the "argument". Get hold of this.
MathArray::iterator st = extractArgument(p->cell(0), jt, ar.end());
return;
lyxerr << "\nIntegrals from: " << ar << "\n";
- for (MathArray::size_type i = 0; i < ar.size() - 1; ++i) {
+ for (MathArray::size_type i = 0; i + 1< ar.size(); ++i) {
MathArray::iterator it = ar.begin() + i;
// is this a integral name?
return;
lyxerr << "\nSums from: " << ar << "\n";
- for (MathArray::size_type i = 0; i < ar.size() - 1; ++i) {
+ for (MathArray::size_type i = 0; i + 1< ar.size(); ++i) {
MathArray::iterator it = ar.begin() + i;
// is this a sum name?
} else {
// use everything as summation index, don't use scripts.
p->cell(1) = ar;
- p->scripts().reset(0);
}
}
}
void extractDiff(MathArray & ar)
{
lyxerr << "\nDiffs from: " << ar << "\n";
- for (MathArray::size_type i = 0; i < ar.size() - 1; ++i) {
+ for (MathArray::size_type i = 0; i < ar.size(); ++i) {
MathArray::iterator it = ar.begin() + i;
// is this a "differential fraction"?
// create a proper diff inset
MathDiffInset * p = new MathDiffInset;
- // collect function
+ // collect function, let jt point behind last used item
MathArray::iterator jt = it + 1;
- if (f->cell(0).size() > 1)
- p->cell(0) = MathArray(f->cell(0).begin() + 1, f->cell(0).end());
- else
- jt = extractArgument(p->cell(0), jt, ar.end());
-
+ int n = 1;
+ MathArray & numer = f->cell(0);
+ if (numer.size() > 1 && numer.at(1)->asScriptInset()) {
+ // this is something like d^n f(x) / d... or d^n / d...
+ n = 1; // FIXME
+ if (numer.size() > 2)
+ p->cell(0) = MathArray(numer.begin() + 2, numer.end());
+ else
+ jt = extractArgument(p->cell(0), jt, ar.end());
+ } else {
+ // simply d f(x) / d... or d/d...
+ if (numer.size() > 1)
+ p->cell(0) = MathArray(numer.begin() + 1, numer.end());
+ else
+ jt = extractArgument(p->cell(0), jt, ar.end());
+ }
+
// collect denominator
-
+ MathArray & denom = f->cell(1);
+ for (MathArray::iterator dt = denom.begin(); dt + 1 != denom.end(); ) {
+ if (!diffItemTest((*dt).nucleus())) {
+ lyxerr << "extractDiff: should not happen 2\n";
+ return;
+ }
+ MathArray diff;
+ dt = extractArgument(diff, dt + 1, denom.end());
+ p->addDer(diff);
+ // safeguard
+ if (dt == denom.end())
+ break;
+ }
// cleanup
ar.erase(it + 1, jt);
}
+bool MathFracbaseInset::idxFirstUp(idx_type & idx, pos_type & pos) const
+{
+ idx = 0;
+ pos = 0;
+ return true;
+}
+
+
+bool MathFracbaseInset::idxFirstDown(idx_type & idx, pos_type & pos) const
+{
+ idx = 1;
+ pos = 0;
+ return true;
+}
+
+
+bool MathFracbaseInset::idxLastUp(idx_type & idx, pos_type & pos) const
+{
+ idx = 0;
+ pos = cell(0).size();
+ return true;
+}
+
+
+bool MathFracbaseInset::idxLastDown(idx_type & idx, pos_type & pos) const
+{
+ idx = 1;
+ pos = cell(1).size();
+ return true;
+}
+
+
bool MathFracbaseInset::idxUp(MathInset::idx_type & idx,
MathInset::pos_type & pos) const
{
///
MathFracbaseInset();
///
- bool idxUp(MathInset::idx_type &, MathInset::pos_type &) const;
+ bool idxUp(idx_type &, pos_type &) const;
///
- bool idxDown(MathInset::idx_type &, MathInset::pos_type &) const;
+ bool idxDown(idx_type &, pos_type &) const;
///
- bool idxLeft(MathInset::idx_type &, MathInset::pos_type &) const;
+ bool idxLeft(idx_type &, pos_type &) const;
///
- bool idxRight(MathInset::idx_type &, MathInset::pos_type &) const;
+ bool idxRight(idx_type &, pos_type &) const;
+ ///
+ bool idxFirstUp(idx_type &, pos_type &) const;
+ ///
+ bool idxFirstDown(idx_type &, pos_type &) const;
+ ///
+ bool idxLastUp(idx_type &, pos_type &) const;
+ ///
+ bool idxLastDown(idx_type &, pos_type &) const;
};
#endif
}
+bool MathInset::idxFirstUp(idx_type &, pos_type &) const
+{
+ return false;
+}
+
+
+bool MathInset::idxFirstDown(idx_type &, pos_type &) const
+{
+ return false;
+}
+
+
bool MathInset::idxLast(idx_type &, pos_type &) const
{
return false;
}
+bool MathInset::idxLastUp(idx_type &, pos_type &) const
+{
+ return false;
+}
+
+
+bool MathInset::idxLastDown(idx_type &, pos_type &) const
+{
+ return false;
+}
+
+
bool MathInset::idxHome(idx_type &, pos_type &) const
{
return false;
/// Target pos when we enter the inset from the left by pressing "Right"
virtual bool idxFirst(idx_type & idx, pos_type & pos) const;
+ /// Target pos when we enter the inset from the left by pressing "Up"
+ virtual bool idxFirstUp(idx_type & idx, pos_type & pos) const;
+ /// Target pos when we enter the inset from the left by pressing "Down"
+ virtual bool idxFirstDown(idx_type & idx, pos_type & pos) const;
/// Target pos when we enter the inset from the right by pressing "Left"
virtual bool idxLast(idx_type & idx, pos_type & pos) const;
+ /// Target pos when we enter the inset from the right by pressing "Up"
+ virtual bool idxLastUp(idx_type & idx, pos_type & pos) const;
+ /// Target pos when we enter the inset from the right by pressing "Down"
+ virtual bool idxLastDown(idx_type & idx, pos_type & pos) const;
/// Where should we go if we press home?
virtual bool idxHome(idx_type & idx, pos_type & pos) const;
}
+bool MathScriptInset::idxFirstUp(idx_type & idx, pos_type & pos) const
+{
+ if (!hasUp())
+ return false;
+ idx = 1;
+ pos = 0;
+ return true;
+}
+
+
+bool MathScriptInset::idxFirstDown(idx_type & idx, pos_type & pos) const
+{
+ if (!hasDown())
+ return false;
+ idx = 0;
+ pos = 0;
+ return true;
+}
+
+
+bool MathScriptInset::idxLastUp(idx_type & idx, pos_type & pos) const
+{
+ if (!hasUp())
+ return false;
+ idx = 1;
+ pos = up().data_.size();
+ return true;
+}
+
+
+bool MathScriptInset::idxLastDown(idx_type & idx, pos_type & pos) const
+{
+ if (!hasDown())
+ return false;
+ idx = 0;
+ pos = down().data_.size();
+ return true;
+}
+
+
void MathScriptInset::write(WriteStream & os) const
{
//lyxerr << "unexpected call to MathScriptInset::write()\n";
int width(MathInset const * nuc) const;
///
- bool idxLeft(MathInset::idx_type &, MathInset::pos_type &) const;
+ bool idxLeft(idx_type &, pos_type &) const;
///
- bool idxRight(MathInset::idx_type &, MathInset::pos_type &) const;
+ bool idxRight(idx_type &, pos_type &) const;
+ ///
+ bool idxFirstUp(idx_type &, pos_type &) const;
+ ///
+ bool idxFirstDown(idx_type &, pos_type &) const;
+ ///
+ bool idxLastUp(idx_type &, pos_type &) const;
+ ///
+ bool idxLastDown(idx_type &, pos_type &) const;
///
MathScriptInset const * asScriptInset() const;