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;
}
case ERT_CODE: {
data = InsetERTMailer::params2string(InsetCollapsable::Open);
data = InsetERT::params2string(InsetCollapsable::Open);
break;
}
case EXTERNAL_CODE: {

View File

@ -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);
}

View File

@ -13,9 +13,10 @@
#include <config.h>
#include "GuiERT.h"
#include "support/gettext.h"
#include "FuncRequest.h"
#include "support/gettext.h"
#include <QRadioButton>
#include <QPushButton>
@ -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_)));
}

View File

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

View File

@ -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<InsetERT &>(*this)).showDialog(bv);
bv->showDialog("ert", params2string(status()),
const_cast<InsetERT *>(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();
}

View File

@ -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

View File

@ -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 <boost/regex.hpp>
@ -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);