Counters & cnts =
buffer_->masterBuffer()->params().documentClass().counters();
- // right now, we only need to do this at export time
- if (utype == OutputUpdate) {
- for (size_t i = 0; i < numcnts; ++i) {
- docstring const cnt = from_ascii(counters_to_save[i]);
- if (cnts.hasCounter(cnt))
- counter_map[cnt] = cnts.value(cnt);
- }
- }
-
// this has to be done separately
docstring const eqstr = from_ascii("equation");
if (cnts.hasCounter(eqstr)) {
- if (utype == OutputUpdate)
- counter_map[eqstr] = cnts.value(eqstr);
for (size_t i = 0; i != label_.size(); ++i) {
if (numbered(i)) {
Paragraph const & par = it.paragraph();
int extra_offset = 0;
for (row_type row = 0; row < nrows(); ++row) {
rowinfo(row).offset[mi.base.bv] += extra_offset;
- if (!numbered(row))
- continue;
docstring const nl = nicelabel(row);
+ if (nl.empty())
+ continue;
Dimension dimnl;
mathed_string_dim(mi.base.font, nl, dimnl);
int const ind = indent(*mi.base.bv);
dim.wid, dim.asc + dim.des, backgroundColor(pi));
return;
}
- // If there are numbers, the margins around the (displayed)
- // equation have to be cleared.
- if (numberedType())
- pi.pain.fillRectangle(pi.leftx, y - dim.asc,
- pi.rightx - pi.leftx, dim.height(), pi.background_color);
+
pi.pain.fillRectangle(x + 1, y - dim.asc + 1, dim.wid - 2,
- dim.asc + dim.des - 1, pi.backgroundColor(this));
+ dim.height() - 1, pi.backgroundColor(this));
}
}
// First draw the numbers
- ColorCode color = pi.selected && lyxrc.use_system_colors
- ? Color_selectiontext : standardColor();
- bool const really_change_color = pi.base.font.color() == Color_none;
- Changer dummy0 = really_change_color ? pi.base.font.changeColor(color)
- : noChange();
if (numberedType()) {
BufferParams::MathNumber const math_number = buffer().params().getMathNumber();
for (row_type row = 0; row < nrows(); ++row) {
Dimension dimnl;
mathed_string_dim(pi.base.font, nl, dimnl);
if (math_number == BufferParams::LEFT) {
+ ColorCode const col = pi.selected_left
+ ? Color_selectiontext
+ : pi.base.font.color();
+ Changer dummy0 = pi.base.font.changeColor(col);
if (dimnl.wid > x - pi.leftx)
yy += rowinfo(row).descent + dimnl.asc;
+ pi.pain.fillRectangle(pi.leftx, yy - dimnl.asc,
+ dimnl.width(), dimnl.height(),
+ pi.selected_left ? Color_selection : pi.background_color);
pi.draw(pi.leftx, yy, nl);
} else {
+ ColorCode const col = pi.selected_right
+ ? Color_selectiontext
+ : pi.base.font.color();
+ Changer dummy0 = pi.base.font.changeColor(col);
if (dimnl.wid > pi.rightx - x - dim.wid)
yy += rowinfo(row).descent + dimnl.asc;
+ pi.pain.fillRectangle(pi.rightx - dimnl.wid, yy - dimnl.asc,
+ dimnl.width(), dimnl.height(),
+ pi.selected_right ? Color_selection : pi.background_color);
pi.draw(pi.rightx - dimnl.wid, yy, nl);
}
}
}
// Then the equations
+ ColorCode color = pi.selected && lyxrc.use_system_colors
+ ? Color_selectiontext : standardColor();
+ bool const really_change_color = pi.base.font.color() == Color_none;
+ Changer dummy0 = really_change_color ? pi.base.font.changeColor(color)
+ : noChange();
Changer dummy1 = pi.base.changeFontSet(standardFont());
Changer dummy2 = pi.base.font.changeStyle(display() ? DISPLAY_STYLE
: TEXT_STYLE);
if (lsize != "normalsize" && !prefixIs(lsize, "error"))
setfont += from_ascii("\\" + lsize + '\n');
- docstring setcnt;
- if (forexport && haveNumbers()) {
- docstring eqstr = from_ascii("equation");
- CounterMap::const_iterator it = counter_map.find(eqstr);
- if (it != counter_map.end()) {
- int num = it->second;
- if (num >= 0)
- setcnt += from_ascii("\\setcounter{") + eqstr + '}' +
- '{' + convert<docstring>(num) + '}' + '\n';
- }
- for (size_t i = 0; i != numcnts; ++i) {
- docstring cnt = from_ascii(counters_to_save[i]);
- it = counter_map.find(cnt);
- if (it == counter_map.end())
- continue;
- int num = it->second;
- if (num > 0)
- setcnt += from_ascii("\\setcounter{") + cnt + '}' +
- '{' + convert<docstring>(num) + '}';
- }
- }
- docstring const snippet = macro_preamble + setfont + setcnt
- + latexString(*this) + endfont;
+ docstring const snippet = macro_preamble + setfont + latexString(*this) + endfont;
LYXERR(Debug::MACROS, "Preview snippet: " << snippet);
preview_->addPreview(snippet, *buffer, forexport);
}
void InsetMathHull::numbered(row_type row, Numbered num)
{
numbered_[row] = num;
- if (!numbered(row) && label_[row]) {
- delete label_[row];
- label_[row] = 0;
- }
}
}
-Inset::RowFlags InsetMathHull::rowFlags() const
+int InsetMathHull::rowFlags() const
{
switch (type_) {
case hullUnknown:
docstring InsetMathHull::nicelabel(row_type row) const
{
- if (!numbered(row))
- return docstring();
+ if (!numbered(row)) {
+ if (!label_[row])
+ return docstring();
+ return '[' + label_[row]->screenLabel() + ']';
+ }
docstring const & val = numbers_[row];
if (!label_[row])
return '(' + val + ')';
}
-docstring InsetMathHull::eolString(row_type row, bool fragile, bool latex,
- bool last_eoln) const
+void InsetMathHull::eol(TeXMathStream & os, row_type row, bool fragile, bool latex,
+ bool last_eoln) const
{
- docstring res;
if (numberedType()) {
- if (label_[row] && numbered(row)) {
+ if (label_[row]) {
docstring const name =
latex ? escape(label_[row]->getParam("name"))
: label_[row]->getParam("name");
- res += "\\label{" + name + '}';
+ os << "\\label{" + name + '}';
}
if (type_ != hullMultline) {
if (numbered_[row] == NONUMBER)
- res += "\\nonumber ";
+ os << "\\nonumber ";
else if (numbered_[row] == NOTAG)
- res += "\\notag ";
+ os<< "\\notag ";
+ }
+ if (os.output() == TeXMathStream::wsPreview && !numbers_[row].empty()) {
+ os << "\\global\\def\\theequation{" << numbers_[row] << "}\n";
}
+
}
// Never add \\ on the last empty line of eqnarray and friends
last_eoln = false;
- return res + InsetMathGrid::eolString(row, fragile, latex, last_eoln);
+ InsetMathGrid::eol(os, row, fragile, latex, last_eoln);
}
void InsetMathHull::write(TeXMathStream & os) const
// if there is an argument, find the corresponding label, else
// check whether there is at least one label.
for (row = 0; row != nrows(); ++row)
- if (numbered(row) && label_[row]
+ if (label_[row]
&& (cmd.argument().empty() || label(row) == cmd.argument()))
break;
}
// if there is no argument and we're inside math, we retrieve
// the row number from the cursor position.
row_type row = (type_ == hullMultline) ? nrows() - 1 : cur.row();
- enabled = numberedType() && label_[row] && numbered(row);
+ enabled = numberedType() && label_[row];
} else {
// if there is an argument, find the corresponding label, else
// check whether there is at least one label.
for (row_type row = 0; row != nrows(); ++row) {
- if (numbered(row) && label_[row] &&
+ if (label_[row] &&
(cmd.argument().empty() || label(row) == cmd.argument())) {
enabled = true;
break;
void InsetMathHull::edit(Cursor & cur, bool front, EntryDirection entry_from)
{
- InsetMathNest::edit(cur, front, entry_from);
+ cur.push(*this);
+ bool enter_front = (entry_from == Inset::ENTRY_DIRECTION_LEFT ||
+ (entry_from == Inset::ENTRY_DIRECTION_IGNORE && front));
+ enter_front ? idxFirst(cur) : idxLast(cur);
// The inset formula dimension is not necessarily the same as the
// one of the instant preview image, so we have to indicate to the
// BufferView that a metrics update is needed.
odocstringstream oss;
otexrowstream ots(oss);
Encoding const * const enc = encodings.fromLyXName("utf8");
- TeXMathStream wi(ots, false, true, TeXMathStream::wsDefault, enc);
+ TeXMathStream::OutputType ot;
+ if (op.find_effective())
+ ot = TeXMathStream::wsSearchAdv;
+ else
+ ot = TeXMathStream::wsDefault;
// Fix Bug #6139
- if (type_ == hullRegexp)
+ if (type_ == hullRegexp) {
+ TeXMathStream wi(ots, false, true, ot, enc);
write(wi);
+ }
else {
+ TeXMathStream wi(ots, false, true, ot, enc);
for (row_type r = 0; r < nrows(); ++r) {
for (col_type c = 0; c < ncols(); ++c)
wi << (c == 0 ? "" : "\t") << cell(index(r, c));
// executed, and the formula is not output to the DocBook stream.
odocstringstream ostmp;
MathMLStream mstmp(ostmp, ms.xmlns(), ms.xmlMode());
- InsetMathGrid::mathmlize(mstmp);
+ mathmlize(mstmp);
// Choose the display style for the formula, to be output as an attribute near the formula root.
std::string mathmlAttr;
// and we simply do not have that in InsetMathGrid.
void InsetMathHull::mathmlize(MathMLStream & ms) const
{
- bool const havenumbers = haveNumbers();
- bool const havetable = havenumbers || nrows() > 1 || ncols() > 1;
+ bool const havetable = haveNumbers() || nrows() > 1 || ncols() > 1;
+
+ if (havetable) {
+ if (getType() == hullSimple) {
+ ms << MTag("mtable");
+ } else if (getType() >= hullAlign && getType() <= hullXXAlignAt) {
+ string alignment;
+ for (col_type col = 0; col < ncols(); ++col) {
+ alignment += (col % 2) ? "left " : "right ";
+ }
+ ms << MTag("mtable", "displaystyle='true' columnalign='" + alignment + "'");
+ } else {
+ ms << MTag("mtable", "displaystyle='true'");
+ }
+ }
- if (havetable)
- ms << MTag("mtable");
char const * const celltag = havetable ? "mtd" : "mrow";
// FIXME There does not seem to be wide support at the moment
// for mlabeledtr, so we have to use just mtr for now.
- // char const * const rowtag = havenumbers ? "mlabeledtr" : "mtr";
+ // char const * const rowtag = haveNumbers() ? "mlabeledtr" : "mtr";
char const * const rowtag = "mtr";
for (row_type row = 0; row < nrows(); ++row) {
if (havetable)
<< ETag(celltag);
}
// fleqn?
- if (havenumbers) {
+ if (haveNumbers()) {
ms << MTag("mtd");
docstring const & num = numbers_[row];
if (!num.empty())
- ms << '(' << num << ')';
- ms << ETag("mtd");
+ ms << MTagInline("mtext") << '(' << num << ')' << ETagInline("mtext");
+ ms << ETag("mtd");
}
if (havetable)
ms << ETag(rowtag);