1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 1998 The LyX Team.
8 *======================================================*/
13 #pragma implementation
20 #include "insets/insettext.h"
21 #include "support/LOstream.h"
22 #include "lyx_gui_misc.h"
26 InsetERT::InsetERT() : InsetCollapsable()
29 //LyXFont font(LyXFont::ALL_SANE);
30 //font.setLatex (LyXFont::ON);
31 labelfont = LyXFont(LyXFont::ALL_SANE);
34 labelfont.setColor(LColor::latex);
35 setAutoCollapse(false);
40 InsetERT::InsetERT(string const & contents)
43 LyXFont font(LyXFont::ALL_SANE);
45 font.setLatex(LyXFont::ON);
47 font.setColor(LColor::latex);
49 labelfont = LyXFont(LyXFont::ALL_SANE);
52 labelfont.setColor(LColor::latex);
53 setAutoCollapse(false);
56 string::const_iterator cit = contents.begin();
57 string::const_iterator end = contents.end();
58 Paragraph::size_type pos = 0;
59 for (; cit != end; ++cit) {
60 inset.paragraph()->insertChar(pos++, *cit, font);
65 void InsetERT::write(Buffer const * buf, ostream & os) const
67 os << getInsetName() << "\n";
68 InsetCollapsable::write(buf, os);
72 Inset * InsetERT::clone(Buffer const &, bool same_id) const
74 InsetERT * result = new InsetERT;
75 result->inset.init(&inset, same_id);
77 result->collapsed_ = collapsed_;
84 string const InsetERT::editMessage() const
86 return _("Opened ERT Inset");
90 bool InsetERT::insertInset(BufferView *, Inset *)
96 void InsetERT::setFont(BufferView *, LyXFont const &, bool, bool selectall)
98 // if selectall is activated then the fontchange was an outside general
99 // fontchange and this messages is not needed
101 WriteAlert(_("Impossible Operation!"),
102 _("Not permitted to change font-types inside ERT-insets!"),
107 void InsetERT::edit(BufferView * bv, int x, int y, unsigned int button)
109 InsetCollapsable::edit(bv, x, y, button);
111 LyXFont font(LyXFont::ALL_SANE);
112 font.setLatex (LyXFont::ON);
117 int InsetERT::latex(Buffer const *, std::ostream & os, bool /*fragile*/,
118 bool /*free_spc*/) const
120 Paragraph::size_type siz = inset.paragraph()->size();
121 for (Paragraph::size_type i = 0; i != siz; ++i) {
122 char c = inset.paragraph()->getChar(i);
124 case Paragraph::META_NEWLINE:
136 int InsetERT::ascii(Buffer const *,
137 std::ostream &, int /*linelen*/) const
143 int InsetERT::linuxdoc(Buffer const *, std::ostream &) const
149 int InsetERT::docBook(Buffer const *, std::ostream &) const