2000-02-25 12:06:15 +00:00
|
|
|
/* This file is part of
|
|
|
|
* ======================================================
|
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
2000-02-25 13:35:38 +00:00
|
|
|
* Copyright 1998 The LyX Team.
|
2000-02-25 12:06:15 +00:00
|
|
|
*
|
|
|
|
*======================================================*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "insetert.h"
|
|
|
|
#include "gettext.h"
|
|
|
|
#include "lyxfont.h"
|
2000-03-08 13:52:57 +00:00
|
|
|
#include "buffer.h"
|
2000-07-04 11:30:07 +00:00
|
|
|
#include "insets/insettext.h"
|
2000-04-08 17:02:02 +00:00
|
|
|
#include "support/LOstream.h"
|
|
|
|
#include "lyx_gui_misc.h"
|
2000-02-25 12:06:15 +00:00
|
|
|
|
2000-04-04 00:19:15 +00:00
|
|
|
using std::ostream;
|
2000-02-25 12:06:15 +00:00
|
|
|
|
2000-06-12 11:27:15 +00:00
|
|
|
InsetERT::InsetERT() : InsetCollapsable()
|
2000-02-25 12:06:15 +00:00
|
|
|
{
|
2001-06-27 14:10:35 +00:00
|
|
|
setLabel(_("666"));
|
2001-07-08 12:52:16 +00:00
|
|
|
//LyXFont font(LyXFont::ALL_SANE);
|
|
|
|
//font.setLatex (LyXFont::ON);
|
|
|
|
labelfont = LyXFont(LyXFont::ALL_SANE);
|
|
|
|
labelfont.decSize();
|
|
|
|
labelfont.decSize();
|
|
|
|
labelfont.setColor(LColor::latex);
|
|
|
|
setAutoCollapse(false);
|
|
|
|
setInsetName("ERT");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
InsetERT::InsetERT(string const & contents)
|
|
|
|
{
|
|
|
|
setLabel(_("666"));
|
2001-04-02 14:02:58 +00:00
|
|
|
LyXFont font(LyXFont::ALL_SANE);
|
2001-07-08 12:52:16 +00:00
|
|
|
#ifndef NO_LATEX
|
|
|
|
font.setLatex(LyXFont::ON);
|
|
|
|
#else
|
|
|
|
font.setColor(LColor::latex);
|
2001-06-27 14:10:35 +00:00
|
|
|
#endif
|
2001-04-02 14:02:58 +00:00
|
|
|
labelfont = LyXFont(LyXFont::ALL_SANE);
|
|
|
|
labelfont.decSize();
|
|
|
|
labelfont.decSize();
|
2001-06-05 17:05:51 +00:00
|
|
|
labelfont.setColor(LColor::latex);
|
2001-04-02 14:02:58 +00:00
|
|
|
setAutoCollapse(false);
|
|
|
|
setInsetName("ERT");
|
2001-07-08 12:52:16 +00:00
|
|
|
|
|
|
|
string::const_iterator cit = contents.begin();
|
|
|
|
string::const_iterator end = contents.end();
|
|
|
|
Paragraph::size_type pos = 0;
|
|
|
|
for (; cit != end; ++cit) {
|
|
|
|
inset.paragraph()->insertChar(pos++, *cit, font);
|
|
|
|
}
|
2000-02-25 12:06:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
void InsetERT::write(Buffer const * buf, ostream & os) const
|
2000-06-28 13:35:52 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
os << getInsetName() << "\n";
|
2001-06-28 10:25:20 +00:00
|
|
|
InsetCollapsable::write(buf, os);
|
2000-06-28 13:35:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-07-06 15:57:54 +00:00
|
|
|
Inset * InsetERT::clone(Buffer const &, bool same_id) const
|
2000-02-25 12:06:15 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
InsetERT * result = new InsetERT;
|
2001-07-06 15:57:54 +00:00
|
|
|
result->inset.init(&inset, same_id);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
2001-07-12 14:35:38 +00:00
|
|
|
result->collapsed_ = collapsed_;
|
2001-07-06 15:57:54 +00:00
|
|
|
if (same_id)
|
|
|
|
result->id_ = id_;
|
2001-04-02 14:02:58 +00:00
|
|
|
return result;
|
2000-02-25 12:06:15 +00:00
|
|
|
}
|
|
|
|
|
2000-04-04 00:19:15 +00:00
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
string const InsetERT::editMessage() const
|
2000-04-04 00:19:15 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
return _("Opened ERT Inset");
|
2000-02-25 12:06:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
bool InsetERT::insertInset(BufferView *, Inset *)
|
2001-06-27 14:10:35 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
void InsetERT::setFont(BufferView *, LyXFont const &, bool, bool selectall)
|
2000-02-25 12:06:15 +00:00
|
|
|
{
|
2001-05-28 15:11:24 +00:00
|
|
|
// if selectall is activated then the fontchange was an outside general
|
|
|
|
// fontchange and this messages is not needed
|
|
|
|
if (!selectall)
|
|
|
|
WriteAlert(_("Impossible Operation!"),
|
|
|
|
_("Not permitted to change font-types inside ERT-insets!"),
|
|
|
|
_("Sorry."));
|
2000-02-25 12:06:15 +00:00
|
|
|
}
|
2000-03-24 13:24:58 +00:00
|
|
|
|
2000-07-04 19:16:35 +00:00
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
void InsetERT::edit(BufferView * bv, int x, int y, unsigned int button)
|
2000-03-24 13:24:58 +00:00
|
|
|
{
|
2001-06-28 10:25:20 +00:00
|
|
|
InsetCollapsable::edit(bv, x, y, button);
|
2001-06-27 14:10:35 +00:00
|
|
|
#ifndef NO_LATEX
|
2001-04-02 14:02:58 +00:00
|
|
|
LyXFont font(LyXFont::ALL_SANE);
|
|
|
|
font.setLatex (LyXFont::ON);
|
2001-06-27 14:10:35 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
int InsetERT::latex(Buffer const *, std::ostream & os, bool /*fragile*/,
|
2001-06-27 14:10:35 +00:00
|
|
|
bool /*free_spc*/) const
|
|
|
|
{
|
2001-07-16 15:42:57 +00:00
|
|
|
Paragraph * par = inset.paragraph();
|
|
|
|
while (par) {
|
|
|
|
Paragraph::size_type siz = inset.paragraph()->size();
|
|
|
|
for (Paragraph::size_type i = 0; i != siz; ++i) {
|
|
|
|
char c = inset.paragraph()->getChar(i);
|
|
|
|
switch (c) {
|
|
|
|
case Paragraph::META_NEWLINE:
|
|
|
|
os << '\n';
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
os << c;
|
|
|
|
break;
|
|
|
|
}
|
2001-07-09 23:12:04 +00:00
|
|
|
}
|
2001-07-16 15:42:57 +00:00
|
|
|
par = par->next();
|
2001-06-27 14:10:35 +00:00
|
|
|
}
|
2001-07-16 15:42:57 +00:00
|
|
|
|
2001-06-27 14:10:35 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
int InsetERT::ascii(Buffer const *,
|
2001-06-27 14:10:35 +00:00
|
|
|
std::ostream &, int /*linelen*/) const
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
int InsetERT::linuxdoc(Buffer const *, std::ostream &) const
|
2001-06-27 14:10:35 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
int InsetERT::docBook(Buffer const *, std::ostream &) const
|
2001-06-27 14:10:35 +00:00
|
|
|
{
|
|
|
|
return 0;
|
2000-03-24 13:24:58 +00:00
|
|
|
}
|