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);
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;
- }
}
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));