this feels good...

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23990 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2008-03-26 23:41:35 +00:00
parent 958b6b7069
commit ba348ede83
7 changed files with 29 additions and 56 deletions

View File

@ -1206,7 +1206,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
break; break;
} }
case ERT_CODE: { case ERT_CODE: {
data = InsetERTMailer::params2string(InsetCollapsable::Open); data = InsetERT::params2string(InsetCollapsable::Open);
break; break;
} }
case EXTERNAL_CODE: { case EXTERNAL_CODE: {

View File

@ -241,7 +241,7 @@ Inset * createInsetHelper(Buffer & buf, FuncRequest const & cmd)
case ERT_CODE: { case ERT_CODE: {
InsetCollapsable::CollapseStatus st; InsetCollapsable::CollapseStatus st;
InsetERTMailer::string2params(to_utf8(cmd.argument()), st); InsetERT::string2params(to_utf8(cmd.argument()), st);
return new InsetERT(buf, st); return new InsetERT(buf, st);
} }

View File

@ -13,9 +13,10 @@
#include <config.h> #include <config.h>
#include "GuiERT.h" #include "GuiERT.h"
#include "support/gettext.h"
#include "FuncRequest.h" #include "FuncRequest.h"
#include "support/gettext.h"
#include <QRadioButton> #include <QRadioButton>
#include <QPushButton> #include <QPushButton>
@ -66,7 +67,7 @@ void GuiERT::updateContents()
bool GuiERT::initialiseParams(string const & data) bool GuiERT::initialiseParams(string const & data)
{ {
InsetERTMailer::string2params(data, status_); InsetERT::string2params(data, status_);
return true; return true;
} }
@ -79,7 +80,7 @@ void GuiERT::clearParams()
void GuiERT::dispatchParams() void GuiERT::dispatchParams()
{ {
dispatch(FuncRequest(getLfun(), InsetERTMailer::params2string(status_))); dispatch(FuncRequest(getLfun(), InsetERT::params2string(status_)));
} }

View File

@ -721,7 +721,7 @@ bool InsetCollapsable::getStatus(Cursor & cur, FuncRequest const & cmd,
if (layout_->isPassThru()) { if (layout_->isPassThru()) {
flag.enabled(false); flag.enabled(false);
return true; return true;
} else }
return InsetText::getStatus(cur, cmd, flag); return InsetText::getStatus(cur, cmd, flag);
case LFUN_INSET_TOGGLE: case LFUN_INSET_TOGGLE:

View File

@ -30,6 +30,7 @@
#include "Paragraph.h" #include "Paragraph.h"
#include "frontends/alert.h" #include "frontends/alert.h"
#include "frontends/Application.h"
#include "support/debug.h" #include "support/debug.h"
#include "support/gettext.h" #include "support/gettext.h"
@ -42,7 +43,6 @@ using namespace lyx::support;
namespace lyx { namespace lyx {
InsetERT::InsetERT(Buffer const & buf, CollapseStatus status) InsetERT::InsetERT(Buffer const & buf, CollapseStatus status)
: InsetCollapsable(buf, status) : InsetCollapsable(buf, status)
{} {}
@ -50,7 +50,8 @@ InsetERT::InsetERT(Buffer const & buf, CollapseStatus status)
InsetERT::~InsetERT() 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: { case LFUN_INSET_MODIFY: {
InsetCollapsable::CollapseStatus st; InsetCollapsable::CollapseStatus st;
InsetERTMailer::string2params(to_utf8(cmd.argument()), st); InsetERT::string2params(to_utf8(cmd.argument()), st);
setStatus(cur, st); setStatus(cur, st);
break; break;
} }
@ -186,26 +187,13 @@ void InsetERT::draw(PainterInfo & pi, int x, int y) const
bool InsetERT::showInsetDialog(BufferView * bv) const bool InsetERT::showInsetDialog(BufferView * bv) const
{ {
InsetERTMailer(const_cast<InsetERT &>(*this)).showDialog(bv); bv->showDialog("ert", params2string(status()),
const_cast<InsetERT *>(this));
return true; return true;
} }
string const InsetERTMailer::name_("ert"); void InsetERT::string2params(string const & in, CollapseStatus & status)
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)
{ {
status = InsetCollapsable::Collapsed; status = InsetCollapsable::Collapsed;
if (in.empty()) if (in.empty())
@ -217,8 +205,11 @@ void InsetERTMailer::string2params(string const & in,
string name; string name;
lex >> name; lex >> name;
if (name != name_) if (name != "ert") {
return print_mailer_error("InsetERTMailer", in, 1, name_); LYXERR0("InsetERT::string2params(" << in << ")\n"
"Expected arg 1 to be \"ert\"\n");
return;
}
int s; int s;
lex >> s; lex >> s;
@ -227,11 +218,10 @@ void InsetERTMailer::string2params(string const & in,
} }
string const string InsetERT::params2string(CollapseStatus status)
InsetERTMailer::params2string(InsetCollapsable::CollapseStatus status)
{ {
ostringstream data; ostringstream data;
data << name_ << ' ' << status; data << "ert" << ' ' << status;
return data.str(); return data.str();
} }

View File

@ -14,7 +14,6 @@
#define INSETERT_H #define INSETERT_H
#include "InsetCollapsable.h" #include "InsetCollapsable.h"
#include "MailInset.h"
namespace lyx { namespace lyx {
@ -36,6 +35,10 @@ public:
InsetERT(Buffer const &, CollapseStatus status = Open); InsetERT(Buffer const &, CollapseStatus status = Open);
/// ///
~InsetERT(); ~InsetERT();
///
static void string2params(std::string const &, CollapseStatus &);
///
static std::string params2string(CollapseStatus);
private: private:
/// ///
InsetCode lyxCode() const { return ERT_CODE; } 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 } // namespace lyx
#endif #endif

View File

@ -21,13 +21,14 @@
#include "DispatchResult.h" #include "DispatchResult.h"
#include "FuncRequest.h" #include "FuncRequest.h"
#include "FuncStatus.h" #include "FuncStatus.h"
#include "support/gettext.h"
#include "InsetList.h" #include "InsetList.h"
#include "Language.h" #include "Language.h"
#include "MetricsInfo.h" #include "MetricsInfo.h"
#include "TextClass.h" #include "TextClass.h"
#include "support/debug.h"
#include "support/docstream.h" #include "support/docstream.h"
#include "support/gettext.h"
#include "support/lstrings.h" #include "support/lstrings.h"
#include <boost/regex.hpp> #include <boost/regex.hpp>
@ -224,6 +225,7 @@ void InsetListings::doDispatch(Cursor & cur, FuncRequest & cmd)
bool InsetListings::getStatus(Cursor & cur, FuncRequest const & cmd, bool InsetListings::getStatus(Cursor & cur, FuncRequest const & cmd,
FuncStatus & status) const FuncStatus & status) const
{ {
LYXERR0("CURSOR SIZE: " << cur.depth());
switch (cmd.action) { switch (cmd.action) {
case LFUN_INSET_DIALOG_UPDATE: case LFUN_INSET_DIALOG_UPDATE:
status.enabled(true); status.enabled(true);