2002-09-25 14:26:13 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file insetert.C
|
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-03-21 17:09:55 +00:00
|
|
|
|
*
|
2002-09-25 14:26:13 +00:00
|
|
|
|
* \author J<EFBFBD>rgen Vigna
|
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
2002-03-21 17:09:55 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-09-25 14:26:13 +00:00
|
|
|
|
*/
|
2003-11-10 09:06:48 +00:00
|
|
|
|
|
2000-02-25 12:06:15 +00:00
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
#include "insetert.h"
|
2002-08-13 14:40:38 +00:00
|
|
|
|
|
2000-03-08 13:52:57 +00:00
|
|
|
|
#include "buffer.h"
|
2003-09-09 11:24:33 +00:00
|
|
|
|
#include "bufferparams.h"
|
2001-07-24 15:07:09 +00:00
|
|
|
|
#include "BufferView.h"
|
2005-02-03 17:24:40 +00:00
|
|
|
|
#include "cursor.h"
|
2001-12-28 13:26:54 +00:00
|
|
|
|
#include "debug.h"
|
2003-10-29 10:47:21 +00:00
|
|
|
|
#include "dispatchresult.h"
|
2002-08-13 14:40:38 +00:00
|
|
|
|
#include "funcrequest.h"
|
2004-11-04 19:50:04 +00:00
|
|
|
|
#include "FuncStatus.h"
|
2002-08-13 14:40:38 +00:00
|
|
|
|
#include "gettext.h"
|
|
|
|
|
#include "language.h"
|
2003-09-16 10:54:23 +00:00
|
|
|
|
#include "LColor.h"
|
2005-02-03 17:24:40 +00:00
|
|
|
|
#include "LyXAction.h"
|
2002-07-21 21:21:06 +00:00
|
|
|
|
#include "lyxlex.h"
|
2005-02-03 17:24:40 +00:00
|
|
|
|
#include "lyxtextclass.h"
|
2003-09-05 09:01:27 +00:00
|
|
|
|
#include "metricsinfo.h"
|
2005-02-03 17:24:40 +00:00
|
|
|
|
#include "ParagraphParameters.h"
|
2003-09-06 17:23:08 +00:00
|
|
|
|
#include "paragraph.h"
|
2001-12-28 13:26:54 +00:00
|
|
|
|
|
2001-11-26 10:19:58 +00:00
|
|
|
|
#include "frontends/Alert.h"
|
2002-08-13 14:40:38 +00:00
|
|
|
|
#include "frontends/LyXView.h"
|
2001-12-28 13:26:54 +00:00
|
|
|
|
|
2004-07-24 10:55:30 +00:00
|
|
|
|
#include <sstream>
|
2000-02-25 12:06:15 +00:00
|
|
|
|
|
2003-07-25 17:11:25 +00:00
|
|
|
|
using lyx::pos_type;
|
2005-02-03 17:24:40 +00:00
|
|
|
|
using lyx::support::token;
|
2003-07-25 17:11:25 +00:00
|
|
|
|
|
2002-02-16 15:59:55 +00:00
|
|
|
|
using std::endl;
|
2003-09-08 00:33:41 +00:00
|
|
|
|
using std::min;
|
2003-12-10 21:32:05 +00:00
|
|
|
|
|
2003-07-25 17:11:25 +00:00
|
|
|
|
using std::auto_ptr;
|
2003-12-10 21:32:05 +00:00
|
|
|
|
using std::istringstream;
|
2003-09-05 09:01:27 +00:00
|
|
|
|
using std::ostream;
|
2003-12-10 21:32:05 +00:00
|
|
|
|
using std::ostringstream;
|
|
|
|
|
using std::string;
|
2001-11-27 10:34:16 +00:00
|
|
|
|
|
2000-02-25 12:06:15 +00:00
|
|
|
|
|
2001-07-24 10:13:19 +00:00
|
|
|
|
void InsetERT::init()
|
2000-02-25 12:06:15 +00:00
|
|
|
|
{
|
2001-07-25 19:45:21 +00:00
|
|
|
|
setButtonLabel();
|
2003-09-16 15:39:33 +00:00
|
|
|
|
|
|
|
|
|
LyXFont font(LyXFont::ALL_SANE);
|
|
|
|
|
font.decSize();
|
|
|
|
|
font.decSize();
|
|
|
|
|
font.setColor(LColor::latex);
|
|
|
|
|
setLabelFont(font);
|
|
|
|
|
|
2001-07-08 12:52:16 +00:00
|
|
|
|
setInsetName("ERT");
|
|
|
|
|
}
|
|
|
|
|
|
2001-07-24 15:07:09 +00:00
|
|
|
|
|
2003-12-12 14:02:14 +00:00
|
|
|
|
InsetERT::InsetERT(BufferParams const & bp, CollapseStatus status)
|
|
|
|
|
: InsetCollapsable(bp, status)
|
2001-07-24 10:13:19 +00:00
|
|
|
|
{
|
|
|
|
|
init();
|
|
|
|
|
}
|
|
|
|
|
|
2001-07-08 12:52:16 +00:00
|
|
|
|
|
2003-05-26 09:13:55 +00:00
|
|
|
|
InsetERT::InsetERT(InsetERT const & in)
|
2003-12-02 07:15:42 +00:00
|
|
|
|
: InsetCollapsable(in)
|
2001-07-27 12:03:36 +00:00
|
|
|
|
{
|
|
|
|
|
init();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-11-23 23:04:52 +00:00
|
|
|
|
auto_ptr<InsetBase> InsetERT::doClone() const
|
2001-07-27 12:03:36 +00:00
|
|
|
|
{
|
2003-07-25 17:11:25 +00:00
|
|
|
|
return auto_ptr<InsetBase>(new InsetERT(*this));
|
2001-07-27 12:03:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-03-03 20:25:07 +00:00
|
|
|
|
InsetERT::InsetERT(BufferParams const & bp,
|
2004-11-30 01:59:49 +00:00
|
|
|
|
Language const *, string const & contents, CollapseStatus status)
|
2003-12-12 14:02:14 +00:00
|
|
|
|
: InsetCollapsable(bp, status)
|
2001-07-08 12:52:16 +00:00
|
|
|
|
{
|
2004-11-30 01:59:49 +00:00
|
|
|
|
//LyXFont font(LyXFont::ALL_INHERIT, lang);
|
|
|
|
|
LyXFont font;
|
|
|
|
|
getDrawFont(font);
|
2001-07-08 12:52:16 +00:00
|
|
|
|
string::const_iterator cit = contents.begin();
|
|
|
|
|
string::const_iterator end = contents.end();
|
2001-11-27 10:34:16 +00:00
|
|
|
|
pos_type pos = 0;
|
2004-03-25 09:16:36 +00:00
|
|
|
|
for (; cit != end; ++cit)
|
|
|
|
|
paragraphs().begin()->insertChar(pos++, *cit, font);
|
|
|
|
|
|
2001-07-24 15:07:09 +00:00
|
|
|
|
// the init has to be after the initialization of the paragraph
|
|
|
|
|
// because of the label settings (draw_label for ert insets).
|
|
|
|
|
init();
|
2000-02-25 12:06:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-08-06 14:55:02 +00:00
|
|
|
|
InsetERT::~InsetERT()
|
|
|
|
|
{
|
2003-07-14 17:50:00 +00:00
|
|
|
|
InsetERTMailer(*this).hideDialog();
|
2001-08-06 14:55:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-08-28 07:41:31 +00:00
|
|
|
|
void InsetERT::write(Buffer const & buf, ostream & os) const
|
2000-06-28 13:35:52 +00:00
|
|
|
|
{
|
2003-12-12 14:02:14 +00:00
|
|
|
|
os << "ERT" << "\n";
|
|
|
|
|
InsetCollapsable::write(buf, os);
|
2000-06-28 13:35:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-03-21 17:09:55 +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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-08-28 07:41:31 +00:00
|
|
|
|
int InsetERT::latex(Buffer const &, ostream & os,
|
2003-11-05 12:06:20 +00:00
|
|
|
|
OutputParams const &) const
|
2001-06-27 14:10:35 +00:00
|
|
|
|
{
|
2004-03-28 22:00:22 +00:00
|
|
|
|
ParagraphList::const_iterator par = paragraphs().begin();
|
|
|
|
|
ParagraphList::const_iterator end = paragraphs().end();
|
2003-04-02 17:11:38 +00:00
|
|
|
|
|
2001-09-28 20:23:49 +00:00
|
|
|
|
int lines = 0;
|
2003-04-02 17:11:38 +00:00
|
|
|
|
while (par != end) {
|
2001-11-27 10:34:16 +00:00
|
|
|
|
pos_type siz = par->size();
|
|
|
|
|
for (pos_type i = 0; i < siz; ++i) {
|
2003-02-08 19:18:01 +00:00
|
|
|
|
// ignore all struck out text
|
2003-02-26 17:04:10 +00:00
|
|
|
|
if (isDeletedText(*par, i))
|
2003-02-08 19:18:01 +00:00
|
|
|
|
continue;
|
2003-03-17 16:25:00 +00:00
|
|
|
|
|
2005-02-03 17:24:40 +00:00
|
|
|
|
os << par->getChar(i);
|
2001-07-09 23:12:04 +00:00
|
|
|
|
}
|
2003-04-02 17:11:38 +00:00
|
|
|
|
++par;
|
|
|
|
|
if (par != end) {
|
2003-06-07 17:45:43 +00:00
|
|
|
|
os << "\n";
|
|
|
|
|
++lines;
|
2001-09-28 20:23:49 +00:00
|
|
|
|
}
|
2001-06-27 14:10:35 +00:00
|
|
|
|
}
|
2002-03-21 17:09:55 +00:00
|
|
|
|
|
2001-09-28 20:23:49 +00:00
|
|
|
|
return lines;
|
2001-06-27 14:10:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-11-05 12:06:20 +00:00
|
|
|
|
int InsetERT::plaintext(Buffer const &, ostream &,
|
|
|
|
|
OutputParams const & /*runparams*/) const
|
2001-06-27 14:10:35 +00:00
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-10-31 18:45:43 +00:00
|
|
|
|
int InsetERT::linuxdoc(Buffer const &, ostream & os,
|
2004-03-25 09:16:36 +00:00
|
|
|
|
OutputParams const &) const
|
2001-06-27 14:10:35 +00:00
|
|
|
|
{
|
2004-03-28 22:00:22 +00:00
|
|
|
|
ParagraphList::const_iterator par = paragraphs().begin();
|
|
|
|
|
ParagraphList::const_iterator end = paragraphs().end();
|
2003-04-02 17:11:38 +00:00
|
|
|
|
|
2001-10-15 12:21:11 +00:00
|
|
|
|
int lines = 0;
|
2003-04-02 17:11:38 +00:00
|
|
|
|
while (par != end) {
|
2001-11-27 10:34:16 +00:00
|
|
|
|
pos_type siz = par->size();
|
2005-02-03 17:24:40 +00:00
|
|
|
|
for (pos_type i = 0; i < siz; ++i)
|
|
|
|
|
os << par->getChar(i);
|
2003-04-02 17:11:38 +00:00
|
|
|
|
++par;
|
|
|
|
|
if (par != end) {
|
2001-10-15 12:21:11 +00:00
|
|
|
|
os << "\n";
|
|
|
|
|
lines ++;
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-03-21 17:09:55 +00:00
|
|
|
|
|
2001-10-15 12:21:11 +00:00
|
|
|
|
return lines;
|
2001-06-27 14:10:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-10-31 18:45:43 +00:00
|
|
|
|
int InsetERT::docbook(Buffer const &, ostream & os,
|
2003-11-05 12:06:20 +00:00
|
|
|
|
OutputParams const &) const
|
2001-06-27 14:10:35 +00:00
|
|
|
|
{
|
2004-03-28 22:00:22 +00:00
|
|
|
|
ParagraphList::const_iterator par = paragraphs().begin();
|
|
|
|
|
ParagraphList::const_iterator end = paragraphs().end();
|
2003-04-02 17:11:38 +00:00
|
|
|
|
|
2001-10-15 12:21:11 +00:00
|
|
|
|
int lines = 0;
|
2003-04-02 17:11:38 +00:00
|
|
|
|
while (par != end) {
|
2001-11-27 10:34:16 +00:00
|
|
|
|
pos_type siz = par->size();
|
2005-02-03 17:24:40 +00:00
|
|
|
|
for (pos_type i = 0; i < siz; ++i)
|
|
|
|
|
os << par->getChar(i);
|
2003-04-02 17:11:38 +00:00
|
|
|
|
++par;
|
|
|
|
|
if (par != end) {
|
2001-10-15 12:21:11 +00:00
|
|
|
|
os << "\n";
|
2004-04-01 10:21:29 +00:00
|
|
|
|
++lines;
|
2001-10-15 12:21:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2002-03-21 17:09:55 +00:00
|
|
|
|
|
2001-10-15 12:21:11 +00:00
|
|
|
|
return lines;
|
2000-03-24 13:24:58 +00:00
|
|
|
|
}
|
2001-07-24 15:07:09 +00:00
|
|
|
|
|
|
|
|
|
|
2004-11-24 21:58:42 +00:00
|
|
|
|
void InsetERT::doDispatch(LCursor & cur, FuncRequest & cmd)
|
2001-07-24 15:07:09 +00:00
|
|
|
|
{
|
2004-11-24 21:58:42 +00:00
|
|
|
|
//lyxerr << "\nInsetERT::doDispatch (begin): cmd: " << cmd << endl;
|
2002-08-19 10:11:13 +00:00
|
|
|
|
switch (cmd.action) {
|
2003-05-16 07:44:00 +00:00
|
|
|
|
|
2004-01-15 17:34:44 +00:00
|
|
|
|
case LFUN_INSET_MODIFY: {
|
|
|
|
|
InsetCollapsable::CollapseStatus st;
|
|
|
|
|
InsetERTMailer::string2params(cmd.argument, st);
|
2005-05-06 20:00:31 +00:00
|
|
|
|
setStatus(cur, st);
|
2004-02-16 11:58:51 +00:00
|
|
|
|
break;
|
2004-01-15 17:34:44 +00:00
|
|
|
|
}
|
2005-02-03 17:24:40 +00:00
|
|
|
|
case LFUN_PASTE:
|
|
|
|
|
case LFUN_PASTESELECTION: {
|
|
|
|
|
InsetCollapsable::doDispatch(cur, cmd);
|
2003-12-10 09:45:32 +00:00
|
|
|
|
|
2005-02-03 17:24:40 +00:00
|
|
|
|
// Since we can only store plain text, we must reset all
|
|
|
|
|
// attributes.
|
|
|
|
|
// FIXME: Change only the pasted paragraphs
|
|
|
|
|
|
|
|
|
|
BufferParams const & bp = cur.buffer().params();
|
|
|
|
|
LyXLayout_ptr const layout =
|
|
|
|
|
bp.getLyXTextClass().defaultLayout();
|
|
|
|
|
LyXFont font = layout->font;
|
|
|
|
|
// We need to set the language for non-english documents
|
|
|
|
|
font.setLanguage(bp.language);
|
|
|
|
|
ParagraphList::iterator const end = paragraphs().end();
|
|
|
|
|
for (ParagraphList::iterator par = paragraphs().begin();
|
|
|
|
|
par != end; ++par) {
|
|
|
|
|
par->layout(layout);
|
|
|
|
|
// in case par had a manual label
|
|
|
|
|
par->setBeginOfBody();
|
|
|
|
|
pos_type const siz = par->size();
|
|
|
|
|
for (pos_type i = 0; i < siz; ++i) {
|
|
|
|
|
par->setFont(i, font);
|
|
|
|
|
}
|
|
|
|
|
par->params().clear();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
2001-07-24 15:07:09 +00:00
|
|
|
|
default:
|
2004-11-24 21:58:42 +00:00
|
|
|
|
InsetCollapsable::doDispatch(cur, cmd);
|
2004-02-16 11:58:51 +00:00
|
|
|
|
break;
|
2001-07-24 15:07:09 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2001-07-24 22:08:49 +00:00
|
|
|
|
|
|
|
|
|
|
2004-11-04 19:50:04 +00:00
|
|
|
|
bool InsetERT::getStatus(LCursor & cur, FuncRequest const & cmd,
|
|
|
|
|
FuncStatus & status) const
|
|
|
|
|
{
|
|
|
|
|
switch (cmd.action) {
|
|
|
|
|
// suppress these
|
2005-02-03 17:24:40 +00:00
|
|
|
|
case LFUN_ACUTE:
|
|
|
|
|
case LFUN_BREVE:
|
|
|
|
|
case LFUN_CARON:
|
|
|
|
|
case LFUN_CEDILLA:
|
|
|
|
|
case LFUN_CIRCLE:
|
|
|
|
|
case LFUN_CIRCUMFLEX:
|
|
|
|
|
case LFUN_DOT:
|
|
|
|
|
case LFUN_GRAVE:
|
|
|
|
|
case LFUN_HUNG_UMLAUT:
|
|
|
|
|
case LFUN_MACRON:
|
|
|
|
|
case LFUN_OGONEK:
|
|
|
|
|
case LFUN_SPECIAL_CARON:
|
|
|
|
|
case LFUN_TIE:
|
|
|
|
|
case LFUN_TILDE:
|
|
|
|
|
case LFUN_UMLAUT:
|
|
|
|
|
case LFUN_UNDERBAR:
|
|
|
|
|
case LFUN_UNDERDOT:
|
|
|
|
|
case LFUN_APPENDIX:
|
|
|
|
|
case LFUN_BREAKLINE:
|
|
|
|
|
case LFUN_INSET_CAPTION:
|
|
|
|
|
case LFUN_DEPTH_MIN:
|
|
|
|
|
case LFUN_DEPTH_PLUS:
|
|
|
|
|
case LFUN_LDOTS:
|
|
|
|
|
case LFUN_END_OF_SENTENCE:
|
|
|
|
|
case LFUN_ENVIRONMENT_INSERT:
|
|
|
|
|
case LFUN_INSET_ERT:
|
|
|
|
|
case LFUN_FILE_INSERT:
|
|
|
|
|
case LFUN_INSET_FLOAT:
|
|
|
|
|
case LFUN_INSET_WIDE_FLOAT:
|
|
|
|
|
case LFUN_INSET_WRAP:
|
2004-11-04 19:50:04 +00:00
|
|
|
|
case LFUN_BOLD:
|
|
|
|
|
case LFUN_CODE:
|
|
|
|
|
case LFUN_DEFAULT:
|
|
|
|
|
case LFUN_EMPH:
|
|
|
|
|
case LFUN_FREEFONT_APPLY:
|
|
|
|
|
case LFUN_FREEFONT_UPDATE:
|
|
|
|
|
case LFUN_NOUN:
|
|
|
|
|
case LFUN_ROMAN:
|
|
|
|
|
case LFUN_SANS:
|
|
|
|
|
case LFUN_FRAK:
|
|
|
|
|
case LFUN_ITAL:
|
|
|
|
|
case LFUN_FONT_SIZE:
|
|
|
|
|
case LFUN_FONT_STATE:
|
|
|
|
|
case LFUN_UNDERLINE:
|
2005-02-03 17:24:40 +00:00
|
|
|
|
case LFUN_INSET_FOOTNOTE:
|
|
|
|
|
case LFUN_HFILL:
|
|
|
|
|
case LFUN_HTMLURL:
|
|
|
|
|
case LFUN_HYPHENATION:
|
|
|
|
|
case LFUN_LIGATURE_BREAK:
|
|
|
|
|
case LFUN_INDEX_INSERT:
|
|
|
|
|
case LFUN_INDEX_PRINT:
|
|
|
|
|
case LFUN_INSERT_LABEL:
|
|
|
|
|
case LFUN_INSET_OPTARG:
|
|
|
|
|
case LFUN_INSERT_BIBITEM:
|
|
|
|
|
case LFUN_INSERT_LINE:
|
|
|
|
|
case LFUN_INSERT_PAGEBREAK:
|
|
|
|
|
case LFUN_LANGUAGE:
|
|
|
|
|
case LFUN_LAYOUT:
|
|
|
|
|
case LFUN_LAYOUT_PARAGRAPH:
|
|
|
|
|
case LFUN_LAYOUT_TABULAR:
|
|
|
|
|
case LFUN_INSET_MARGINAL:
|
|
|
|
|
case LFUN_MATH_DISPLAY:
|
|
|
|
|
case LFUN_INSERT_MATH:
|
|
|
|
|
case LFUN_INSERT_MATRIX:
|
|
|
|
|
case LFUN_MATH_MODE:
|
|
|
|
|
case LFUN_MENU_OPEN_BY_NAME:
|
|
|
|
|
case LFUN_MENU_SEPARATOR:
|
|
|
|
|
case LFUN_INSERT_BRANCH:
|
|
|
|
|
case LFUN_INSERT_CHARSTYLE:
|
|
|
|
|
case LFUN_INSERT_NOTE:
|
|
|
|
|
case LFUN_INSERT_BOX:
|
|
|
|
|
case LFUN_GOTONOTE:
|
|
|
|
|
case LFUN_PARAGRAPH_SPACING:
|
|
|
|
|
case LFUN_QUOTE:
|
2005-05-08 10:02:38 +00:00
|
|
|
|
case LFUN_LABEL_GOTO:
|
2005-02-03 17:24:40 +00:00
|
|
|
|
case LFUN_REFERENCE_GOTO:
|
|
|
|
|
case LFUN_SPACE_INSERT:
|
|
|
|
|
case LFUN_GOTOFILEROW:
|
|
|
|
|
case LFUN_NOTIFY:
|
|
|
|
|
case LFUN_SETXY:
|
|
|
|
|
case LFUN_TABULAR_INSERT:
|
|
|
|
|
case LFUN_TOC_INSERT:
|
|
|
|
|
case LFUN_URL:
|
|
|
|
|
case LFUN_FLOAT_LIST:
|
|
|
|
|
case LFUN_INSET_INSERT:
|
|
|
|
|
case LFUN_PARAGRAPH_APPLY:
|
|
|
|
|
case LFUN_PARAGRAPH_UPDATE:
|
|
|
|
|
case LFUN_NOACTION:
|
2004-11-04 19:50:04 +00:00
|
|
|
|
status.enabled(false);
|
|
|
|
|
return true;
|
2004-11-23 23:04:52 +00:00
|
|
|
|
|
2005-04-22 08:57:22 +00:00
|
|
|
|
case LFUN_INSET_MODIFY:
|
|
|
|
|
case LFUN_PASTE:
|
|
|
|
|
case LFUN_PASTESELECTION:
|
|
|
|
|
status.enabled(true);
|
|
|
|
|
return true;
|
|
|
|
|
|
2005-02-03 17:24:40 +00:00
|
|
|
|
// this one is difficult to get right. As a half-baked
|
|
|
|
|
// solution, we consider only the first action of the sequence
|
|
|
|
|
case LFUN_SEQUENCE: {
|
|
|
|
|
// argument contains ';'-terminated commands
|
|
|
|
|
string const firstcmd = token(cmd.argument, ';', 0);
|
|
|
|
|
FuncRequest func(lyxaction.lookupFunc(firstcmd));
|
|
|
|
|
func.origin = cmd.origin;
|
|
|
|
|
return getStatus(cur, func, status);
|
|
|
|
|
}
|
|
|
|
|
|
2004-11-04 19:50:04 +00:00
|
|
|
|
default:
|
|
|
|
|
return InsetCollapsable::getStatus(cur, cmd, status);
|
2005-02-03 17:24:40 +00:00
|
|
|
|
}
|
2004-11-04 19:50:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-12-12 14:02:14 +00:00
|
|
|
|
void InsetERT::setButtonLabel()
|
2001-07-25 19:45:21 +00:00
|
|
|
|
{
|
2005-11-07 12:21:59 +00:00
|
|
|
|
setLabel(isOpen() ? _("ERT") : getNewLabel(_("ERT")));
|
2001-07-25 19:45:21 +00:00
|
|
|
|
}
|
2001-07-27 12:03:36 +00:00
|
|
|
|
|
|
|
|
|
|
2005-02-03 17:24:40 +00:00
|
|
|
|
bool InsetERT::insetAllowed(InsetBase::Code /* code */) const
|
2003-12-02 07:15:42 +00:00
|
|
|
|
{
|
2005-02-03 17:24:40 +00:00
|
|
|
|
return false;
|
2003-12-02 07:15:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-06-02 10:03:27 +00:00
|
|
|
|
void InsetERT::metrics(MetricsInfo & mi, Dimension & dim) const
|
2001-07-31 09:53:40 +00:00
|
|
|
|
{
|
2003-12-03 18:17:20 +00:00
|
|
|
|
LyXFont tmpfont = mi.base.font;
|
|
|
|
|
getDrawFont(mi.base.font);
|
2005-04-10 14:07:33 +00:00
|
|
|
|
mi.base.font.realize(tmpfont);
|
2003-12-02 07:15:42 +00:00
|
|
|
|
InsetCollapsable::metrics(mi, dim);
|
2003-12-03 18:17:20 +00:00
|
|
|
|
mi.base.font = tmpfont;
|
2003-07-18 07:47:07 +00:00
|
|
|
|
dim_ = dim;
|
2001-08-06 14:55:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-05-30 06:48:24 +00:00
|
|
|
|
void InsetERT::draw(PainterInfo & pi, int x, int y) const
|
2001-07-31 09:53:40 +00:00
|
|
|
|
{
|
2003-12-03 18:17:20 +00:00
|
|
|
|
LyXFont tmpfont = pi.base.font;
|
|
|
|
|
getDrawFont(pi.base.font);
|
2005-04-10 14:07:33 +00:00
|
|
|
|
// I don't understand why the above .realize isn't needed, or
|
|
|
|
|
// even wanted, here. It just works. -- MV 10.04.2005
|
2003-12-02 07:15:42 +00:00
|
|
|
|
InsetCollapsable::draw(pi, x, y);
|
2003-12-03 18:17:20 +00:00
|
|
|
|
pi.base.font = tmpfont;
|
2001-08-06 14:55:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-03-10 22:12:07 +00:00
|
|
|
|
bool InsetERT::showInsetDialog(BufferView * bv) const
|
2001-08-06 14:55:02 +00:00
|
|
|
|
{
|
2003-07-14 17:50:00 +00:00
|
|
|
|
InsetERTMailer(const_cast<InsetERT &>(*this)).showDialog(bv);
|
2001-08-06 14:55:02 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-02-20 14:55:17 +00:00
|
|
|
|
void InsetERT::getDrawFont(LyXFont & font) const
|
|
|
|
|
{
|
2003-11-10 09:06:48 +00:00
|
|
|
|
font = LyXFont(LyXFont::ALL_INHERIT, latex_language);
|
2002-02-20 14:55:17 +00:00
|
|
|
|
font.setFamily(LyXFont::TYPEWRITER_FAMILY);
|
|
|
|
|
font.setColor(LColor::latex);
|
|
|
|
|
}
|
2002-03-05 14:55:20 +00:00
|
|
|
|
|
|
|
|
|
|
2003-03-07 14:08:10 +00:00
|
|
|
|
string const InsetERTMailer::name_("ert");
|
|
|
|
|
|
2003-02-25 14:51:38 +00:00
|
|
|
|
InsetERTMailer::InsetERTMailer(InsetERT & inset)
|
2003-03-07 14:08:10 +00:00
|
|
|
|
: inset_(inset)
|
2003-02-25 14:51:38 +00:00
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
2003-07-23 09:54:21 +00:00
|
|
|
|
string const InsetERTMailer::inset2string(Buffer const &) const
|
2003-02-25 14:51:38 +00:00
|
|
|
|
{
|
2003-03-07 14:08:10 +00:00
|
|
|
|
return params2string(inset_.status());
|
2003-02-25 14:51:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void InsetERTMailer::string2params(string const & in,
|
2003-12-10 21:32:05 +00:00
|
|
|
|
InsetCollapsable::CollapseStatus & status)
|
2003-02-25 14:51:38 +00:00
|
|
|
|
{
|
2003-12-02 07:15:42 +00:00
|
|
|
|
status = InsetCollapsable::Collapsed;
|
2003-12-11 15:23:15 +00:00
|
|
|
|
if (in.empty())
|
|
|
|
|
return;
|
2003-02-27 13:26:07 +00:00
|
|
|
|
|
2003-12-10 21:32:05 +00:00
|
|
|
|
istringstream data(in);
|
|
|
|
|
LyXLex lex(0,0);
|
|
|
|
|
lex.setStream(data);
|
2003-02-27 13:26:07 +00:00
|
|
|
|
|
2003-12-10 21:32:05 +00:00
|
|
|
|
string name;
|
|
|
|
|
lex >> name;
|
2003-12-11 15:23:15 +00:00
|
|
|
|
if (name != name_)
|
|
|
|
|
return print_mailer_error("InsetERTMailer", in, 1, name_);
|
2003-02-25 14:51:38 +00:00
|
|
|
|
|
2003-12-10 21:32:05 +00:00
|
|
|
|
int s;
|
|
|
|
|
lex >> s;
|
|
|
|
|
if (lex)
|
|
|
|
|
status = static_cast<InsetCollapsable::CollapseStatus>(s);
|
2003-02-25 14:51:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-12-02 07:15:42 +00:00
|
|
|
|
string const
|
|
|
|
|
InsetERTMailer::params2string(InsetCollapsable::CollapseStatus status)
|
2003-02-25 14:51:38 +00:00
|
|
|
|
{
|
2003-12-10 21:32:05 +00:00
|
|
|
|
ostringstream data;
|
|
|
|
|
data << name_ << ' ' << status;
|
|
|
|
|
return data.str();
|
2003-02-25 14:51:38 +00:00
|
|
|
|
}
|