#include <config.h>
#include "InsetMathGrid.h"
+
#include "MathData.h"
#include "MathParser.h"
#include "MathStream.h"
+#include "MetricsInfo.h"
#include "BufferView.h"
#include "CutAndPaste.h"
#include "FuncStatus.h"
-#include "Color.h"
#include "Cursor.h"
-#include "debug.h"
+#include "support/debug.h"
#include "FuncRequest.h"
-#include "gettext.h"
+#include "support/gettext.h"
#include "frontends/Clipboard.h"
#include "frontends/Painter.h"
#include "support/lstrings.h"
+#include "support/docstream.h"
#include <sstream>
+using namespace std;
+using namespace lyx::support;
namespace lyx {
-using support::bformat;
-
-using std::endl;
-using std::max;
-using std::min;
-using std::swap;
-
-using std::string;
-using std::istream;
-using std::istringstream;
-using std::vector;
-
-
namespace {
docstring verboseHLine(int n)
InsetMathGrid::RowInfo::RowInfo()
- : lines_(0), skip_(0), allow_pagebreak_(true)
+ : lines_(0), skip_(0), allow_newpage_(true)
{}
}
--it;
if (newcolumn) {
- colinfo_[col].lines_ = std::count(
+ colinfo_[col].lines_ = count(
colinfo_[col].special_.begin(),
colinfo_[col].special_.end(), '|');
- LYXERR(Debug::MATHED)
- << "special column separator: `"
- << to_utf8(colinfo_[col].special_)
- << '\'' << endl;
+ LYXERR(Debug::MATHED, "special column separator: `"
+ << to_utf8(colinfo_[col].special_) << '\'');
++col;
colinfo_[col].lines_ = 0;
colinfo_[col].special_.clear();
colinfo_[col].align_ = static_cast<char>(c);
if (!colinfo_[col].special_.empty()) {
colinfo_[col].special_ += c;
- colinfo_[col].lines_ = std::count(
+ colinfo_[col].lines_ = count(
colinfo_[col].special_.begin(),
colinfo_[col].special_.end(), '|');
- LYXERR(Debug::MATHED)
- << "special column separator: `"
- << to_utf8(colinfo_[col].special_)
- << '\'' << endl;
+ LYXERR(Debug::MATHED, "special column separator: `"
+ << to_utf8(colinfo_[col].special_) << '\'');
}
++col;
colinfo_[col].lines_ = 0;
void InsetMathGrid::draw(PainterInfo & pi, int x, int y) const
{
- drawWithMargin(pi, x, y, 0, 0);
+ drawWithMargin(pi, x, y, 1, 1);
}
- i * hlinesep() - hlinesep()/2 - rowsep()/2;
pi.pain.line(x + lmargin + 1, yy,
x + dim.width() - rmargin - 1, yy,
- Color::foreground);
+ Color_foreground);
}
for (col_type col = 0; col <= ncols(); ++col)
- i * vlinesep() - vlinesep()/2 - colsep()/2;
pi.pain.line(xx, y - dim.ascent() + 1,
xx, y + dim.descent() - 1,
- Color::foreground);
+ Color_foreground);
}
drawMarkers2(pi, x, y);
}
}
-void InsetMathGrid::drawT(TextPainter & pain, int x, int y) const
+void InsetMathGrid::drawT(TextPainter & /*pain*/, int /*x*/, int /*y*/) const
{
// for (idx_type idx = 0; idx < nargs(); ++idx)
// cell(idx).drawT(pain, x + cellXOffset(idx), y + cellYOffset(idx));
if (!rowinfo_[row].crskip_.zero())
eol += '[' + from_utf8(rowinfo_[row].crskip_.asLatexString()) + ']';
- else if(!rowinfo_[row].allow_pagebreak_)
+ else if(!rowinfo_[row].allow_newpage_)
eol += '*';
// make sure an upcoming '[' does not break anything
return false;
cur.idx() += ncols();
}
- cur.pos() = cur.cell().x2pos(cur.x_target() - cur.cell().xo(cur.bv()));
+ cur.pos() = cur.cell().x2pos(&cur.bv(), cur.x_target() - cur.cell().xo(cur.bv()));
return true;
}
-bool InsetMathGrid::idxLeft(Cursor & cur) const
+bool InsetMathGrid::idxBackward(Cursor & cur) const
{
- // leave matrix if on the left hand edge
+ // leave matrix if at the front edge
if (cur.col() == 0)
return false;
--cur.idx();
}
-bool InsetMathGrid::idxRight(Cursor & cur) const
+bool InsetMathGrid::idxForward(Cursor & cur) const
{
- // leave matrix if on the right hand edge
+ // leave matrix if at the back edge
if (cur.col() + 1 == ncols())
return false;
++cur.idx();
// See below.
cur.selection() = false;
if (!idxPrev(cur)) {
- cmd = FuncRequest(LFUN_FINISHED_LEFT);
+ cmd = FuncRequest(LFUN_FINISHED_BACKWARD);
cur.undispatched();
}
break;
// hard bound to LFUN_CELL_BACKWARD
cur.selection() = false;
if (!idxNext(cur)) {
- cmd = FuncRequest(LFUN_FINISHED_RIGHT);
+ cmd = FuncRequest(LFUN_FINISHED_FORWARD);
cur.undispatched();
}
break;
- case LFUN_BREAK_LINE: {
+ case LFUN_NEW_LINE: {
cur.recordUndoInset();
row_type const r = cur.row();
addRow(r);
cur.pos() = cur.lastpos();
//mathcursor->normalize();
- //cmd = FuncRequest(LFUN_FINISHED_LEFT);
+ //cmd = FuncRequest(LFUN_FINISHED_BACKWARD);
break;
}
for (int i = 0, n = extractInt(is); i < n; ++i)
addRow(cur.row());
else if (s == "delete-row") {
+ cur.clearSelection(); // bug 4323
for (int i = 0, n = extractInt(is); i < n; ++i) {
delRow(cur.row());
if (cur.idx() >= nargs())
row_type const r = cur.row();
col_type const c = cur.col();
for (int i = 0, n = extractInt(is); i < n; ++i)
- addCol(cur.col());
+ addCol(cur.col() + 1);
cur.idx() = index(r, c);
}
else if (s == "delete-column") {
+ cur.clearSelection(); // bug 4323
row_type const r = cur.row();
col_type const c = cur.col();
for (int i = 0, n = extractInt(is); i < n; ++i)
cur.undispatched();
break;
}
+ // perhaps this should be FINISHED_BACKWARD -- just for clarity?
lyxerr << "returning FINISHED_LEFT" << endl;
break;
}
case LFUN_LINE_BEGIN:
case LFUN_WORD_BACKWARD_SELECT:
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.macroModeClose();
if (cur.pos() != 0) {
cur.idx() = 0;
cur.pos() = 0;
} else {
- cmd = FuncRequest(LFUN_FINISHED_LEFT);
+ cmd = FuncRequest(LFUN_FINISHED_BACKWARD);
cur.undispatched();
}
break;
case LFUN_WORD_FORWARD_SELECT:
case LFUN_WORD_FORWARD:
+ case LFUN_WORD_RIGHT_SELECT:
+ 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.macroModeClose();
cur.clearTargetX();
cur.idx() = cur.lastidx();
cur.pos() = cur.lastpos();
} else {
- cmd = FuncRequest(LFUN_FINISHED_RIGHT);
+ cmd = FuncRequest(LFUN_FINISHED_FORWARD);
cur.undispatched();
}
break;
status.enable(false);
break;
}
- if (!support::contains("tcb", cmd.argument()[0])) {
+ if (!contains("tcb", cmd.argument()[0])) {
status.enable(false);
break;
}