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 setStatus(cur, string2params(to_utf8(cmd.argument())));
122 InsetCollapsable::doDispatch(cur, cmd);
129 bool InsetERT::getStatus(Cursor & cur, FuncRequest const & cmd,
130 FuncStatus & status) const
132 switch (cmd.action()) {
133 case LFUN_INSET_MODIFY:
134 if (cmd.getArg(0) == "ert") {
135 status.setEnabled(true);
141 return InsetCollapsable::getStatus(cur, cmd, status);
146 docstring const InsetERT::buttonLabel(BufferView const & bv) const
148 if (decoration() == InsetLayout::CLASSIC)
149 return isOpen(bv) ? _("ERT") : getNewLabel(_("ERT"));
151 return getNewLabel(_("ERT"));
155 InsetCollapsable::CollapseStatus InsetERT::string2params(string const & in)
159 istringstream data(in);
162 lex.setContext("InsetERT::string2params");
166 return static_cast<CollapseStatus>(s);
170 string InsetERT::params2string(CollapseStatus status)
173 data << "ert" << ' ' << status;
178 docstring InsetERT::xhtml(XHTMLStream &, OutputParams const &) const