#include "InsetMathGrid.h"
+#include "InsetMathUnknown.h"
#include "MathData.h"
#include "MathParser.h"
#include "MathStream.h"
}
+bool InsetMathGrid::interpretString(Cursor & cur, docstring const & str)
+{
+ if (str == "\\hline") {
+ FuncRequest fr = FuncRequest(LFUN_INSET_MODIFY, "tabular add-hline-above");
+ FuncStatus status;
+ if (getStatus(cur, fr, status)) {
+ if (status.enabled()) {
+ rowinfo_[cur.row()].lines_++;
+ return true;
+ }
+ }
+ }
+ return InsetMathNest::interpretString(cur, str);
+}
+
+
void InsetMathGrid::setHorizontalAlignments(docstring const & hh)
{
col_type col = 0;
// make sure an upcoming '[' does not break anything
if (row + 1 < nrows()) {
MathData const & c = cell(index(row + 1, 0));
- if (c.size() && c.front()->getChar() == '[')
+ if (!c.empty() && c.front()->getChar() == '[')
//eol += "[0pt]";
eol += "{}";
}
// try to delete entire sequence of ncols() empty cells if possible
for (idx_type i = idx; i < idx + ncols(); ++i)
- if (cell(i).size())
+ if (!cell(i).empty())
return false;
// move cells if necessary
switch (act) {
// insert file functions
- case LFUN_LINE_DELETE:
+ case LFUN_LINE_DELETE_FORWARD:
cur.recordUndoInset();
//autocorrect_ = false;
//macroModeClose();
docstring & special = colinfo_[cur.col()].special_;
if (!special.empty()) {
docstring::size_type i = special.rfind('|');
- LASSERT(i != docstring::npos, /**/);
+ LASSERT(i != docstring::npos, break);
special.erase(i, 1);
}
}
docstring & special = colinfo_[cur.col()+1].special_;
if (!special.empty()) {
docstring::size_type i = special.find('|');
- LASSERT(i != docstring::npos, /**/);
+ LASSERT(i != docstring::npos, break);
special.erase(i, 1);
}
}
cap::replaceSelection(cur);
docstring topaste;
if (cmd.argument().empty() && !theClipboard().isInternal())
- topaste = theClipboard().getAsText();
+ topaste = theClipboard().getAsText(Clipboard::PlainTextType);
else {
idocstringstream is(cmd.argument());
int n = 0;
}
InsetMathGrid grid(buffer_, 1, 1);
if (!topaste.empty())
- if ((topaste.size() == 1 && topaste.at(0) < 0x80)
+ if ((topaste.size() == 1 && isAscii(topaste))
|| !mathed_parse_normal(grid, topaste, parseflg)) {
resetGrid(grid);
mathed_parse_normal(grid, topaste, parseflg | Parse::VERBATIM);
}
+ bool hline_enabled = false;
+ FuncRequest fr = FuncRequest(LFUN_INSET_MODIFY, "tabular add-hline-above");
+ FuncStatus status;
+ if (getStatus(cur, fr, status))
+ hline_enabled = status.enabled();
if (grid.nargs() == 1) {
// single cell/part of cell
- cur.recordUndo();
+ cur.recordUndoInset();
cur.cell().insert(cur.pos(), grid.cell(0));
cur.pos() += grid.cell(0).size();
+ if (hline_enabled)
+ rowinfo_[cur.row()].lines_ += grid.rowinfo_[0].lines_;
+ else {
+ for (unsigned int l = 0; l < grid.rowinfo_[0].lines_; ++l) {
+ cur.cell().insert(0,
+ MathAtom(new InsetMathUnknown(from_ascii("\\hline"))));
+ cur.pos()++;
+ }
+ }
} else {
// multiple cells
cur.recordUndoInset();
idx_type i = index(r + cur.row(), c + col(cur.idx()));
cell(i).insert(0, grid.cell(grid.index(r, c)));
}
+ if (hline_enabled)
+ rowinfo_[r].lines_ += grid.rowinfo_[r].lines_;
+ else {
+ for (unsigned int l = 0; l < grid.rowinfo_[r].lines_; ++l) {
+ idx_type i = index(r + cur.row(), 0);
+ cell(i).insert(0,
+ MathAtom(new InsetMathUnknown(from_ascii("\\hline"))));
+ }
+ }
// append the left over horizontal cells to the last column
idx_type i = index(r + cur.row(), ncols() - 1);
for (InsetMath::col_type c = numcols; c < grid.ncols(); ++c)
}
// append the left over vertical cells to the last _cell_
idx_type i = nargs() - 1;
- for (row_type r = numrows; r < grid.nrows(); ++r)
+ for (row_type r = numrows; r < grid.nrows(); ++r) {
for (col_type c = 0; c < grid.ncols(); ++c)
cell(i).append(grid.cell(grid.index(r, c)));
+ if (hline_enabled)
+ rowinfo_[r].lines_ += grid.rowinfo_[r].lines_;
+ else {
+ for (unsigned int l = 0; l < grid.rowinfo_[r].lines_; ++l) {
+ cell(i).insert(0,
+ MathAtom(new InsetMathUnknown(from_ascii("\\hline"))));
+ }
+ }
+ }
}
cur.clearSelection(); // bug 393
// FIXME audit setBuffer calls