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"
23 #include "BufferView.h"
30 setLabel(_("666"), true);
31 labelfont = LyXFont(LyXFont::ALL_SANE);
35 labelfont.setLatex(LyXFont::ON);
37 labelfont.setColor(LColor::latex);
43 InsetERT::InsetERT() : InsetCollapsable()
50 InsetERT::InsetERT(InsetERT const & in, bool same_id)
51 : InsetCollapsable(in, same_id)
57 InsetERT::InsetERT(string const & contents, bool collapsed)
58 : InsetCollapsable(collapsed)
60 LyXFont font(LyXFont::ALL_INHERIT);
61 font.setFamily(LyXFont::TYPEWRITER_FAMILY);
62 font.setColor(LColor::latex);
63 string::const_iterator cit = contents.begin();
64 string::const_iterator end = contents.end();
65 Paragraph::size_type pos = 0;
66 for (; cit != end; ++cit) {
67 inset.paragraph()->insertChar(pos++, *cit, font);
69 // the init has to be after the initialization of the paragraph
70 // because of the label settings (draw_label for ert insets).
75 void InsetERT::write(Buffer const * buf, ostream & os) const
77 os << getInsetName() << "\n";
78 InsetCollapsable::write(buf, os);
82 string const InsetERT::editMessage() const
84 return _("Opened ERT Inset");
88 bool InsetERT::insertInset(BufferView *, Inset *)
94 void InsetERT::setFont(BufferView *, LyXFont const &, bool, bool selectall)
96 // if selectall is activated then the fontchange was an outside general
97 // fontchange and this messages is not needed
99 WriteAlert(_("Impossible Operation!"),
100 _("Not permitted to change font-types inside ERT-insets!"),
105 void InsetERT::edit(BufferView * bv, int x, int y, unsigned int button)
107 InsetCollapsable::edit(bv, x, y, button);
109 LyXFont font(LyXFont::ALL_SANE);
110 font.setLatex (LyXFont::ON);
112 LyXFont font(LyXFont::ALL_INHERIT);
113 font.setFamily(LyXFont::TYPEWRITER_FAMILY);
114 font.setColor(LColor::latex);
116 inset.setFont(bv, font);
120 void InsetERT::edit(BufferView * bv, bool)
126 int InsetERT::latex(Buffer const *, std::ostream & os, bool /*fragile*/,
127 bool /*free_spc*/) const
129 Paragraph * par = inset.paragraph();
131 Paragraph::size_type siz = inset.paragraph()->size();
132 for (Paragraph::size_type i = 0; i != siz; ++i) {
133 char c = inset.paragraph()->getChar(i);
135 case Paragraph::META_NEWLINE:
150 int InsetERT::ascii(Buffer const *,
151 std::ostream &, int /*linelen*/) const
157 int InsetERT::linuxdoc(Buffer const *, std::ostream &) const
163 int InsetERT::docBook(Buffer const *, std::ostream &) const
169 UpdatableInset::RESULT
170 InsetERT::localDispatch(BufferView * bv, kb_action action, string const & arg)
172 UpdatableInset::RESULT result = DISPATCHED_NOUPDATE;
176 bv->owner()->setLayout(inset.paragraph()->getLayout());
179 result = InsetCollapsable::localDispatch(bv, action, arg);
182 case LFUN_BREAKPARAGRAPH:
183 case LFUN_BREAKPARAGRAPHKEEPLAYOUT: {
185 LyXFont font(LyXFont::ALL_SANE);
186 font.setLatex (LyXFont::ON);
188 LyXFont font(LyXFont::ALL_INHERIT);
189 font.setFamily(LyXFont::TYPEWRITER_FAMILY);
190 font.setColor(LColor::latex);
192 inset.setFont(bv, font);