if (display()) {
bv->lockedInsetStoreUndo(Undo::INSERT);
bool old = par_->numberedType();
- for (int row = 0; row < par_->nrows(); ++row)
+ for (unsigned int row = 0; row < par_->nrows(); ++row)
par_->numbered(row, !old);
bv->owner()->message(old ? _("No number") : _("Number"));
updateLocal(bv, true);
// returns the nearest enclosing grid
-MathArrayInset * matrixpar(int & idx)
+MathArrayInset * matrixpar(unsigned int & idx)
{
idx = 0;
return (mathcursor ? mathcursor->enclosingArray(idx) : 0);
{
bv->lockedInsetStoreUndo(Undo::INSERT);
lyxerr << "handling halign '" << arg << "'\n";
- int idx;
+ unsigned int idx;
MathArrayInset * p = matrixpar(idx);
if (!p)
break;
{
bv->lockedInsetStoreUndo(Undo::INSERT);
lyxerr << "handling valign '" << arg << "'\n";
- int idx;
+ unsigned int idx;
MathArrayInset * p = matrixpar(idx);
if (!p)
break;
case LFUN_MATH_ROW_INSERT:
{
bv->lockedInsetStoreUndo(Undo::INSERT);
- int idx;
+ unsigned int idx;
MathArrayInset * p = matrixpar(idx);
lyxerr << " calling LFUN_MATH_ROW_INSERT on " << p << endl;
if (!p)
case LFUN_MATH_ROW_DELETE:
{
bv->lockedInsetStoreUndo(Undo::INSERT);
- int idx;
+ unsigned int idx;
MathArrayInset * p = matrixpar(idx);
lyxerr << " calling LFUN_MATH_ROW_DELETE on " << p << endl;
if (!p)
case LFUN_MATH_COLUMN_INSERT:
{
bv->lockedInsetStoreUndo(Undo::INSERT);
- int idx;
+ unsigned int idx;
MathArrayInset * p = matrixpar(idx);
if (!p)
break;
case LFUN_MATH_COLUMN_DELETE:
{
bv->lockedInsetStoreUndo(Undo::INSERT);
- int idx;
+ unsigned int idx;
MathArrayInset * p = matrixpar(idx);
if (!p)
break;
os << '[' << char(v_align_) << ']';
os << '{';
- for (int col = 0; col < ncols(); ++col)
+ for (unsigned int col = 0; col < ncols(); ++col)
os << colinfo_[col].align_;
os << "}\n";
#include "math_specialcharinset.h"
#include "math_parser.h"
+#define FILEDEBUG 0
+
using std::endl;
using std::min;
using std::max;
using std::swap;
using std::isalnum;
-
namespace {
struct Selection
if (i1.idx_ == i2.idx_)
data_.push_back(MathArray(i1.cell(), i1.pos_, i2.pos_));
else {
- std::vector<int> indices = i1.par_->idxBetween(i1.idx_, i2.idx_);
+ std::vector<unsigned int> indices = i1.par_->idxBetween(i1.idx_, i2.idx_);
for (unsigned i = 0; i < indices.size(); ++i)
data_.push_back(i1.cell(indices[i]));
}
if (i1.idx_ == i2.idx_)
i1.cell().erase(i1.pos_, i2.pos_);
else {
- std::vector<int> indices = i1.par_->idxBetween(i1.idx_, i2.idx_);
+ std::vector<unsigned int> indices = i1.par_->idxBetween(i1.idx_, i2.idx_);
for (unsigned i = 0; i < indices.size(); ++i)
i1.cell(indices[i]).erase();
}
Selection theSelection;
+#if FILEDEBUG
std::ostream & operator<<(std::ostream & os, MathCursorPos const & p)
{
os << "(par: " << p.par_ << " idx: " << p.idx_
<< " pos: " << p.pos_ << ")";
return os;
}
+#endif
}
}
+#if FILEDEBUG
void MathCursor::dump(char const *) const
{
-#if 0
lyxerr << "MC: " << what << "\n";
for (unsigned i = 0; i < Cursor_.size(); ++i)
lyxerr << " i: " << i
<< " idx: " << Cursor_[i].idx_
<< " par: " << Cursor_[i].par_ << "\n";
//lyxerr << " sel: " << selection_ << " data: " << array() << "\n";
-#endif
}
-
void MathCursor::seldump(char const * str) const
{
//lyxerr << "SEL: " << str << ": '" << theSelection << "'\n";
//dump(" Pos");
- return;
lyxerr << "\n\n\n=================vvvvvvvvvvvvv======================= "
<< str << "\ntheSelection: " << selection_
lyxerr << "\n===================^^^^^^^^^^^^=====================\n\n\n";
}
+#else
+
+void MathCursor::seldump(char const *) const {}
+void MathCursor::dump(char const *) const {}
+
+#endif
+
bool MathCursor::isInside(MathInset const * p) const
{
cursor().par_ = outerPar();
while (1) {
- idx() = -1;
- cursor().pos_ = -1;
+ idx() = 0;
+ cursor().pos_ = 0;
//lyxerr << "found idx: " << idx() << " cursor: " << pos() << "\n";
int distmin = 1 << 30; // large enough
- for (int i = 0; i < par()->nargs(); ++i) {
+ for (unsigned int i = 0; i < par()->nargs(); ++i) {
MathXArray const & ar = par()->xcell(i);
int x1 = x - ar.xo();
int y1 = y - ar.yo();
int y2 = c.yo() + c.descent();
pain.fillRectangle(x1, y1, x2 - x1, y2 - y1, LColor::selection);
} else {
- std::vector<int> indices = i1.par_->idxBetween(i1.idx_, i2.idx_);
+ std::vector<unsigned int> indices = i1.par_->idxBetween(i1.idx_, i2.idx_);
for (unsigned i = 0; i < indices.size(); ++i) {
MathXArray & c = i1.xcell(indices[i]);
int x1 = c.xo();
getSelection(i1, i2);
if (i1.idx_ == i2.idx_) {
MathArray & ar = i1.cell();
- for (int pos = i1.pos_; pos != i2.pos_; ++pos) {
+ for (unsigned int pos = i1.pos_; pos != i2.pos_; ++pos) {
MathInset * p = ar.at(pos)->nucleus();
if (p)
p->handleFont(t);
}
-int MathCursor::idx() const
+unsigned int MathCursor::idx() const
{
return cursor().idx_;
}
-int & MathCursor::idx()
+unsigned int & MathCursor::idx()
{
return cursor().idx_;
}
-int MathCursor::pos() const
+unsigned int MathCursor::pos() const
{
return cursor().pos_;
}
-int & MathCursor::pos()
+unsigned int & MathCursor::pos()
{
return cursor().pos_;
}
}
-MathArrayInset * MathCursor::enclosingArray(int & idx) const
+MathArrayInset * MathCursor::enclosingArray(unsigned int & idx) const
{
for (int i = Cursor_.size() - 1; i >= 0; --i) {
if (Cursor_[i].par_->isArray()) {
#endif
MathCursor * it = const_cast<MathCursor *>(this);
- if (idx() < 0)
- lyxerr << "this should not really happen - 1: " << idx() << "\n";
if (idx() >= par()->nargs()) {
- lyxerr << "this should not really happen - 2: "
+ lyxerr << "this should not really happen - 1: "
<< idx() << " " << par()->nargs() << "\n";
dump("error 2");
}
- it->idx() = max(idx(), 0);
it->idx() = min(idx(), par()->nargs() - 1);
- if (pos() < 0)
- lyxerr << "this should not really happen - 3: " << pos() << "\n";
if (pos() > size()) {
- lyxerr << "this should not really happen - 4: "
+ lyxerr << "this should not really happen - 2: "
<< pos() << " " << size() << "\n";
dump("error 4");
}
- it->pos() = max(pos(), 0);
it->pos() = min(pos(), size());
}
-int MathCursor::size() const
+unsigned int MathCursor::size() const
{
return array().size();
}
-int MathCursor::col() const
+unsigned int MathCursor::col() const
{
return par()->col(idx());
}
-int MathCursor::row() const
+unsigned int MathCursor::row() const
{
return par()->row(idx());
}
return dummy;
}
- if (idx() < 0 || idx() >= par()->nargs()) {
+ if (idx() >= par()->nargs()) {
lyxerr << "############ idx_ " << idx() << " not valid\n";
return dummy;
}
p->addRow(row());
// split line
- const int r = row();
- for (int c = col() + 1; c < p->ncols(); ++c) {
- const int i1 = p->index(r, c);
- const int i2 = p->index(r + 1, c);
+ const unsigned int r = row();
+ for (unsigned int c = col() + 1; c < p->ncols(); ++c) {
+ const unsigned int i1 = p->index(r, c);
+ const unsigned int i2 = p->index(r + 1, c);
lyxerr << "swapping cells " << i1 << " and " << i2 << "\n";
p->cell(i1).swap(p->cell(i2));
}
char MathCursor::valign() const
{
- int idx;
+ unsigned int idx;
MathArrayInset * p = enclosingArray(idx);
return p ? p->valign() : 0;
}
char MathCursor::halign() const
{
- int idx;
+ unsigned int idx;
MathArrayInset * p = enclosingArray(idx);
return p ? p->halign(idx % p->ncols()) : 0;
}
}
-int MathCursor::cellXOffset() const
+unsigned int MathCursor::cellXOffset() const
{
return par()->cellXOffset(idx());
}
-int MathCursor::cellYOffset() const
+unsigned int MathCursor::cellYOffset() const
{
return par()->cellYOffset(idx());
}
//lyxerr << "trans: '" << c << "' int: " << int(c) << endl;
if (s.size() > 7 && s.substr(0, 7) == "matrix ") {
- int m = 1;
- int n = 1;
+ unsigned int m = 1;
+ unsigned int n = 1;
string v_align;
string h_align;
istringstream is(s.substr(7).c_str());
is >> m >> n >> v_align >> h_align;
- m = std::max(1, m);
- n = std::max(1, n);
+ m = std::max(1u, m);
+ n = std::max(1u, n);
v_align += 'c';
MathArrayInset * p = new MathArrayInset(m, n);
p->valign(v_align[0]);
}
-MathArray & MathCursorPos::cell(int idx) const
+MathArray & MathCursorPos::cell(unsigned int idx) const
{
return par_->cell(idx);
}
}
-MathXArray & MathCursorPos::xcell(int idx) const
+MathXArray & MathCursorPos::xcell(unsigned int idx) const
{
return par_->xcell(idx);
}
/// inset
MathInset * par_;
/// cell index
- int idx_;
+ unsigned int idx_;
/// cell position
- int pos_;
+ unsigned int pos_;
/// returns cell corresponding to this position
MathArray & cell() const;
/// returns cell corresponding to this position
- MathArray & cell(int idx) const;
+ MathArray & cell(unsigned int idx) const;
/// returns xcell corresponding to this position
MathXArray & xcell() const;
/// returns xcell corresponding to this position
- MathXArray & xcell(int idx) const;
+ MathXArray & xcell(unsigned int idx) const;
};
///
///
MathInset * par() const;
/// return the next enclosing grid inset and the cursor's index in it
- MathArrayInset * enclosingArray(int &) const;
+ MathArrayInset * enclosingArray(unsigned int &) const;
///
InsetFormulaBase const * formula();
///
- int pos() const;
+ unsigned int pos() const;
///
- int idx() const;
+ unsigned int idx() const;
///
- int size() const;
+ unsigned int size() const;
///
void interpret(string const &);
///
///
char halign() const;
///
- int col() const;
+ unsigned int col() const;
///
- int row() const;
+ unsigned int row() const;
///
MathStyles style() const;
///
- int last() const;
+ unsigned int last() const;
///
MathInset * parInset(int i) const;
///
/// can the setPos routine enter that inset?
MathInset * positionable(MathAtom *, int x, int y) const;
/// write access to cursor cell position
- int & pos();
+ unsigned int & pos();
/// write access to cursor cell index
- int & idx();
+ unsigned int & idx();
/// x-offset of current cell relative to par xo
- int cellXOffset() const;
+ unsigned int cellXOffset() const;
/// y-offset of current cell relative to par yo
- int cellYOffset() const;
+ unsigned int cellYOffset() const;
/// current x position relative to par xo
int xpos() const;
/// current y position relative to par yo
///
void draw(Painter &, int x, int y) const;
public:
- ///
- char const name() const;
-
///
const bool atop_;
};
{}
-MathGridInset::MathGridInset(int m, int n)
+MathGridInset::MathGridInset(unsigned int m, unsigned int n)
: MathNestInset(m * n), rowinfo_(n), colinfo_(m), v_align_('c')
{
if (m <= 0)
}
-int MathGridInset::index(int row, int col) const
+unsigned int MathGridInset::index(unsigned int row, unsigned int col) const
{
return col + ncols() * row;
}
void MathGridInset::setDefaults()
{
- for (int col = 0; col < ncols(); ++col) {
+ for (unsigned int col = 0; col < ncols(); ++col) {
colinfo_[col].align_ = defaultColAlign(col);
colinfo_[col].skip_ = defaultColSpace(col);
}
void MathGridInset::halign(string const & hh)
{
- int n = hh.size();
+ unsigned int n = hh.size();
if (n > ncols())
n = ncols();
- for (int i = 0; i < n; ++i)
+ for (unsigned int i = 0; i < n; ++i)
colinfo_[i].align_ = hh[i];
}
-void MathGridInset::halign(char h, int col)
+void MathGridInset::halign(char h, unsigned int col)
{
colinfo_[col].align_ = h;
}
-char MathGridInset::halign(int col) const
+char MathGridInset::halign(unsigned int col) const
{
return colinfo_[col].align_;
}
-void MathGridInset::vskip(LyXLength const & skip, int row)
+void MathGridInset::vskip(LyXLength const & skip, unsigned int row)
{
rowinfo_[row].skip_ = skip;
}
-LyXLength MathGridInset::vskip(int row) const
+LyXLength MathGridInset::vskip(unsigned int row) const
{
return rowinfo_[row].skip_;
}
size_ = st;
// adjust vertical structure
- for (int row = 0; row < nrows(); ++row) {
+ for (unsigned int row = 0; row < nrows(); ++row) {
int asc = 0;
int desc = 0;
- for (int col = 0; col < ncols(); ++col) {
+ for (unsigned int col = 0; col < ncols(); ++col) {
MathXArray const & c = xcell(index(row, col));
asc = std::max(asc, c.ascent());
desc = std::max(desc, c.descent());
h = rowinfo_.back().offset_ / 2;
}
- for (int row = 0; row < nrows(); ++row) {
+ for (unsigned int row = 0; row < nrows(); ++row) {
rowinfo_[row].offset_ -= h;
rowinfo_[row].offset_ += MATH_BORDER;
}
// adjust horizontal structure
- for (int col = 0; col < ncols(); ++col) {
+ for (unsigned int col = 0; col < ncols(); ++col) {
int wid = 0;
- for (int row = 0; row < nrows(); ++row)
+ for (unsigned int row = 0; row < nrows(); ++row)
wid = std::max(wid, xcell(index(row, col)).width());
colinfo_[col].width_ = wid;
colinfo_[col].offset_ = colinfo_[col].width_;
{
xo(x);
yo(y);
- for (int idx = 0; idx < nargs(); ++idx)
+ for (unsigned int idx = 0; idx < nargs(); ++idx)
xcell(idx).draw(pain, x + cellXOffset(idx), y + cellYOffset(idx));
}
void MathGridInset::write(std::ostream & os, bool fragile) const
{
- for (int row = 0; row < nrows(); ++row) {
- for (int col = 0; col < ncols(); ++col) {
+ for (unsigned int row = 0; row < nrows(); ++row) {
+ for (unsigned int col = 0; col < ncols(); ++col) {
cell(index(row, col)).write(os, fragile);
os << eocString(col);
}
}
-string MathGridInset::eolString(int row) const
+string MathGridInset::eolString(unsigned int row) const
{
- if (row == nrows() - 1)
+ if (row + 1 == nrows())
return "";
if (rowinfo_[row].skip_.value() != 0)
}
-string MathGridInset::eocString(int col) const
+string MathGridInset::eocString(unsigned int col) const
{
- if (col == ncols() - 1)
+ if (col + 1 == ncols())
return "";
return " & ";
}
-void MathGridInset::addRow(int row)
+void MathGridInset::addRow(unsigned int row)
{
rowinfo_.insert(rowinfo_.begin() + row + 1, RowInfo());
cells_.insert(cells_.begin() + (row + 1) * ncols(), ncols(), MathXArray());
void MathGridInset::appendRow()
{
rowinfo_.push_back(RowInfo());
- for (int i = 0; i < ncols(); ++i)
+ for (unsigned int i = 0; i < ncols(); ++i)
cells_.push_back(cells_type::value_type());
}
-void MathGridInset::delRow(int row)
+void MathGridInset::delRow(unsigned int row)
{
if (nrows() == 1)
return;
}
-void MathGridInset::addCol(int newcol)
+void MathGridInset::addCol(unsigned int newcol)
{
- int const nc = ncols();
- int const nr = nrows();
+ unsigned int const nc = ncols();
+ unsigned int const nr = nrows();
cells_type new_cells((nc + 1) * nr);
- for (int row = 0; row < nr; ++row)
- for (int col = 0; col < nc; ++col)
+ for (unsigned int row = 0; row < nr; ++row)
+ for (unsigned int col = 0; col < nc; ++col)
new_cells[row * (nc + 1) + col + (col > newcol)]
= cells_[row * nc + col];
std::swap(cells_, new_cells);
}
-void MathGridInset::delCol(int col)
+void MathGridInset::delCol(unsigned int col)
{
if (ncols() == 1)
return;
cells_type tmpcells;
- for (int i = 0; i < nargs(); ++i)
+ for (unsigned int i = 0; i < nargs(); ++i)
if (i % ncols() != col)
tmpcells.push_back(cells_[i]);
std::swap(cells_, tmpcells);
}
-int MathGridInset::cellXOffset(int idx) const
+int MathGridInset::cellXOffset(unsigned int idx) const
{
- int c = col(idx);
+ unsigned int c = col(idx);
int x = colinfo_[c].offset_;
char align = colinfo_[c].align_;
if (align == 'r' || align == 'R')
}
-int MathGridInset::cellYOffset(int idx) const
+int MathGridInset::cellYOffset(unsigned int idx) const
{
return rowinfo_[row(idx)].offset_;
}
-bool MathGridInset::idxUp(int & idx, int & pos) const
+bool MathGridInset::idxUp(unsigned int & idx, unsigned int & pos) const
{
if (idx < ncols())
return false;
}
-bool MathGridInset::idxDown(int & idx, int & pos) const
+bool MathGridInset::idxDown(unsigned int & idx, unsigned int & pos) const
{
if (idx >= ncols() * (nrows() - 1))
return false;
}
-bool MathGridInset::idxLeft(int & idx, int & pos) const
+bool MathGridInset::idxLeft(unsigned int & idx, unsigned int & pos) const
{
// leave matrix if on the left hand edge
if (col(idx) == 0)
}
-bool MathGridInset::idxRight(int & idx, int & pos) const
+bool MathGridInset::idxRight(unsigned int & idx, unsigned int & pos) const
{
// leave matrix if on the right hand edge
if (col(idx) == ncols() - 1)
}
-bool MathGridInset::idxFirst(int & idx, int & pos) const
+bool MathGridInset::idxFirst(unsigned int & idx, unsigned int & pos) const
{
switch (v_align_) {
case 't':
}
-bool MathGridInset::idxLast(int & idx, int & pos) const
+bool MathGridInset::idxLast(unsigned int & idx, unsigned int & pos) const
{
switch (v_align_) {
case 't':
}
-void MathGridInset::idxDelete(int & idx, bool & popit, bool & deleteit)
+void MathGridInset::idxDelete(unsigned int & idx, bool & popit, bool & deleteit)
{
popit = false;
deleteit = false;
// delete entire row if in first cell of empty row
if (col(idx) == 0 && nrows() > 1) {
bool deleterow = true;
- for (int i = idx; i < idx + ncols(); ++i)
+ for (unsigned int i = idx; i < idx + ncols(); ++i)
if (cell(i).size()) {
deleterow = false;
break;
}
-void MathGridInset::idxDeleteRange(int /*from*/, int /*to*/)
+void MathGridInset::idxDeleteRange(unsigned int /*from*/, unsigned int /*to*/)
{
// leave this unimplemented unless someone wants to have it.
/*
}
-MathGridInset::RowInfo const & MathGridInset::rowinfo(int i) const
+MathGridInset::RowInfo const & MathGridInset::rowinfo(unsigned int i) const
{
return rowinfo_[i];
}
-MathGridInset::RowInfo & MathGridInset::rowinfo(int i)
+MathGridInset::RowInfo & MathGridInset::rowinfo(unsigned int i)
{
return rowinfo_[i];
}
-std::vector<int> MathGridInset::idxBetween(int from, int to) const
+std::vector<unsigned int>
+ MathGridInset::idxBetween(unsigned int from, unsigned int to) const
{
- int r1 = std::min(row(from), row(to));
- int r2 = std::max(row(from), row(to));
- int c1 = std::min(col(from), col(to));
- int c2 = std::max(col(from), col(to));
- std::vector<int> res;
- for (int i = r1; i <= r2; ++i)
- for (int j = c1; j <= c2; ++j)
+ unsigned int r1 = std::min(row(from), row(to));
+ unsigned int r2 = std::max(row(from), row(to));
+ unsigned int c1 = std::min(col(from), col(to));
+ unsigned int c2 = std::max(col(from), col(to));
+ std::vector<unsigned int> res;
+ for (unsigned int i = r1; i <= r2; ++i)
+ for (unsigned int j = c1; j <= c2; ++j)
res.push_back(index(i, j));
return res;
}
public:
///
- MathGridInset(int m, int n);
+ MathGridInset(unsigned int m, unsigned int n);
///
void write(std::ostream &, bool fragile) const;
///
///
void halign(string const &);
///
- void halign(char c, int col);
+ void halign(char c, unsigned int col);
///
- char halign(int col) const;
+ char halign(unsigned int col) const;
///
void valign(char c);
///
char valign() const;
///
- void vskip(LyXLength const &, int row);
+ void vskip(LyXLength const &, unsigned int row);
///
- LyXLength vskip(int row) const;
+ LyXLength vskip(unsigned int row) const;
///
- void resize(short int type, int cols);
+ void resize(short int type, unsigned int cols);
///
- const RowInfo & rowinfo(int row) const;
+ const RowInfo & rowinfo(unsigned int row) const;
///
- RowInfo & rowinfo(int row);
+ RowInfo & rowinfo(unsigned int row);
///
bool isGrid() const { return true; }
///
- int ncols() const { return colinfo_.size(); }
+ unsigned int ncols() const { return colinfo_.size(); }
///
- int nrows() const { return rowinfo_.size(); }
+ unsigned int nrows() const { return rowinfo_.size(); }
///
- int col(int idx) const { return idx % ncols(); }
+ unsigned int col(unsigned int idx) const { return idx % ncols(); }
///
- int row(int idx) const { return idx / ncols(); }
+ unsigned int row(unsigned int idx) const { return idx / ncols(); }
///
- int cellXOffset(int idx) const;
+ int cellXOffset(unsigned int idx) const;
///
- int cellYOffset(int idx) const;
+ int cellYOffset(unsigned int idx) const;
///
- bool idxUp(int &, int &) const;
+ bool idxUp(unsigned int &, unsigned int &) const;
///
- bool idxDown(int &, int &) const;
+ bool idxDown(unsigned int &, unsigned int &) const;
///
- bool idxLeft(int &, int &) const;
+ bool idxLeft(unsigned int &, unsigned int &) const;
///
- bool idxRight(int &, int &) const;
+ bool idxRight(unsigned int &, unsigned int &) const;
///
- bool idxFirst(int &, int &) const;
+ bool idxFirst(unsigned int &, unsigned int &) const;
///
- bool idxLast(int &, int &) const;
+ bool idxLast(unsigned int &, unsigned int &) const;
///
- void idxDelete(int &, bool &, bool &);
+ void idxDelete(unsigned int &, bool &, bool &);
///
- void idxDeleteRange(int, int);
+ void idxDeleteRange(unsigned int, unsigned int);
///
- void addRow(int);
+ void addRow(unsigned int);
///
- void delRow(int);
+ void delRow(unsigned int);
///
- void addCol(int);
+ void addCol(unsigned int);
///
- void delCol(int);
+ void delCol(unsigned int);
///
virtual void appendRow();
///
- int index(int row, int col) const;
+ unsigned int index(unsigned int row, unsigned int col) const;
///
- std::vector<int> idxBetween(int from, int to) const;
+ std::vector<unsigned int> idxBetween(unsigned int from, unsigned int to) const;
///
- virtual int defaultColSpace(int) { return 10; }
+ virtual int defaultColSpace(unsigned int) { return 10; }
///
- virtual char defaultColAlign(int) { return 'c'; }
+ virtual char defaultColAlign(unsigned int) { return 'c'; }
///
void setDefaults();
protected:
/// returns proper 'end of line' code for LaTeX
- string eolString(int row) const;
+ string eolString(unsigned int row) const;
/// returns proper 'end of column' code for LaTeX
- string eocString(int col) const;
+ string eocString(unsigned int col) const;
/// row info
std::vector<RowInfo> rowinfo_;
}
-int MathInset::nargs() const
+unsigned int MathInset::nargs() const
{
return 0;
}
MathXArray dummyCell;
-MathXArray & MathInset::xcell(int)
+MathXArray & MathInset::xcell(unsigned int)
{
lyxerr << "I don't have a cell\n";
return dummyCell;
}
-MathXArray const & MathInset::xcell(int) const
+MathXArray const & MathInset::xcell(unsigned int) const
{
lyxerr << "I don't have a cell\n";
return dummyCell;
}
-MathArray & MathInset::cell(int)
+MathArray & MathInset::cell(unsigned int)
{
lyxerr << "I don't have a cell\n";
return dummyCell.data_;
}
-MathArray const & MathInset::cell(int) const
+MathArray const & MathInset::cell(unsigned int) const
{
lyxerr << "I don't have a cell\n";
return dummyCell.data_;
{}
-bool MathInset::idxNext(int &, int &) const
+bool MathInset::idxNext(unsigned int &, unsigned int &) const
{
return false;
}
-bool MathInset::idxRight(int &, int &) const
+bool MathInset::idxRight(unsigned int &, unsigned int &) const
{
return false;
}
-bool MathInset::idxPrev(int &, int &) const
+bool MathInset::idxPrev(unsigned int &, unsigned int &) const
{
return false;
}
-bool MathInset::idxLeft(int &, int &) const
+bool MathInset::idxLeft(unsigned int &, unsigned int &) const
{
return false;
}
-bool MathInset::idxUp(int &, int &) const
+bool MathInset::idxUp(unsigned int &, unsigned int &) const
{
return false;
}
-bool MathInset::idxDown(int &, int &) const
+bool MathInset::idxDown(unsigned int &, unsigned int &) const
{
return false;
}
-bool MathInset::idxFirst(int &, int &) const
+bool MathInset::idxFirst(unsigned int &, unsigned int &) const
{
return false;
}
-bool MathInset::idxLast(int &, int &) const
+bool MathInset::idxLast(unsigned int &, unsigned int &) const
{
return false;
}
-bool MathInset::idxHome(int &, int &) const
+bool MathInset::idxHome(unsigned int &, unsigned int &) const
{
return false;
}
-bool MathInset::idxEnd(int &, int &) const
+bool MathInset::idxEnd(unsigned int &, unsigned int &) const
{
return false;
}
-void MathInset::idxDelete(int &, bool & popit, bool & deleteit)
+void MathInset::idxDelete(unsigned int &, bool & popit, bool & deleteit)
{
popit = false;
deleteit = false;
}
-void MathInset::idxDeleteRange(int, int)
+void MathInset::idxDeleteRange(unsigned int, unsigned int)
{}
{}
-std::vector<int> MathInset::idxBetween(int from, int to) const
+std::vector<unsigned int>
+ MathInset::idxBetween(unsigned int from, unsigned int to) const
{
- std::vector<int> res;
- for (int i = from; i <= to; ++i)
+ std::vector<unsigned int> res;
+ for (unsigned int i = from; i <= to; ++i)
res.push_back(i);
return res;
}
virtual MathStyles size() const;
/// Where should we go when we press the up cursor key?
- virtual bool idxUp(int & idx, int & pos) const;
+ virtual bool idxUp(unsigned int & idx, unsigned int & pos) const;
/// The down key
- virtual bool idxDown(int & idx, int & pos) const;
+ virtual bool idxDown(unsigned int & idx, unsigned int & pos) const;
/// The left key
- virtual bool idxLeft(int & idx, int & pos) const;
+ virtual bool idxLeft(unsigned int & idx, unsigned int & pos) const;
/// The right key
- virtual bool idxRight(int & idx, int & pos) const;
+ virtual bool idxRight(unsigned int & idx, unsigned int & pos) const;
/// Move one physical cell up
- virtual bool idxNext(int & idx, int & pos) const;
+ virtual bool idxNext(unsigned int & idx, unsigned int & pos) const;
/// Move one physical cell down
- virtual bool idxPrev(int & idx, int & pos) const;
+ virtual bool idxPrev(unsigned int & idx, unsigned int & pos) const;
/// Target pos when we enter the inset from the left by pressing "Right"
- virtual bool idxFirst(int & idx, int & pos) const;
+ virtual bool idxFirst(unsigned int & idx, unsigned int & pos) const;
/// Target pos when we enter the inset from the right by pressing "Left"
- virtual bool idxLast(int & idx, int & pos) const;
+ virtual bool idxLast(unsigned int & idx, unsigned int & pos) const;
/// Where should we go if we press home?
- virtual bool idxHome(int & idx, int & pos) const;
+ virtual bool idxHome(unsigned int & idx, unsigned int & pos) const;
/// Where should we go if we press end?
- virtual bool idxEnd(int & idx, int & pos) const;
+ virtual bool idxEnd(unsigned int & idx, unsigned int & pos) const;
/// Delete a cell and move cursor
// the return value indicates whether the cursor should leave the inset
// and/or the whole inset should be deleted
- virtual void idxDelete(int & idx, bool & popit, bool & deleteit);
+ virtual void idxDelete(unsigned int & idx, bool & popit, bool & deleteit);
// deletes a cell range and moves the cursor
- virtual void idxDeleteRange(int from, int to);
+ virtual void idxDeleteRange(unsigned int from, unsigned int to);
// returns list of cell indices that are "between" from and to for
// selection purposes
- virtual std::vector<int> idxBetween(int from, int to) const;
+ virtual std::vector<unsigned int>
+ idxBetween(unsigned int from, unsigned int to) const;
///
- virtual int nargs() const;
+ virtual unsigned int nargs() const;
///
- virtual MathArray & cell(int);
+ virtual MathArray & cell(unsigned int);
///
- virtual MathArray const & cell(int) const;
+ virtual MathArray const & cell(unsigned int) const;
///
- virtual MathXArray & xcell(int);
+ virtual MathXArray & xcell(unsigned int);
///
- virtual MathXArray const & xcell(int) const;
+ virtual MathXArray const & xcell(unsigned int) const;
///
virtual int xo() const;
///
///
- virtual int ncols() const { return 1; }
+ virtual unsigned int ncols() const { return 1; }
///
- virtual int nrows() const { return 1; }
+ virtual unsigned int nrows() const { return 1; }
///
- virtual int col(int) const { return 0; }
+ virtual unsigned int col(unsigned int) const { return 0; }
///
- virtual int row(int) const { return 0; }
+ virtual unsigned int row(unsigned int) const { return 0; }
///
- virtual int cellXOffset(int) const { return 0; }
+ virtual int cellXOffset(unsigned int) const { return 0; }
///
- virtual int cellYOffset(int) const { return 0; }
+ virtual int cellYOffset(unsigned int) const { return 0; }
///
- virtual void addRow(int) {}
+ virtual void addRow(unsigned int) {}
///
- virtual void delRow(int) {}
+ virtual void delRow(unsigned int) {}
///
- virtual void addCol(int) {}
+ virtual void addCol(unsigned int) {}
///
- virtual void delCol(int) {}
+ virtual void delCol(unsigned int) {}
///
virtual void userSetSize(MathStyles &) {}
int lwid;
mathed_string_dim(LM_TC_TEXTRM, size_, "#1: ", lasc, ldes, lwid);
- for (int i = 0; i < nargs(); ++i) {
+ for (unsigned int i = 0; i < nargs(); ++i) {
MathXArray const & c = xcell(i);
c.metrics(st);
width_ = std::max(width_, c.width() + lwid);
int lwid;
mathed_string_dim(LM_TC_TEXTRM, size_, "#1: ", lasc, ldes, lwid);
- for (int i = 0; i < nargs(); ++i) {
+ for (unsigned int i = 0; i < nargs(); ++i) {
MathXArray const & c = xcell(i);
h += std::max(c.ascent(), lasc) + 5;
c.draw(pain, x + lwid, h);
}
-void MathMacro::dump(std::ostream & os) const
+void MathMacro::dump() const
{
MathMacroTable::dump();
- os << "\n macro: '" << this << "'\n";
- os << " name: '" << name() << "'\n";
- os << " template: '" << tmplate_ << "'\n";
- os << " template: '" << *tmplate_ << "'\n";
- os << endl;
+ lyxerr << "\n macro: '" << this << "'\n";
+ lyxerr << " name: '" << name() << "'\n";
+ lyxerr << " template: '" << tmplate_ << "'\n";
+ lyxerr << " template: '" << *tmplate_ << "'\n";
+ lyxerr << endl;
}
void MathMacro::write(std::ostream & os, bool fragile) const
{
os << '\\' << name();
- for (int i = 0; i < nargs(); ++i) {
+ for (unsigned int i = 0; i < nargs(); ++i) {
os << '{';
cell(i).write(os, fragile);
os << '}';
void MathMacro::writeNormal(std::ostream & os) const
{
os << "[macro " << name() << " ";
- for (int i = 0; i < nargs(); ++i) {
+ for (unsigned int i = 0; i < nargs(); ++i) {
cell(i).writeNormal(os);
os << ' ';
}
}
-bool MathMacro::idxUp(int & idx, int & pos) const
+bool MathMacro::idxUp(unsigned int & idx, unsigned int & pos) const
{
return MathNestInset::idxLeft(idx, pos);
}
-bool MathMacro::idxDown(int & idx, int & pos) const
+bool MathMacro::idxDown(unsigned int & idx, unsigned int & pos) const
{
return MathNestInset::idxRight(idx, pos);
}
-bool MathMacro::idxLeft(int &, int &) const
+bool MathMacro::idxLeft(unsigned int &, unsigned int &) const
{
return false;
}
-bool MathMacro::idxRight(int &, int &) const
+bool MathMacro::idxRight(unsigned int &, unsigned int &) const
{
return false;
}
///
void writeNormal(std::ostream &) const;
///
- void dump(std::ostream & os) const;
+ void dump() const;
///
- bool idxUp(int &, int &) const;
+ bool idxUp(unsigned int &, unsigned int &) const;
///
- bool idxDown(int &, int &) const;
+ bool idxDown(unsigned int &, unsigned int &) const;
///
- bool idxLeft(int &, int &) const;
+ bool idxLeft(unsigned int &, unsigned int &) const;
///
- bool idxRight(int &, int &) const;
+ bool idxRight(unsigned int &, unsigned int &) const;
///
void validate(LaTeXFeatures &) const;
};
-inline std::ostream & operator<<(std::ostream & os, MathMacro const & m)
-{
- m.dump(os);
- return os;
-}
#endif
}
-MathMatrixInset::MathMatrixInset(MathInsetTypes t, int cols)
+MathMatrixInset::MathMatrixInset(MathInsetTypes t, unsigned int cols)
: MathGridInset(cols, 1), objtype_(t), nonum_(1), label_(1)
{
setDefaults();
}
-char MathMatrixInset::defaultColAlign(int col)
+char MathMatrixInset::defaultColAlign(unsigned int col)
{
switch (getType()) {
case LM_OT_ALIGN:
}
-int MathMatrixInset::defaultColSpace(int col)
+int MathMatrixInset::defaultColSpace(unsigned int col)
{
switch (getType()) {
case LM_OT_ALIGN:
if (numberedType()) {
int l = 0;
- for (int row = 0; row < nrows(); ++row)
+ for (unsigned int row = 0; row < nrows(); ++row)
l = std::max(l, mathed_string_width(LM_TC_BF, size(), nicelabel(row)));
if (l)
if (numberedType()) {
int xx = x + colinfo_.back().offset_ + colinfo_.back().width_ + 20;
- for (int row = 0; row < nrows(); ++row) {
+ for (unsigned int row = 0; row < nrows(); ++row) {
int yy = y + rowinfo_[row].offset_;
drawStr(pain, LM_TC_BF, size(), xx, yy, nicelabel(row));
}
bool n = numberedType();
- for (int row = 0; row < nrows(); ++row) {
- for (int col = 0; col < ncols(); ++col) {
+ for (unsigned int row = 0; row < nrows(); ++row) {
+ for (unsigned int col = 0; col < ncols(); ++col) {
cell(index(row, col)).write(os, fragile);
os << eocString(col);
}
}
-string MathMatrixInset::label(int row) const
+string MathMatrixInset::label(unsigned int row) const
{
return label_[row];
}
-void MathMatrixInset::label(int row, string const & label)
+void MathMatrixInset::label(unsigned int row, string const & label)
{
label_[row] = label;
}
-void MathMatrixInset::numbered(int row, bool num)
+void MathMatrixInset::numbered(unsigned int row, bool num)
{
nonum_[row] = !num;
}
-bool MathMatrixInset::numbered(int row) const
+bool MathMatrixInset::numbered(unsigned int row) const
{
return !nonum_[row];
}
std::vector<string> const MathMatrixInset::getLabelList() const
{
std::vector<string> res;
- for (int row = 0; row < nrows(); ++row)
+ for (unsigned int row = 0; row < nrows(); ++row)
if (!label_[row].empty() && nonum_[row] != 1)
res.push_back(label_[row]);
return res;
{
if (getType() == LM_OT_SIMPLE || getType() == LM_OT_XXALIGNAT)
return false;
- for (int row = 0; row < nrows(); ++row)
+ for (unsigned int row = 0; row < nrows(); ++row)
if (!nonum_[row])
return true;
return false;
}
-void MathMatrixInset::addRow(int row)
+void MathMatrixInset::addRow(unsigned int row)
{
nonum_.insert(nonum_.begin() + row + 1, !numberedType());
label_.insert(label_.begin() + row + 1, string());
}
-void MathMatrixInset::delRow(int row)
+void MathMatrixInset::delRow(unsigned int row)
{
MathGridInset::delRow(row);
nonum_.erase(nonum_.begin() + row);
}
-void MathMatrixInset::addCol(int col)
+void MathMatrixInset::addCol(unsigned int col)
{
switch (getType()) {
case LM_OT_EQUATION:
}
-void MathMatrixInset::delCol(int col)
+void MathMatrixInset::delCol(unsigned int col)
{
switch (getType()) {
case LM_OT_ALIGNAT:
}
-string MathMatrixInset::nicelabel(int row) const
+string MathMatrixInset::nicelabel(unsigned int row) const
{
if (nonum_[row])
return string();
}
}
+
void MathMatrixInset::mutate(string const & newtype)
{
if (newtype == "dump") {
mutate(typecode(newtype));
}
+
void MathMatrixInset::glueall()
{
MathArray ar;
- for (int i = 0; i < nargs(); ++i)
+ for (unsigned int i = 0; i < nargs(); ++i)
ar.push_back(cell(i));
*this = MathMatrixInset(LM_OT_SIMPLE);
cell(0) = ar;
MathGridInset::addCol(1);
// split it "nicely"
- int pos = firstRelOp(cell(0));
+ unsigned int pos = firstRelOp(cell(0));
cell(1) = cell(0);
cell(0).erase(pos, cell(0).size());
cell(1).erase(0, pos);
MathGridInset::addCol(1);
// split it "nicely" on the firest relop
- int pos = firstRelOp(cell(0));
+ unsigned int pos = firstRelOp(cell(0));
cell(1) = cell(0);
cell(0).erase(pos, cell(0).size());
cell(1).erase(0, pos);
case LM_OT_EQUATION: {
// set correct (no)numbering
bool allnonum = true;
- for (int r = 0; r < nrows(); ++r) {
- if (!nonum_[r])
+ for (unsigned int row = 0; row < nrows(); ++row) {
+ if (!nonum_[row])
allnonum = false;
}
// set first non-empty label
string label;
- for (int r = 0; r < nrows(); ++r) {
- if (!label_[r].empty()) {
- label = label_[r];
+ for (unsigned int row = 0; row < nrows(); ++row) {
+ if (!label_[row].empty()) {
+ label = label_[row];
break;
}
}
case LM_OT_XALIGNAT:
case LM_OT_XXALIGNAT:
default: {
- for (int row = 0; row < nrows(); ++row) {
- int c = 3 * row + 1;
+ for (unsigned int row = 0; row < nrows(); ++row) {
+ unsigned int c = 3 * row + 1;
cell(c).push_back(cell(c + 1));
}
MathGridInset::delCol(2);
///
explicit MathMatrixInset(MathInsetTypes t);
///
- MathMatrixInset(MathInsetTypes t, int cols);
+ MathMatrixInset(MathInsetTypes t, unsigned int cols);
///
MathInset * clone() const;
///
///
void draw(Painter &, int x, int y) const;
///
- string label(int row) const;
+ string label(unsigned int row) const;
///
- void label(int row, string const & label);
+ void label(unsigned int row, string const & label);
///
- void numbered(int row, bool num);
+ void numbered(unsigned int row, bool num);
///
- bool numbered(int row) const;
+ bool numbered(unsigned int row) const;
///
bool numberedType() const;
///
void validate(LaTeXFeatures & features) const;
///
- void addRow(int);
+ void addRow(unsigned int);
///
- void delRow(int);
+ void delRow(unsigned int);
///
- void addCol(int);
+ void addCol(unsigned int);
///
- void delCol(int);
+ void delCol(unsigned int);
///
void appendRow();
void mutate(MathInsetTypes);
///
- int defaultColSpace(int col);
+ int defaultColSpace(unsigned int col);
///
- char defaultColAlign(int col);
+ char defaultColAlign(unsigned int col);
///
MathInsetTypes getType() const;
///
void glueall();
///
- string nicelabel(int row) const;
+ string nicelabel(unsigned int row) const;
///
MathInsetTypes objtype_;
#include "debug.h"
-MathNestInset::MathNestInset(int nargs)
+MathNestInset::MathNestInset(unsigned int nargs)
: MathDimInset(), cells_(nargs)
{}
-int MathNestInset::nargs() const
+unsigned int MathNestInset::nargs() const
{
return cells_.size();
}
-MathXArray & MathNestInset::xcell(int i)
+MathXArray & MathNestInset::xcell(unsigned int i)
{
return cells_[i];
}
-MathXArray const & MathNestInset::xcell(int i) const
+MathXArray const & MathNestInset::xcell(unsigned int i) const
{
return cells_[i];
}
-MathArray & MathNestInset::cell(int i)
+MathArray & MathNestInset::cell(unsigned int i)
{
return cells_[i].data_;
}
-MathArray const & MathNestInset::cell(int i) const
+MathArray const & MathNestInset::cell(unsigned int i) const
{
return cells_[i].data_;
}
void MathNestInset::substitute(MathMacro const & m)
{
- for (int i = 0; i < nargs(); ++i)
+ for (unsigned int i = 0; i < nargs(); ++i)
cell(i).substitute(m);
}
void MathNestInset::metrics(MathStyles st) const
{
size_ = st;
- for (int i = 0; i < nargs(); ++i)
+ for (unsigned int i = 0; i < nargs(); ++i)
xcell(i).metrics(st);
}
{
xo(x);
yo(y);
- for (int i = 0; i < nargs(); ++i)
+ for (unsigned int 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(unsigned int & idx, unsigned int & pos) const
{
if (idx + 1 >= nargs())
return false;
}
-bool MathNestInset::idxRight(int & idx, int & pos) const
+bool MathNestInset::idxRight(unsigned int & idx, unsigned int & pos) const
{
return idxNext(idx, pos);
}
-bool MathNestInset::idxPrev(int & idx, int & pos) const
+bool MathNestInset::idxPrev(unsigned int & idx, unsigned int & pos) const
{
if (idx == 0)
return false;
}
-bool MathNestInset::idxLeft(int & idx, int & pos) const
+bool MathNestInset::idxLeft(unsigned int & idx, unsigned int & pos) const
{
return idxPrev(idx, pos);
}
-bool MathNestInset::idxFirst(int & i, int & pos) const
+bool MathNestInset::idxFirst(unsigned int & i, unsigned int & pos) const
{
if (nargs() == 0)
return false;
}
-bool MathNestInset::idxLast(int & i, int & pos) const
+bool MathNestInset::idxLast(unsigned int & i, unsigned int & pos) const
{
if (nargs() == 0)
return false;
}
-bool MathNestInset::idxHome(int & /* idx */, int & pos) const
+bool MathNestInset::idxHome(unsigned int & /* idx */, unsigned int & pos) const
{
if (pos == 0)
return false;
}
-bool MathNestInset::idxEnd(int & idx, int & pos) const
+bool MathNestInset::idxEnd(unsigned int & idx, unsigned int & pos) const
{
- int n = cell(idx).size();
+ unsigned int n = cell(idx).size();
if (pos == n)
return false;
lyxerr << "---------------------------------------------\n";
write(lyxerr, false);
lyxerr << "\n";
- for (int i = 0; i < nargs(); ++i)
+ for (unsigned int i = 0; i < nargs(); ++i)
lyxerr << cell(i) << "\n";
lyxerr << "---------------------------------------------\n";
}
void MathNestInset::validate(LaTeXFeatures & features) const
{
- for (int i = 0; i < nargs(); ++i)
+ for (unsigned int i = 0; i < nargs(); ++i)
cell(i).validate(features);
}
class MathNestInset : public MathDimInset {
public:
///
- explicit MathNestInset(int ncells);
+ explicit MathNestInset(unsigned int ncells);
///
void metrics(MathStyles st) const;
void substitute(MathMacro const & macro);
/// The left key
- bool idxLeft(int & idx, int & pos) const;
+ bool idxLeft(unsigned int & idx, unsigned int & pos) const;
/// The right key
- bool idxRight(int & idx, int & pos) const;
+ bool idxRight(unsigned int & idx, unsigned int & pos) const;
/// Move one physical cell up
- bool idxNext(int & idx, int & pos) const;
+ bool idxNext(unsigned int & idx, unsigned int & pos) const;
/// Move one physical cell down
- bool idxPrev(int & idx, int & pos) const;
+ bool idxPrev(unsigned int & idx, unsigned int & pos) const;
/// Target pos when we enter the inset from the left by pressing "Right"
- bool idxFirst(int & idx, int & pos) const;
+ bool idxFirst(unsigned int & idx, unsigned int & pos) const;
/// Target pos when we enter the inset from the right by pressing "Left"
- bool idxLast(int & idx, int & pos) const;
+ bool idxLast(unsigned int & idx, unsigned int & pos) const;
/// Where should we go if we press home?
- bool idxHome(int & idx, int & pos) const;
+ bool idxHome(unsigned int & idx, unsigned int & pos) const;
/// Where should we go if we press end?
- bool idxEnd(int & idx, int & pos) const;
+ bool idxEnd(unsigned int & idx, unsigned int & pos) const;
///
- int nargs() const;
+ unsigned int nargs() const;
///
- MathArray & cell(int);
+ MathArray & cell(unsigned int);
///
- MathArray const & cell(int) const;
+ MathArray const & cell(unsigned int) const;
///
- MathXArray & xcell(int);
+ MathXArray & xcell(unsigned int);
///
- MathXArray const & xcell(int) const;
+ MathXArray const & xcell(unsigned int) const;
///
bool isActive() const { return nargs() > 0; }
else {
MathInset * p = createMathInset(t.cs());
- for (int i = 0; i < p->nargs(); ++i)
+ for (unsigned int i = 0; i < p->nargs(); ++i)
parse_into(p->cell(i), FLAG_ITEM);
array.push_back(p);
}
else {
MathInset * p = createMathInset(t.cs());
if (p) {
- for (int i = 0; i < p->nargs(); ++i)
+ for (unsigned int i = 0; i < p->nargs(); ++i)
parse_into(p->cell(i), FLAG_ITEM);
array.push_back(p);
} else {