3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
7 * \author Lars Gullik Bjønnes
9 * Full author contact details are available in file CREDITS.
17 #include "BufferParams.h"
18 #include "BufferView.h"
20 #include "DispatchResult.h"
21 #include "FuncRequest.h"
22 #include "FuncStatus.h"
26 #include "LyXAction.h"
27 #include "MetricsInfo.h"
28 #include "OutputParams.h"
29 #include "ParagraphParameters.h"
30 #include "Paragraph.h"
31 #include "TextClass.h"
33 #include "frontends/alert.h"
34 #include "frontends/Application.h"
36 #include "support/debug.h"
37 #include "support/gettext.h"
38 #include "support/lstrings.h"
43 using namespace lyx::support;
47 InsetERT::InsetERT(Buffer * buf, CollapseStatus status)
48 : InsetCollapsable(buf)
56 hideDialogs("ert", this);
60 void InsetERT::write(ostream & os) const
63 InsetCollapsable::write(os);
67 int InsetERT::plaintext(odocstream & os, OutputParams const & rp) const
70 // do not output TeX code
73 ParagraphList::const_iterator par = paragraphs().begin();
74 ParagraphList::const_iterator end = paragraphs().end();
77 pos_type siz = par->size();
78 for (pos_type i = 0; i < siz; ++i) {
79 char_type const c = par->getChar(i);
80 // output the active characters
97 int InsetERT::docbook(odocstream & os, OutputParams const &) const
99 // FIXME can we do the same thing here as for LaTeX?
100 ParagraphList::const_iterator par = paragraphs().begin();
101 ParagraphList::const_iterator end = paragraphs().end();
105 pos_type siz = par->size();
106 for (pos_type i = 0; i < siz; ++i)
107 os.put(par->getChar(i));
119 void InsetERT::doDispatch(Cursor & cur, FuncRequest & cmd)
121 switch (cmd.action) {
122 case LFUN_INSET_MODIFY: {
123 setStatus(cur, string2params(to_utf8(cmd.argument())));
127 InsetCollapsable::doDispatch(cur, cmd);
133 bool InsetERT::getStatus(Cursor & cur, FuncRequest const & cmd,
134 FuncStatus & status) const
136 switch (cmd.action) {
137 case LFUN_INSET_MODIFY:
138 status.setEnabled(true);
142 return InsetCollapsable::getStatus(cur, cmd, status);
147 docstring const InsetERT::buttonLabel(BufferView const & bv) const
149 if (decoration() == InsetLayout::CLASSIC)
150 return isOpen(bv) ? _("ERT") : getNewLabel(_("ERT"));
152 return getNewLabel(_("ERT"));
156 bool InsetERT::showInsetDialog(BufferView * bv) const
158 bv->showDialog("ert", params2string(status(*bv)),
159 const_cast<InsetERT *>(this));
164 InsetCollapsable::CollapseStatus InsetERT::string2params(string const & in)
168 istringstream data(in);
171 lex.setContext("InsetERT::string2params");
175 return static_cast<CollapseStatus>(s);
179 string InsetERT::params2string(CollapseStatus status)
182 data << "ert" << ' ' << status;
187 docstring InsetERT::xhtml(XHTMLStream &, OutputParams const &) const