]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_nestinset.C
use stream-like syntax for LaTeX output
[lyx.git] / src / mathed / math_nestinset.C
index ebe624c0447830962a2ce9e4a4532726961ccbb6..9b8a411002adc960bb51ce5d94f350d6de3b2f1f 100644 (file)
@@ -6,53 +6,52 @@
 #include "debug.h"
 
 
-MathNestInset::MathNestInset(int nargs)
+MathNestInset::MathNestInset(idx_type nargs)
        : MathDimInset(), cells_(nargs)
 {}
 
 
-int MathNestInset::nargs() const
+MathInset::idx_type MathNestInset::nargs() const
 {
        return cells_.size();
 }
 
 
-MathXArray & MathNestInset::xcell(int i)
+MathXArray & MathNestInset::xcell(idx_type i)
 {
        return cells_[i];
 }
 
 
-MathXArray const & MathNestInset::xcell(int i) const
+MathXArray const & MathNestInset::xcell(idx_type i) const
 {
        return cells_[i];
 }
 
 
-MathArray & MathNestInset::cell(int i)
+MathArray & MathNestInset::cell(idx_type i)
 {
        return cells_[i].data_;
 }
 
 
-MathArray const & MathNestInset::cell(int i) const
+MathArray const & MathNestInset::cell(idx_type i) const
 {
        return cells_[i].data_;
 }
 
 
-void MathNestInset::substitute(MathArray & array, MathMacro const & m) const
+void MathNestInset::substitute(MathMacro const & m)
 {
-       array.push_back(clone());
-       for (int i = 0; i < nargs(); ++i)
-               array.back()->cell(i).substitute(m);
+       for (idx_type i = 0; i < nargs(); ++i)
+               cell(i).substitute(m);
 }
 
 
-void MathNestInset::metrics(MathStyles st) const
+void MathNestInset::metrics(MathMetricsInfo const & st) const
 {
        size_ = st;
-       for (int i = 0; i < nargs(); ++i)
+       for (idx_type i = 0; i < nargs(); ++i)
                xcell(i).metrics(st);
 }
 
@@ -61,12 +60,12 @@ void MathNestInset::draw(Painter & pain, int x, int y) const
 {
        xo(x);
        yo(y);
-       for (int i = 0; i < nargs(); ++i)
+       for (idx_type i = 0; i < nargs(); ++i)
                xcell(i).draw(pain, x + xcell(i).xo(), y + xcell(i).yo());
 }
 
 
-bool MathNestInset::idxNext(int & idx, int & pos) const
+bool MathNestInset::idxNext(idx_type & idx, pos_type & pos) const
 {
        if (idx + 1 >= nargs())
                return false;
@@ -76,13 +75,13 @@ bool MathNestInset::idxNext(int & idx, int & pos) const
 }
 
 
-bool MathNestInset::idxRight(int & idx, int & pos) const
+bool MathNestInset::idxRight(idx_type & idx, pos_type & pos) const
 {
        return idxNext(idx, pos);
 }
 
 
-bool MathNestInset::idxPrev(int & idx, int & pos) const
+bool MathNestInset::idxPrev(idx_type & idx, pos_type & pos) const
 {
        if (idx == 0)
                return false;
@@ -92,13 +91,13 @@ bool MathNestInset::idxPrev(int & idx, int & pos) const
 }
 
 
-bool MathNestInset::idxLeft(int & idx, int & pos) const
+bool MathNestInset::idxLeft(idx_type & idx, pos_type & pos) const
 {
        return idxPrev(idx, pos);
 }
 
 
-bool MathNestInset::idxFirst(int & i, int & pos) const
+bool MathNestInset::idxFirst(idx_type & i, pos_type & pos) const
 {
        if (nargs() == 0)
                return false;
@@ -108,7 +107,7 @@ bool MathNestInset::idxFirst(int & i, int & pos) const
 }
 
 
-bool MathNestInset::idxLast(int & i, int & pos) const
+bool MathNestInset::idxLast(idx_type & i, pos_type & pos) const
 {
        if (nargs() == 0)
                return false;
@@ -118,7 +117,7 @@ bool MathNestInset::idxLast(int & i, int & pos) const
 }
 
 
-bool MathNestInset::idxHome(int & /* idx */, int & pos) const
+bool MathNestInset::idxHome(idx_type & /* idx */, pos_type & pos) const
 {
        if (pos == 0)
                return false;
@@ -127,31 +126,33 @@ bool MathNestInset::idxHome(int & /* idx */, int & pos) const
 }
 
 
-bool MathNestInset::idxEnd(int & idx, int & pos) const
+bool MathNestInset::idxEnd(idx_type & idx, pos_type & pos) const
 {
-       if (pos == cell(idx).size())
+       pos_type n = cell(idx).size();
+       if (pos == n)
                return false;
 
-       pos = cell(idx).size();
+       pos = n;
        return true;
 }
 
 
 void MathNestInset::dump() const
 {
-       lyxerr << "---------------------------------------------\n";
-       write(lyxerr, false);
-       lyxerr << "\n";
-       for (int i = 0; i < nargs(); ++i)
-               lyxerr << cell(i) << "\n";
-       lyxerr << "---------------------------------------------\n";
+       MathWriteInfo os(lyxerr);
+       os << "---------------------------------------------\n";
+       write(os);
+       os << "\n";
+       for (idx_type i = 0; i < nargs(); ++i)
+               os << cell(i) << "\n";
+       os << "---------------------------------------------\n";
 }
 
 
-void MathNestInset::push_back(MathInset * p)
+void MathNestInset::push_back(MathAtom const & t)
 {
        if (nargs())
-               cells_.back().data_.push_back(p);
+               cells_.back().data_.push_back(t);
        else
                lyxerr << "can't push without a cell\n";
 }
@@ -159,6 +160,6 @@ void MathNestInset::push_back(MathInset * p)
 
 void MathNestInset::validate(LaTeXFeatures & features) const
 {
-       for (int i = 0; i < nargs(); ++i)
+       for (idx_type i = 0; i < nargs(); ++i)
                cell(i).validate(features);
 }