pushRight(prevAtom());
return true;
}
-
+
return posLeft() || idxLeft() || popLeft() || selection_;
}
for (col_type c = col() + 1; c < p->ncols(); ++c) {
const MathMatrixInset::idx_type i1 = p->index(r, c);
const MathMatrixInset::idx_type i2 = p->index(r + 1, c);
- lyxerr << "swapping cells " << i1 << " and " << i2 << "\n";
+ //lyxerr << "swapping cells " << i1 << " and " << i2 << "\n";
p->cell(i1).swap(p->cell(i2));
}
// split cell
splitCell();
p->cell(idx()).swap(p->cell(idx() + p->ncols() - 1));
+
+ // correct cursor position
+ --idx();
+ pos() = size();
}
}
popit = false;
deleteit = false;
- // delete entire row if in first cell of empty row
- if (col(idx) == 0 && nrows() > 1) {
+ // delete entire sequence of ncols() empty cells if possible
+ if (idx <= index(nrows() - 1, 0)) {
bool deleterow = true;
for (idx_type i = idx; i < idx + ncols(); ++i)
if (cell(i).size()) {
deleterow = false;
break;
}
- if (deleterow)
+
+ if (deleterow) {
+ // move cells if necessary
+ for (idx_type i = index(row(idx), 0); i < idx; ++i)
+ cell(i).swap(cell(i + ncols()));
+
delRow(row(idx));
- if (idx >= nargs())
- idx = nargs() - 1;
- return;
+ if (idx >= nargs())
+ idx = nargs() - 1;
+ return;
+ }
}
// undo effect of Ctrl-Tab (i.e. pull next cell)
#include "Painter.h"
#include "LaTeXFeatures.h"
-using std::endl;
MathMacro::MathMacro(string const & name)
: MathNestInset(MathMacroTable::provide(name)->asMacroTemplate()->numargs()),
lyxerr << "\n macro: '" << this << "'\n";
lyxerr << " name: '" << name() << "'\n";
lyxerr << " template: '"; tmplate_->write(lyxerr, false); lyxerr << "'\n";
- lyxerr << endl;
}
Token const & t = getToken();
- if (t.cat() == catMath || t.cs() == "(") {
+ if (t.cs() == "(") {
matrix = MathAtom(new MathMatrixInset(LM_OT_SIMPLE));
parse_into(matrix->cell(0), 0);
return true;
}
+ if (t.cat() == catMath) {
+ Token const & n = getToken();
+ if (n.cat() == catMath) {
+ // TeX's $$...$$ syntax for displayed math
+ matrix = MathAtom(new MathMatrixInset(LM_OT_EQUATION));
+ MathMatrixInset * p = matrix->asMatrixInset();
+ parse_into(p->cell(0), 0);
+ p->numbered(0, curr_num_);
+ p->label(0, curr_label_);
+ } else {
+ // simple $...$ stuff
+ putback();
+ matrix = MathAtom(new MathMatrixInset(LM_OT_SIMPLE));
+ parse_into(matrix->cell(0), 0);
+ }
+ return true;
+ }
+
if (!t.cs().size()) {
lyxerr << "start of math expected, got '" << t << "'\n";
return false;
parse_into(p->cell(0), 0);
p->numbered(0, curr_num_);
p->label(0, curr_label_);
- return p;
+ return true;
}
if (cs != "begin") {