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 "OutputParams.h"
28 #include "ParagraphParameters.h"
29 #include "Paragraph.h"
30 #include "TextClass.h"
32 #include "support/gettext.h"
33 #include "support/lstrings.h"
38 using namespace lyx::support;
42 InsetERT::InsetERT(Buffer * buf, CollapseStatus status)
43 : InsetCollapsable(buf)
49 void InsetERT::write(ostream & os) const
52 InsetCollapsable::write(os);
56 int InsetERT::plaintext(odocstream & os, OutputParams const & rp) const
59 // do not output TeX code
62 ParagraphList::const_iterator par = paragraphs().begin();
63 ParagraphList::const_iterator end = paragraphs().end();
66 pos_type siz = par->size();
67 for (pos_type i = 0; i < siz; ++i) {
68 char_type const c = par->getChar(i);
69 // output the active characters
86 int InsetERT::docbook(odocstream & os, OutputParams const &) const
88 // FIXME can we do the same thing here as for LaTeX?
89 ParagraphList::const_iterator par = paragraphs().begin();
90 ParagraphList::const_iterator end = paragraphs().end();
94 pos_type siz = par->size();
95 for (pos_type i = 0; i < siz; ++i)
96 os.put(par->getChar(i));
108 void InsetERT::doDispatch(Cursor & cur, FuncRequest & cmd)
110 switch (cmd.action()) {
111 case LFUN_INSET_MODIFY:
112 if (cmd.getArg(0) == "ert") {
113 cur.recordUndoInset(ATOMIC_UNDO, this);
114 setStatus(cur, string2params(to_utf8(cmd.argument())));
119 InsetCollapsable::doDispatch(cur, cmd);
126 bool InsetERT::getStatus(Cursor & cur, FuncRequest const & cmd,
127 FuncStatus & status) const
129 switch (cmd.action()) {
130 case LFUN_INSET_MODIFY:
131 if (cmd.getArg(0) == "ert") {
132 status.setEnabled(true);
138 return InsetCollapsable::getStatus(cur, cmd, status);
143 docstring const InsetERT::buttonLabel(BufferView const & bv) const
145 if (decoration() == InsetLayout::CLASSIC)
146 return isOpen(bv) ? _("ERT") : getNewLabel(_("ERT"));
148 return getNewLabel(_("ERT"));
152 InsetCollapsable::CollapseStatus InsetERT::string2params(string const & in)
156 istringstream data(in);
159 lex.setContext("InsetERT::string2params");
163 return static_cast<CollapseStatus>(s);
167 string InsetERT::params2string(CollapseStatus status)
170 data << "ert" << ' ' << status;
175 docstring InsetERT::xhtml(XHTMLStream &, OutputParams const &) const