X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmathed%2FInsetMathHull.cpp;h=92574c8d2a0eac7e3b79c91236f7b94f54fd330f;hb=67215833a174bfb1db8a259f61ed57ae67e10655;hp=8f40d2cff1fbb7e31cbb64d814b3fc5252e08226;hpb=56e012be83fd4fec1e21d750e961ff936cc8c889;p=lyx.git diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp index 8f40d2cff1..92574c8d2a 100644 --- a/src/mathed/InsetMathHull.cpp +++ b/src/mathed/InsetMathHull.cpp @@ -198,7 +198,7 @@ docstring hullName(HullType type) static InsetLabel * dummy_pointer = 0; InsetMathHull::InsetMathHull(Buffer * buf) - : InsetMathGrid(buf, 1, 1), type_(hullNone), numbered_(1, NUMBER), + : InsetMathGrid(buf, 1, 1), type_(hullNone), numbered_(1, NONUMBER), numbers_(1, empty_docstring()), label_(1, dummy_pointer), preview_(new RenderPreview(this)) { @@ -316,8 +316,12 @@ void InsetMathHull::updateBuffer(ParIterator const & it, UpdateType utype) counter_map[eqstr] = cnts.value(eqstr); for (size_t i = 0; i != label_.size(); ++i) { if (numbered(i)) { - cnts.step(eqstr, utype); - numbers_[i] = cnts.theCounter(eqstr, lang); + Paragraph const & par = it.paragraph(); + if (!par.isDeleted(it.pos())) { + cnts.step(eqstr, utype); + numbers_[i] = cnts.theCounter(eqstr, lang); + } else + numbers_[i] = from_ascii("#"); } else numbers_[i] = empty_docstring(); } @@ -419,22 +423,6 @@ InsetMath::mode_type InsetMathHull::currentMode() const } -bool InsetMathHull::idxFirst(Cursor & cur) const -{ - cur.idx() = 0; - cur.pos() = 0; - return true; -} - - -bool InsetMathHull::idxLast(Cursor & cur) const -{ - cur.idx() = nargs() - 1; - cur.pos() = cur.lastpos(); - return true; -} - - // FIXME: InsetMathGrid should be changed to let the real column alignment be // given by a virtual method like displayColAlign, because the values produced // by defaultColAlign can be invalidated by lfuns such as add-column. For the @@ -442,7 +430,7 @@ bool InsetMathHull::idxLast(Cursor & cur) const // alignment is not implemented in the LyXHTML output. char InsetMathHull::defaultColAlign(col_type col) { - return colAlign(type_, col); + return colAlign(type_, col, buffer().params()); } @@ -464,7 +452,7 @@ char InsetMathHull::displayColAlign(idx_type idx) const case hullXAlignAt: case hullXXAlignAt: case hullFlAlign: - return colAlign(type_, col(idx)); + return colAlign(type_, col(idx), buffer().params()); default: break; } @@ -561,8 +549,8 @@ void InsetMathHull::metrics(MetricsInfo & mi, Dimension & dim) const } Changer dummy1 = mi.base.changeFontSet(standardFont()); - Changer dummy2 = mi.base.font.changeStyle(display() ? LM_ST_DISPLAY - : LM_ST_TEXT); + Changer dummy2 = mi.base.font.changeStyle(display() ? FONT_STYLE_DISPLAY + : FONT_STYLE_TEXT); // let the cells adjust themselves InsetMathGrid::metrics(mi, dim); @@ -585,13 +573,6 @@ void InsetMathHull::metrics(MetricsInfo & mi, Dimension & dim) const // reserve some space for marker. dim.wid += 2; - - // make it at least as high as the current font - int asc = 0; - int des = 0; - math_font_max_dim(mi.base.font, asc, des); - dim.asc = max(dim.asc, asc); - dim.des = max(dim.des, des); } @@ -672,8 +653,8 @@ void InsetMathHull::draw(PainterInfo & pi, int x, int y) const Changer dummy0 = really_change_color ? pi.base.font.changeColor(color) : Changer(); Changer dummy1 = pi.base.changeFontSet(standardFont()); - Changer dummy2 = pi.base.font.changeStyle(display() ? LM_ST_DISPLAY - : LM_ST_TEXT); + Changer dummy2 = pi.base.font.changeStyle(display() ? FONT_STYLE_DISPLAY + : FONT_STYLE_TEXT); int xmath = x; BufferParams::MathNumber const math_number = buffer().params().getMathNumber(); @@ -1741,13 +1722,11 @@ void InsetMathHull::check() const void InsetMathHull::doExtern(Cursor & cur, FuncRequest & func) { - docstring dlang; - docstring extra; - idocstringstream iss(func.argument()); - iss >> dlang >> extra; + //FIXME: sort out whether we want std::string or docstring for those + string const lang = func.getArg(0); + docstring extra = from_utf8(func.getArg(1)); if (extra.empty()) extra = from_ascii("noextra"); - string const lang = to_ascii(dlang); // replace selection with result of computation if (reduceSelectionToOneCell(cur)) { @@ -2253,17 +2232,14 @@ void InsetMathHull::handleFont2(Cursor & cur, docstring const & arg) font.fromString(to_utf8(arg), b); if (font.fontInfo().color() != Color_inherit) { MathAtom at = MathAtom(new InsetMathColor(buffer_, true, font.fontInfo().color())); - cur.handleNest(at, 0); + cur.handleNest(at); } } void InsetMathHull::edit(Cursor & cur, bool front, EntryDirection 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); + InsetMathNest::edit(cur, front, entry_from); // 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.