]> git.lyx.org Git - lyx.git/blob - src/insets/insetert.C
The BIG UNDO patch. Recodes undo handling for better use inside InsetText.
[lyx.git] / src / insets / insetert.C
1 /* This file is part of
2  * ======================================================
3  * 
4  *           LyX, The Document Processor
5  *       
6  *          Copyright 1998 The LyX Team.
7  *
8  *======================================================*/
9
10 #include <config.h>
11
12 #ifdef __GNUG__
13 #pragma implementation
14 #endif
15
16 #include "insetert.h"
17 #include "gettext.h"
18 #include "lyxfont.h"
19 #include "buffer.h"
20 #include "insets/insettext.h"
21 #include "support/LOstream.h"
22 #include "lyx_gui_misc.h"
23
24 using std::ostream;
25
26 InsetERT::InsetERT() : InsetCollapsable()
27 {
28         setLabel(_("666"));
29 #ifndef NO_LATEX
30         LyXFont font(LyXFont::ALL_SANE);
31         font.setLatex (LyXFont::ON);
32 #endif
33         labelfont = LyXFont(LyXFont::ALL_SANE);
34         labelfont.decSize();
35         labelfont.decSize();
36         labelfont.setColor(LColor::latex);
37         setAutoCollapse(false);
38         setInsetName("ERT");
39 }
40
41
42 void InsetERT::write(Buffer const * buf, ostream & os) const 
43 {
44         os << getInsetName() << "\n";
45         InsetCollapsable::write(buf, os);
46 }
47
48
49 Inset * InsetERT::clone(Buffer const &, bool same_id) const
50 {
51         InsetERT * result = new InsetERT;
52         result->inset.init(&inset, same_id);
53         
54         result->collapsed = collapsed;
55         if (same_id)
56                 result->id_ = id_;
57         return result;
58 }
59
60
61 string const InsetERT::editMessage() const 
62 {
63         return _("Opened ERT Inset");
64 }
65
66
67 bool InsetERT::insertInset(BufferView *, Inset *)
68 {
69         return false;
70 }
71
72
73 void InsetERT::setFont(BufferView *, LyXFont const &, bool, bool selectall)
74 {
75         // if selectall is activated then the fontchange was an outside general
76         // fontchange and this messages is not needed
77         if (!selectall)
78                 WriteAlert(_("Impossible Operation!"),
79                            _("Not permitted to change font-types inside ERT-insets!"),
80                            _("Sorry."));
81 }
82
83
84 void InsetERT::edit(BufferView * bv, int x, int y, unsigned int button)
85 {
86         InsetCollapsable::edit(bv, x, y, button);
87 #ifndef NO_LATEX
88         LyXFont font(LyXFont::ALL_SANE);
89         font.setLatex (LyXFont::ON);
90 #endif
91 }
92
93
94 int InsetERT::latex(Buffer const *, std::ostream & os, bool /*fragile*/,
95                     bool /*free_spc*/) const
96 {
97         Paragraph::size_type siz = inset.paragraph()->size();
98         for (Paragraph::size_type i = 0; i != siz; ++i) {
99                 os << inset.paragraph()->getChar(i);
100         }
101         return 1;
102 }
103
104
105 int InsetERT::ascii(Buffer const *,
106                     std::ostream &, int /*linelen*/) const 
107 {
108         return 0;
109 }
110
111
112 int InsetERT::linuxdoc(Buffer const *, std::ostream &) const
113 {
114         return 0;
115 }
116
117
118 int InsetERT::docBook(Buffer const *, std::ostream &) const
119 {
120         return 0;
121 }