]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetScript.cpp
Check in InsetLabel if LFUN_INSET_MODIFY is intended for us.
[lyx.git] / src / insets / InsetScript.cpp
index 514445a943b35acf742132ac8bce0b3fa84c6dce..c98a9bed483bc3304922edec054eb0fd541a5359 100644 (file)
@@ -143,9 +143,9 @@ InsetScript::~InsetScript()
 }
 
 
-docstring InsetScript::name() const 
+docstring InsetScript::layoutName() const
 {
-       return from_ascii("script:" + scripttranslator().find(params_.type));
+       return from_ascii("Script:" + scripttranslator().find(params_.type));
 }
 
 
@@ -214,6 +214,7 @@ void InsetScript::doDispatch(Cursor & cur, FuncRequest & cmd)
 {
        switch (cmd.action()) {
        case LFUN_INSET_MODIFY:
+               cur.recordUndoInset(ATOMIC_UNDO, this);
                string2params(to_utf8(cmd.argument()), params_);
                break;
        default:
@@ -260,7 +261,7 @@ bool InsetScript::getStatus(Cursor & cur, FuncRequest const & cmd,
                FuncStatus & flag) const
 {
        switch (cmd.action()) {
-       case LFUN_BREAK_PARAGRAPH:
+       case LFUN_PARAGRAPH_BREAK:
        case LFUN_LAYOUT:
        case LFUN_LAYOUT_PARAGRAPH:
        case LFUN_MATH_DISPLAY:
@@ -271,7 +272,6 @@ bool InsetScript::getStatus(Cursor & cur, FuncRequest const & cmd,
        case LFUN_FLOAT_LIST_INSERT:
        case LFUN_FLOAT_WIDE_INSERT:
        case LFUN_FOOTNOTE_INSERT:
-       case LFUN_HFILL_INSERT:
        case LFUN_INDEX_PRINT:
        case LFUN_LISTING_INSERT:
        case LFUN_MARGINALNOTE_INSERT:
@@ -313,11 +313,11 @@ docstring InsetScript::toolTip(BufferView const &, int, int) const
 {
        OutputParams rp(&buffer().params().encoding());
        odocstringstream ods;
-       InsetText::plaintext(ods, rp);
+       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, 200) + "...";
+       if (content_tip.size() >= 200)
+               content_tip = content_tip.substr(0, 197) + "...";
        docstring res = scripttranslator_loc().find(params_.type);
        if (!content_tip.empty())
                res += from_ascii(": ") + content_tip;
@@ -325,35 +325,11 @@ docstring InsetScript::toolTip(BufferView const &, int, int) const
 }
 
 
-void InsetScript::validate(LaTeXFeatures & features) const
-{
-       if (params_.type == InsetScriptParams::Subscript)
-               features.require("subscript");
-       InsetText::validate(features);
-}
-
-
-int InsetScript::latex(odocstream & os, OutputParams const & runparams) const
-{
-       switch (params_.type) {
-       case InsetScriptParams::Subscript:
-               os << "\\textsubscript{";
-               break;
-       case InsetScriptParams::Superscript:
-               os << "\\textsuperscript{";
-               break;
-       }
-       int const i = InsetText::latex(os, runparams);
-       os << "}";
-
-       return i;
-}
-
-
-int InsetScript::plaintext(odocstream & os, OutputParams const & runparams) const
+int InsetScript::plaintext(odocstringstream & os,
+        OutputParams const & runparams, size_t max_length) const
 {
        odocstringstream oss;
-       InsetText::plaintext(oss, runparams);
+       InsetText::plaintext(oss, runparams, max_length);
        docstring const text = oss.str();
        switch (params_.type) {
        case InsetScriptParams::Subscript:
@@ -377,7 +353,7 @@ int InsetScript::plaintext(odocstream & os, OutputParams const & runparams) cons
                os << '[' << buffer().B_("superscript") << ':';
                break;
        }
-       InsetText::plaintext(os, runparams);
+       InsetText::plaintext(os, runparams, max_length);
        os << ']';
 
        return PLAINTEXT_NEWLINE;
@@ -403,28 +379,9 @@ int InsetScript::docbook(odocstream & os, OutputParams const & runparams) const
 }
 
 
-docstring InsetScript::xhtml(XHTMLStream & xs, OutputParams const & runparams) const
-{
-       string cmdname;
-       switch (params_.type) {
-       case InsetScriptParams::Subscript:
-               cmdname = "sub";
-               break;
-       case InsetScriptParams::Superscript:
-               cmdname = "sup";
-               break;
-       }
-
-       xs << html::StartTag(cmdname);
-       docstring const ret = InsetText::xhtml(xs, runparams);
-       xs << html::EndTag(cmdname);
-       return ret;
-}
-
-
-docstring InsetScript::contextMenu(BufferView const &, int, int) const
+string InsetScript::contextMenuName() const
 {
-       return from_ascii("context-script");
+       return "context-script";
 }