X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2FInsetScript.cpp;h=f87f6c474765f4a6b6888b442f8580cb69f4dbc8;hb=62af7ee772f16f154225d2d0b65d77f4376b6001;hp=779464c7cd84009463d160963ec0da1bcf725000;hpb=fdbe775b9f5468e8f53dc83a66583f412b5970fb;p=lyx.git diff --git a/src/insets/InsetScript.cpp b/src/insets/InsetScript.cpp index 779464c7cd..f87f6c4747 100644 --- a/src/insets/InsetScript.cpp +++ b/src/insets/InsetScript.cpp @@ -81,7 +81,7 @@ ScriptTranslatorLoc const & scripttranslator_loc() return translator; } -} // anon +} // namespace InsetScriptParams::InsetScriptParams() @@ -160,7 +160,9 @@ Inset::DisplayType InsetScript::display() const void InsetScript::metrics(MetricsInfo & mi, Dimension & dim) const { int const shift = params_.shift(mi.base.font); - ScriptChanger dummy(mi.base); + // Remember the value of the outser font, so that it can be used in cursorPos. + outer_font_ = mi.base.font; + Changer dummy = mi.base.changeScript(); InsetText::metrics(mi, dim); dim.asc -= shift; dim.des += shift; @@ -170,7 +172,7 @@ void InsetScript::metrics(MetricsInfo & mi, Dimension & dim) const void InsetScript::draw(PainterInfo & pi, int x, int y) const { int const shift = params_.shift(pi.base.font); - ScriptChanger dummy(pi.base); + Changer dummy = pi.base.changeScript(); InsetText::draw(pi, x, y + shift); } @@ -178,8 +180,7 @@ void InsetScript::draw(PainterInfo & pi, int x, int y) const void InsetScript::cursorPos(BufferView const & bv, CursorSlice const & sl, bool boundary, int & x, int & y) const { - Font const font = bv.textMetrics(&text()).displayFont(sl.pit(), sl.pos()); - int const shift = params_.shift(font.fontInfo()); + int const shift = params_.shift(outer_font_); InsetText::cursorPos(bv, sl, boundary, x, y); y += shift; } @@ -216,7 +217,7 @@ void InsetScript::doDispatch(Cursor & cur, FuncRequest & cmd) { switch (cmd.action()) { case LFUN_INSET_MODIFY: - cur.recordUndoInset(ATOMIC_UNDO, this); + cur.recordUndoInset(this); string2params(to_utf8(cmd.argument()), params_); break; default: @@ -235,7 +236,7 @@ bool InsetScript::insetAllowed(InsetCode code) const case BOX_CODE: case BRANCH_CODE: case CAPTION_CODE: - case COLLAPSABLE_CODE: + case COLLAPSIBLE_CODE: case FLOAT_CODE: case FLOAT_LIST_CODE: case FOOT_CODE: @@ -263,9 +264,6 @@ bool InsetScript::getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus & flag) const { switch (cmd.action()) { - case LFUN_PARAGRAPH_BREAK: - case LFUN_LAYOUT: - case LFUN_LAYOUT_PARAGRAPH: case LFUN_MATH_DISPLAY: case LFUN_BOX_INSERT: case LFUN_BRANCH_INSERT: @@ -283,13 +281,14 @@ bool InsetScript::getStatus(Cursor & cur, FuncRequest const & cmd, case LFUN_PREVIEW_INSERT: case LFUN_QUOTE_INSERT: case LFUN_TABULAR_INSERT: + case LFUN_TABULAR_STYLE_INSERT: case LFUN_WRAP_INSERT: flag.setEnabled(false); return true; case LFUN_INSET_MODIFY: flag.setEnabled(true); return true; - case LFUN_COMMAND_SEQUENCE: { + case LFUN_COMMAND_SEQUENCE: { // argument contains ';'-terminated commands string arg = to_utf8(cmd.argument()); // prevent insertion of display math formulas like AMS align @@ -318,8 +317,7 @@ docstring InsetScript::toolTip(BufferView const &, int, int) const InsetText::plaintext(ods, rp, 200); docstring content_tip = ods.str(); // shorten it if necessary - if (content_tip.size() >= 200) - content_tip = content_tip.substr(0, 197) + "..."; + support::truncateWithEllipsis(content_tip, 200); docstring res = scripttranslator_loc().find(params_.type); if (!content_tip.empty()) res += from_ascii(": ") + content_tip; @@ -364,13 +362,13 @@ int InsetScript::plaintext(odocstringstream & os, int InsetScript::docbook(odocstream & os, OutputParams const & runparams) const { - string cmdname; + docstring cmdname; switch (params_.type) { case InsetScriptParams::Subscript: - cmdname = "subscript"; + cmdname = from_ascii("subscript"); break; case InsetScriptParams::Superscript: - cmdname = "superscript"; + cmdname = from_ascii("superscript"); break; } os << '<' + cmdname + '>';