mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 21:40:19 +00:00
support reading TeX's $$...$$ syntax
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2887 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
1d415f2c7c
commit
761fab540e
@ -308,7 +308,7 @@ bool MathCursor::left(bool sel)
|
||||
pushRight(prevAtom());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return posLeft() || idxLeft() || popLeft() || selection_;
|
||||
}
|
||||
|
||||
@ -1068,13 +1068,17 @@ void MathCursor::breakLine()
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -464,20 +464,26 @@ void MathGridInset::idxDelete(idx_type & 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) {
|
||||
// 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)
|
||||
|
@ -30,7 +30,6 @@
|
||||
#include "Painter.h"
|
||||
#include "LaTeXFeatures.h"
|
||||
|
||||
using std::endl;
|
||||
|
||||
MathMacro::MathMacro(string const & name)
|
||||
: MathNestInset(MathMacroTable::provide(name)->asMacroTemplate()->numargs()),
|
||||
@ -160,7 +159,6 @@ void MathMacro::dump() const
|
||||
lyxerr << "\n macro: '" << this << "'\n";
|
||||
lyxerr << " name: '" << name() << "'\n";
|
||||
lyxerr << " template: '"; tmplate_->write(lyxerr, false); lyxerr << "'\n";
|
||||
lyxerr << endl;
|
||||
}
|
||||
|
||||
|
||||
|
@ -535,12 +535,30 @@ bool Parser::parse_normal(MathAtom & matrix)
|
||||
|
||||
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;
|
||||
@ -556,7 +574,7 @@ bool Parser::parse_normal(MathAtom & matrix)
|
||||
parse_into(p->cell(0), 0);
|
||||
p->numbered(0, curr_num_);
|
||||
p->label(0, curr_label_);
|
||||
return p;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (cs != "begin") {
|
||||
|
Loading…
Reference in New Issue
Block a user