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, bool collapsed)
41 : InsetCollapsable(collapsed)
44 LyXFont font(LyXFont::ALL_SANE);
46 font.setLatex(LyXFont::ON);
48 font.setColor(LColor::latex);
50 labelfont = LyXFont(LyXFont::ALL_SANE);
53 labelfont.setColor(LColor::latex);
54 setAutoCollapse(false);
57 string::const_iterator cit = contents.begin();
58 string::const_iterator end = contents.end();
59 Paragraph::size_type pos = 0;
60 for (; cit != end; ++cit) {
61 inset.paragraph()->insertChar(pos++, *cit, font);
66 void InsetERT::write(Buffer const * buf, ostream & os) const
68 os << getInsetName() << "\n";
69 InsetCollapsable::write(buf, os);
73 Inset * InsetERT::clone(Buffer const &, bool same_id) const
75 InsetERT * result = new InsetERT;
76 result->inset.init(&inset, same_id);
78 result->collapsed_ = collapsed_;
85 string const InsetERT::editMessage() const
87 return _("Opened ERT Inset");
91 bool InsetERT::insertInset(BufferView *, Inset *)
97 void InsetERT::setFont(BufferView *, LyXFont const &, bool, bool selectall)
99 // if selectall is activated then the fontchange was an outside general
100 // fontchange and this messages is not needed
102 WriteAlert(_("Impossible Operation!"),
103 _("Not permitted to change font-types inside ERT-insets!"),
108 void InsetERT::edit(BufferView * bv, int x, int y, unsigned int button)
110 InsetCollapsable::edit(bv, x, y, button);
112 LyXFont font(LyXFont::ALL_SANE);
113 font.setLatex (LyXFont::ON);
118 void InsetERT::edit(BufferView * bv, bool)
124 int InsetERT::latex(Buffer const *, std::ostream & os, bool /*fragile*/,
125 bool /*free_spc*/) const
127 Paragraph * par = inset.paragraph();
129 Paragraph::size_type siz = inset.paragraph()->size();
130 for (Paragraph::size_type i = 0; i != siz; ++i) {
131 char c = inset.paragraph()->getChar(i);
133 case Paragraph::META_NEWLINE:
148 int InsetERT::ascii(Buffer const *,
149 std::ostream &, int /*linelen*/) const
155 int InsetERT::linuxdoc(Buffer const *, std::ostream &) const
161 int InsetERT::docBook(Buffer const *, std::ostream &) const