diff --git a/src/LyXFunc.cpp b/src/LyXFunc.cpp index 380d601b82..de958700e1 100644 --- a/src/LyXFunc.cpp +++ b/src/LyXFunc.cpp @@ -1206,7 +1206,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd) break; } case ERT_CODE: { - data = InsetERTMailer::params2string(InsetCollapsable::Open); + data = InsetERT::params2string(InsetCollapsable::Open); break; } case EXTERNAL_CODE: { diff --git a/src/factory.cpp b/src/factory.cpp index 75b3eaea74..548c4f9247 100644 --- a/src/factory.cpp +++ b/src/factory.cpp @@ -241,7 +241,7 @@ Inset * createInsetHelper(Buffer & buf, FuncRequest const & cmd) case ERT_CODE: { InsetCollapsable::CollapseStatus st; - InsetERTMailer::string2params(to_utf8(cmd.argument()), st); + InsetERT::string2params(to_utf8(cmd.argument()), st); return new InsetERT(buf, st); } diff --git a/src/frontends/qt4/GuiERT.cpp b/src/frontends/qt4/GuiERT.cpp index 0ff9399465..175c4f4fc0 100644 --- a/src/frontends/qt4/GuiERT.cpp +++ b/src/frontends/qt4/GuiERT.cpp @@ -13,9 +13,10 @@ #include #include "GuiERT.h" -#include "support/gettext.h" #include "FuncRequest.h" +#include "support/gettext.h" + #include #include @@ -66,7 +67,7 @@ void GuiERT::updateContents() bool GuiERT::initialiseParams(string const & data) { - InsetERTMailer::string2params(data, status_); + InsetERT::string2params(data, status_); return true; } @@ -79,7 +80,7 @@ void GuiERT::clearParams() void GuiERT::dispatchParams() { - dispatch(FuncRequest(getLfun(), InsetERTMailer::params2string(status_))); + dispatch(FuncRequest(getLfun(), InsetERT::params2string(status_))); } diff --git a/src/insets/InsetCollapsable.cpp b/src/insets/InsetCollapsable.cpp index 3ec4414d78..b7883fd225 100644 --- a/src/insets/InsetCollapsable.cpp +++ b/src/insets/InsetCollapsable.cpp @@ -721,8 +721,8 @@ bool InsetCollapsable::getStatus(Cursor & cur, FuncRequest const & cmd, if (layout_->isPassThru()) { flag.enabled(false); return true; - } else - return InsetText::getStatus(cur, cmd, flag); + } + return InsetText::getStatus(cur, cmd, flag); case LFUN_INSET_TOGGLE: if ((cmd.argument() == "open" && status_ != Open) diff --git a/src/insets/InsetERT.cpp b/src/insets/InsetERT.cpp index ade0a22f49..0653c02399 100644 --- a/src/insets/InsetERT.cpp +++ b/src/insets/InsetERT.cpp @@ -30,6 +30,7 @@ #include "Paragraph.h" #include "frontends/alert.h" +#include "frontends/Application.h" #include "support/debug.h" #include "support/gettext.h" @@ -42,7 +43,6 @@ using namespace lyx::support; namespace lyx { - InsetERT::InsetERT(Buffer const & buf, CollapseStatus status) : InsetCollapsable(buf, status) {} @@ -50,7 +50,8 @@ InsetERT::InsetERT(Buffer const & buf, CollapseStatus status) InsetERT::~InsetERT() { - InsetERTMailer(*this).hideDialog(); + if (theApp()) + theApp()->hideDialogs("ert", this); } @@ -115,7 +116,7 @@ void InsetERT::doDispatch(Cursor & cur, FuncRequest & cmd) } case LFUN_INSET_MODIFY: { InsetCollapsable::CollapseStatus st; - InsetERTMailer::string2params(to_utf8(cmd.argument()), st); + InsetERT::string2params(to_utf8(cmd.argument()), st); setStatus(cur, st); break; } @@ -186,26 +187,13 @@ void InsetERT::draw(PainterInfo & pi, int x, int y) const bool InsetERT::showInsetDialog(BufferView * bv) const { - InsetERTMailer(const_cast(*this)).showDialog(bv); + bv->showDialog("ert", params2string(status()), + const_cast(this)); return true; } -string const InsetERTMailer::name_("ert"); - -InsetERTMailer::InsetERTMailer(InsetERT & inset) - : inset_(inset) -{} - - -string const InsetERTMailer::inset2string(Buffer const &) const -{ - return params2string(inset_.status()); -} - - -void InsetERTMailer::string2params(string const & in, - InsetCollapsable::CollapseStatus & status) +void InsetERT::string2params(string const & in, CollapseStatus & status) { status = InsetCollapsable::Collapsed; if (in.empty()) @@ -217,8 +205,11 @@ void InsetERTMailer::string2params(string const & in, string name; lex >> name; - if (name != name_) - return print_mailer_error("InsetERTMailer", in, 1, name_); + if (name != "ert") { + LYXERR0("InsetERT::string2params(" << in << ")\n" + "Expected arg 1 to be \"ert\"\n"); + return; + } int s; lex >> s; @@ -227,11 +218,10 @@ void InsetERTMailer::string2params(string const & in, } -string const -InsetERTMailer::params2string(InsetCollapsable::CollapseStatus status) +string InsetERT::params2string(CollapseStatus status) { ostringstream data; - data << name_ << ' ' << status; + data << "ert" << ' ' << status; return data.str(); } diff --git a/src/insets/InsetERT.h b/src/insets/InsetERT.h index 52542beb01..c8ab5e18a3 100644 --- a/src/insets/InsetERT.h +++ b/src/insets/InsetERT.h @@ -14,7 +14,6 @@ #define INSETERT_H #include "InsetCollapsable.h" -#include "MailInset.h" namespace lyx { @@ -36,6 +35,10 @@ public: InsetERT(Buffer const &, CollapseStatus status = Open); /// ~InsetERT(); + /// + static void string2params(std::string const &, CollapseStatus &); + /// + static std::string params2string(CollapseStatus); private: /// InsetCode lyxCode() const { return ERT_CODE; } @@ -78,29 +81,6 @@ private: }; -class InsetERTMailer : public MailInset { -public: - /// - InsetERTMailer(InsetERT & inset); - /// - virtual Inset & inset() const { return inset_; } - /// - virtual std::string const & name() const { return name_; } - /// - virtual std::string const inset2string(Buffer const &) const; - /// - static void string2params(std::string const &, - InsetCollapsable::CollapseStatus &); - /// - static std::string const params2string(InsetCollapsable::CollapseStatus); -private: - /// - static std::string const name_; - /// - InsetERT & inset_; -}; - - } // namespace lyx #endif diff --git a/src/insets/InsetListings.cpp b/src/insets/InsetListings.cpp index 2ff3afd811..e74773d30b 100644 --- a/src/insets/InsetListings.cpp +++ b/src/insets/InsetListings.cpp @@ -21,13 +21,14 @@ #include "DispatchResult.h" #include "FuncRequest.h" #include "FuncStatus.h" -#include "support/gettext.h" #include "InsetList.h" #include "Language.h" #include "MetricsInfo.h" #include "TextClass.h" +#include "support/debug.h" #include "support/docstream.h" +#include "support/gettext.h" #include "support/lstrings.h" #include @@ -224,6 +225,7 @@ void InsetListings::doDispatch(Cursor & cur, FuncRequest & cmd) bool InsetListings::getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus & status) const { + LYXERR0("CURSOR SIZE: " << cur.depth()); switch (cmd.action) { case LFUN_INSET_DIALOG_UPDATE: status.enabled(true);