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 "frontends/alert.h"
33 #include "frontends/Application.h"
35 #include "support/debug.h"
36 #include "support/gettext.h"
37 #include "support/lstrings.h"
42 using namespace lyx::support;
46 InsetERT::InsetERT(Buffer * buf, CollapseStatus status)
47 : InsetCollapsable(buf)
53 void InsetERT::write(ostream & os) const
56 InsetCollapsable::write(os);
60 int InsetERT::plaintext(odocstream & os, OutputParams const & rp) const
63 // do not output TeX code
66 ParagraphList::const_iterator par = paragraphs().begin();
67 ParagraphList::const_iterator end = paragraphs().end();
70 pos_type siz = par->size();
71 for (pos_type i = 0; i < siz; ++i) {
72 char_type const c = par->getChar(i);
73 // output the active characters
90 int InsetERT::docbook(odocstream & os, OutputParams const &) const
92 // FIXME can we do the same thing here as for LaTeX?
93 ParagraphList::const_iterator par = paragraphs().begin();
94 ParagraphList::const_iterator end = paragraphs().end();
98 pos_type siz = par->size();
99 for (pos_type i = 0; i < siz; ++i)
100 os.put(par->getChar(i));
112 void InsetERT::doDispatch(Cursor & cur, FuncRequest & cmd)
114 switch (cmd.action()) {
115 case LFUN_INSET_MODIFY:
116 if (cmd.getArg(0) == "ert") {
117 cur.recordUndoInset(ATOMIC_UNDO, this);
118 setStatus(cur, string2params(to_utf8(cmd.argument())));
123 InsetCollapsable::doDispatch(cur, cmd);
130 bool InsetERT::getStatus(Cursor & cur, FuncRequest const & cmd,
131 FuncStatus & status) const
133 switch (cmd.action()) {
134 case LFUN_INSET_MODIFY:
135 if (cmd.getArg(0) == "ert") {
136 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 InsetCollapsable::CollapseStatus InsetERT::string2params(string const & in)
160 istringstream data(in);
163 lex.setContext("InsetERT::string2params");
167 return static_cast<CollapseStatus>(s);
171 string InsetERT::params2string(CollapseStatus status)
174 data << "ert" << ' ' << status;
179 docstring InsetERT::xhtml(XHTMLStream &, OutputParams const &) const