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)
54 void InsetERT::write(ostream & os) const
57 InsetCollapsable::write(os);
61 int InsetERT::plaintext(odocstream & os, OutputParams const & rp) const
64 // do not output TeX code
67 ParagraphList::const_iterator par = paragraphs().begin();
68 ParagraphList::const_iterator end = paragraphs().end();
71 pos_type siz = par->size();
72 for (pos_type i = 0; i < siz; ++i) {
73 char_type const c = par->getChar(i);
74 // output the active characters
91 int InsetERT::docbook(odocstream & os, OutputParams const &) const
93 // FIXME can we do the same thing here as for LaTeX?
94 ParagraphList::const_iterator par = paragraphs().begin();
95 ParagraphList::const_iterator end = paragraphs().end();
99 pos_type siz = par->size();
100 for (pos_type i = 0; i < siz; ++i)
101 os.put(par->getChar(i));
113 void InsetERT::doDispatch(Cursor & cur, FuncRequest & cmd)
115 switch (cmd.action) {
116 case LFUN_INSET_MODIFY: {
117 setStatus(cur, string2params(to_utf8(cmd.argument())));
121 InsetCollapsable::doDispatch(cur, cmd);
127 bool InsetERT::getStatus(Cursor & cur, FuncRequest const & cmd,
128 FuncStatus & status) const
130 switch (cmd.action) {
131 case LFUN_INSET_MODIFY:
132 status.setEnabled(true);
136 return InsetCollapsable::getStatus(cur, cmd, status);
141 docstring const InsetERT::buttonLabel(BufferView const & bv) const
143 if (decoration() == InsetLayout::CLASSIC)
144 return isOpen(bv) ? _("ERT") : getNewLabel(_("ERT"));
146 return getNewLabel(_("ERT"));
150 InsetCollapsable::CollapseStatus InsetERT::string2params(string const & in)
154 istringstream data(in);
157 lex.setContext("InsetERT::string2params");
161 return static_cast<CollapseStatus>(s);
165 string InsetERT::params2string(CollapseStatus status)
168 data << "ert" << ' ' << status;
173 docstring InsetERT::xhtml(XHTMLStream &, OutputParams const &) const