#include "frontends/Painter.h"
+#include "support/lassert.h"
#include "support/debug.h"
#include "support/gettext.h"
#include "support/lstrings.h"
static InsetLabel * dummy_pointer = 0;
InsetMathHull::InsetMathHull()
- : InsetMathGrid(1, 1), type_(hullNone), nonum_(1, false), label_(1, dummy_pointer),
- preview_(new RenderPreview(this))
+ : InsetMathGrid(1, 1), type_(hullNone), nonum_(1, false),
+ label_(1, dummy_pointer), preview_(new RenderPreview(this))
{
//lyxerr << "sizeof InsetMath: " << sizeof(InsetMath) << endl;
//lyxerr << "sizeof MetricsInfo: " << sizeof(MetricsInfo) << endl;
InsetMathHull::InsetMathHull(HullType type)
- : InsetMathGrid(getCols(type), 1), type_(type), nonum_(1, false), label_(1, dummy_pointer),
- preview_(new RenderPreview(this))
+ : InsetMathGrid(getCols(type), 1), type_(type), nonum_(1, false),
+ label_(1, dummy_pointer), preview_(new RenderPreview(this))
{
initMath();
setDefaults();
}
-namespace {
-
-docstring const latex_string(InsetMathHull const & inset)
+static docstring latexString(InsetMathHull const & inset)
{
odocstringstream ls;
WriteStream wi(ls, false, false);
return ls.str();
}
-} // namespace anon
-
void InsetMathHull::addPreview(graphics::PreviewLoader & ploader) const
{
if (RenderPreview::status() == LyXRC::PREVIEW_ON) {
- docstring const snippet = latex_string(*this);
+ docstring const snippet = latexString(*this);
preview_->addPreview(snippet, ploader);
}
}
{
if (RenderPreview::status() == LyXRC::PREVIEW_ON) {
Buffer const & buffer = cur.buffer();
- docstring const snippet = latex_string(*this);
+ docstring const snippet = latexString(*this);
preview_->addPreview(snippet, buffer);
preview_->startLoading(buffer);
cur.updateFlags(Update::Force);
docstring InsetMathHull::label(row_type row) const
{
- BOOST_ASSERT(row < nrows());
+ LASSERT(row < nrows(), /**/);
if (InsetLabel * il = label_[row])
return il->screenLabel();
return docstring();
if (label_[row]) {
if (label.empty()) {
delete label_[row];
- nonum_[row] = true;
label_[row] = dummy_pointer;
} else
label_[row]->updateCommand(label);
//if (features.amsstyle)
// return;
- features.require("boldsymbol");
//features.binom = true;
InsetMathGrid::validate(features);
{
if (!rowChangeOK())
return;
- nonum_.insert(nonum_.begin() + row + 1, !numberedType());
+
+ bool numbered = numberedType();
+ docstring lab;
+ if (type_ == hullMultline) {
+ if (row + 1 == nrows()) {
+ nonum_[row] = true;
+ lab = label(row);
+ } else
+ numbered = false;
+ }
+
+ nonum_.insert(nonum_.begin() + row + 1, !numbered);
label_.insert(label_.begin() + row + 1, dummy_pointer);
+ if (!lab.empty())
+ label(row + 1, lab);
InsetMathGrid::addRow(row);
}
{
if (nrows() <= 1 || !rowChangeOK())
return;
+ if (row + 1 == nrows() && type_ == hullMultline) {
+ bool const b = nonum_[row - 1];
+ nonum_[row - 1] = nonum_[row];
+ nonum_[row] = b;
+ swap(label_[row - 1], label_[row]);
+ InsetMathGrid::delRow(row);
+ return;
+ }
InsetMathGrid::delRow(row);
// The last dummy row has no number info nor a label.
// Test nrows() + 1 because we have already erased the row.
return docstring();
if (!label_[row])
return from_ascii("(#)");
- return '(' + label_[row]->screenLabel() + ')';
+ return '(' + label_[row]->screenLabel() + from_ascii(", #)");
}
void InsetMathHull::splitTo2Cols()
{
- BOOST_ASSERT(ncols() == 1);
+ LASSERT(ncols() == 1, /**/);
InsetMathGrid::addCol(1);
for (row_type row = 0; row < nrows(); ++row) {
idx_type const i = 2 * row;
void InsetMathHull::splitTo3Cols()
{
- BOOST_ASSERT(ncols() < 3);
+ LASSERT(ncols() < 3, /**/);
if (ncols() < 2)
splitTo2Cols();
InsetMathGrid::addCol(2);
void InsetMathHull::check() const
{
- BOOST_ASSERT(nonum_.size() == nrows());
- BOOST_ASSERT(label_.size() == nrows());
+ LASSERT(nonum_.size() == nrows(), /**/);
+ LASSERT(label_.size() == nrows(), /**/);
}
// just swallow this
break;
- case LFUN_NEW_LINE:
+ case LFUN_NEWLINE_INSERT:
// some magic for the common case
if (type_ == hullSimple || type_ == hullEquation) {
cur.recordUndoInset();
InsetCommandParams p(LABEL_CODE);
p["name"] = cmd.argument().empty() ? old_label : cmd.argument();
- string const data = InsetCommandMailer::params2string("label", p);
+ string const data = InsetCommand::params2string("label", p);
if (cmd.argument().empty())
cur.bv().showDialog("label", data);
string const name = cmd.getArg(0);
if (name == "label") {
InsetCommandParams p(LABEL_CODE);
- InsetCommandMailer::string2params(name, to_utf8(cmd.argument()), p);
+ InsetCommand::string2params(name, to_utf8(cmd.argument()), p);
docstring str = p["name"];
cur.recordUndoInset();
row_type const r = (type_ == hullMultline) ? nrows() - 1 : cur.row();
case LFUN_FINISHED_LEFT:
case LFUN_UP:
case LFUN_DOWN:
- case LFUN_NEW_LINE:
+ case LFUN_NEWLINE_INSERT:
case LFUN_MATH_EXTERN:
case LFUN_MATH_MUTATE:
case LFUN_MATH_DISPLAY:
case LFUN_MATH_NUMBER_LINE_TOGGLE: {
// FIXME: what is the right test, this or the one of
// LABEL_INSERT?
- status.enabled(display());
+ bool const enable = (type_ == hullMultline) ?
+ (nrows() - 1 == cur.row()) : display();
row_type const r = (type_ == hullMultline) ? nrows() - 1 : cur.row();
+ status.enabled(enable);
status.setOnOff(numbered(r));
return true;
}
#if 0
// translate to latex
ostringstream os;
- latex(NULL, os, false, false);
+ latex(os, false, false);
string str = os.str();
// insert this text
// translate to latex
cur.markInsert(bv);
ostringstream os;
- write(NULL, os);
+ write(os);
string str = os.str();
cur.markErase(bv);
string::size_type pos = 0;