using namespace lyx::support;
+
namespace lyx {
static docstring verboseHLine(int n)
static void resetGrid(InsetMathGrid & grid)
{
while (grid.ncols() > 1)
- grid.delCol(grid.ncols());
+ grid.delCol(grid.ncols() - 1);
while (grid.nrows() > 1)
- grid.delRow(grid.nrows());
+ grid.delRow(grid.nrows() - 1);
grid.cell(0).erase(0, grid.cell(0).size());
grid.setDefaults();
}
// compute vertical offsets
rowinfo_[0].offset_ = 0;
for (row_type row = 1; row <= nrows(); ++row) {
- rowinfo_[row].offset_ =
- rowinfo_[row - 1].offset_ +
+ rowinfo_[row].offset_ =
+ rowinfo_[row - 1].offset_ +
rowinfo_[row - 1].descent_ +
rowinfo_[row - 1].skipPixels(mi) +
rowsep() +
}
- dim.wid = colinfo_[ncols() - 1].offset_
- + colinfo_[ncols() - 1].width_
- + vlinesep() * colinfo_[ncols()].lines_
- + border();
+ dim.wid = colinfo_[ncols() - 1].offset_
+ + colinfo_[ncols() - 1].width_
+ + vlinesep() * colinfo_[ncols()].lines_
+ + border();
- dim.asc = - rowinfo_[0].offset_
- + rowinfo_[0].ascent_
- + hlinesep() * rowinfo_[0].lines_
- + border();
+ dim.asc = - rowinfo_[0].offset_
+ + rowinfo_[0].ascent_
+ + hlinesep() * rowinfo_[0].lines_
+ + border();
- dim.des = rowinfo_[nrows() - 1].offset_
- + rowinfo_[nrows() - 1].descent_
- + hlinesep() * rowinfo_[nrows()].lines_
- + border();
+ dim.des = rowinfo_[nrows() - 1].offset_
+ + rowinfo_[nrows() - 1].descent_
+ + hlinesep() * rowinfo_[nrows()].lines_
+ + border();
/*
}
-docstring InsetMathGrid::eolString(row_type row, bool fragile) const
+docstring InsetMathGrid::eolString(row_type row, bool fragile,
+ bool /*latex*/, bool last_eoln) const
{
docstring eol;
}
// only add \\ if necessary
- if (eol.empty() && row + 1 == nrows())
+ if (eol.empty() && row + 1 == nrows() && (nrows() == 1 || !last_eoln))
return docstring();
return (fragile ? "\\protect\\\\" : "\\\\") + eol;
char const * const celltag = havetable ? "mtd" : "mrow";
for (row_type row = 0; row < nrows(); ++row) {
if (havetable)
- os << MTag("mtr");;
+ os << MTag("mtr");
for (col_type col = 0; col < ncols(); ++col) {
os << MTag(celltag);
os << cell(index(row, col));
os << ETag(celltag);
}
if (havetable)
- os << ETag("mtr");;
+ os << ETag("mtr");
}
if (havetable)
os << ETag("mtable");
}
os << MTag("table", attrib);
for (row_type row = 0; row < nrows(); ++row) {
- os << MTag("tr");;
+ os << MTag("tr");
for (col_type col = 0; col < ncols(); ++col) {
os << MTag("td");
os << cell(index(row, col));
os << ETag("td");
}
- os << ETag("tr");;
+ os << ETag("tr");
}
os << ETag("table");
}
// unless there are vertical lines
col_type lastcol = 0;
bool emptyline = true;
- for (col_type col = beg_col; col < end_col; ++col)
- if (!cell(index(row, col)).empty()
- || colinfo_[col + 1].lines_) {
+ bool last_eoln = true;
+ for (col_type col = beg_col; col < end_col; ++col) {
+ bool const empty_cell = cell(index(row, col)).empty();
+ if (!empty_cell)
+ last_eoln = false;
+ if (!empty_cell || colinfo_[col + 1].lines_) {
lastcol = col + 1;
emptyline = false;
}
+ }
for (col_type col = beg_col; col < lastcol; ++col) {
os << cell(index(row, col));
if (os.pendingBrace())
ModeSpecifier specifier(os, TEXT_MODE);
os << eocString(col, lastcol);
}
- eol = eolString(row, os.fragile());
+ eol = eolString(row, os.fragile(), os.latex(), last_eoln);
os << eol;
// append newline only if line wasn't completely empty
// and the formula is not written on a single line
Parse::flags parseflg = Parse::QUIET | Parse::USETEXT;
- switch (cmd.action_) {
+ FuncCode const act = cmd.action();
+ switch (act) {
// insert file functions
case LFUN_LINE_DELETE:
if (cur.idx() > 0)
--cur.idx();
cur.pos() = cur.lastpos();
-
+ cur.forceBufferUpdate();
//mathcursor->normalize();
//cmd = FuncRequest(LFUN_FINISHED_BACKWARD);
break;
cell(i).append(grid.cell(grid.index(r, c)));
}
cur.clearSelection(); // bug 393
- // FIXME audit setBuffer/updateBuffer calls
+ // FIXME audit setBuffer calls
cur.inset().setBuffer(*buffer_);
- // FIXME audit setBuffer/updateBuffer calls
- cur.buffer()->updateBuffer();
+ cur.forceBufferUpdate();
cur.finishUndo();
break;
}
case LFUN_WORD_BACKWARD:
case LFUN_WORD_LEFT_SELECT:
case LFUN_WORD_LEFT:
- cur.selHandle(cmd.action_ == LFUN_WORD_BACKWARD_SELECT ||
- cmd.action_ == LFUN_WORD_LEFT_SELECT ||
- cmd.action_ == LFUN_LINE_BEGIN_SELECT);
+ cur.selHandle(act == LFUN_WORD_BACKWARD_SELECT ||
+ act == LFUN_WORD_LEFT_SELECT ||
+ act == LFUN_LINE_BEGIN_SELECT);
cur.macroModeClose();
if (cur.pos() != 0) {
cur.pos() = 0;
case LFUN_WORD_RIGHT:
case LFUN_LINE_END_SELECT:
case LFUN_LINE_END:
- cur.selHandle(cmd.action_ == LFUN_WORD_FORWARD_SELECT ||
- cmd.action_ == LFUN_WORD_RIGHT_SELECT ||
- cmd.action_ == LFUN_LINE_END_SELECT);
+ cur.selHandle(act == LFUN_WORD_FORWARD_SELECT ||
+ act == LFUN_WORD_RIGHT_SELECT ||
+ act == LFUN_LINE_END_SELECT);
cur.macroModeClose();
cur.clearTargetX();
if (cur.pos() != cur.lastpos()) {
bool InsetMathGrid::getStatus(Cursor & cur, FuncRequest const & cmd,
FuncStatus & status) const
{
- switch (cmd.action_) {
+ switch (cmd.action()) {
case LFUN_INSET_MODIFY: {
istringstream is(to_utf8(cmd.argument()));
string s;
}
case LFUN_CELL_SPLIT:
- status.setEnabled(true);
+ status.setEnabled(cur.idx() != cur.lastidx());
return true;
case LFUN_CELL_BACKWARD: