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);
|
2006-02-27 12:22:36 +00:00
|
|
|
|
text_.current_font.setLanguage(latex_language);
|
|
|
|
|
text_.real_current_font.setLanguage(latex_language);
|
2003-09-16 15:39:33 +00:00
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-02-27 12:22:36 +00:00
|
|
|
|
#if 0
|
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
|
|
|
|
{
|
2006-02-27 12:22:36 +00:00
|
|
|
|
LyXFont font(LyXFont::ALL_INHERIT, latex_language);
|
|
|
|
|
paragraphs().begin()->insert(0, contents, font);
|
2004-03-25 09:16:36 +00:00
|
|
|
|
|
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
|
|
|
|
}
|
2006-02-27 12:22:36 +00:00
|
|
|
|
#endif
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-02-27 12:22:36 +00:00
|
|
|
|
void InsetERT::read(Buffer const & buf, LyXLex & lex)
|
|
|
|
|
{
|
|
|
|
|
InsetCollapsable::read(buf, lex);
|
|
|
|
|
|
|
|
|
|
// Force default font
|
|
|
|
|
// This avoids paragraphs in buffer language that would have a
|
|
|
|
|
// foreign language after a document langauge change, and it ensures
|
|
|
|
|
// that all new text in ERT gets the "latex" language, since new text
|
|
|
|
|
// inherits the language from the last position of the existing text.
|
|
|
|
|
// As a side effect this makes us also robust against bugs in LyX
|
|
|
|
|
// that might lead to font changes in ERT in .lyx files.
|
|
|
|
|
LyXFont font(LyXFont::ALL_INHERIT, latex_language);
|
|
|
|
|
ParagraphList::iterator par = paragraphs().begin();
|
|
|
|
|
ParagraphList::iterator const end = paragraphs().end();
|
|
|
|
|
while (par != end) {
|
|
|
|
|
pos_type siz = par->size();
|
|
|
|
|
for (pos_type i = 0; i <= siz; ++i) {
|
|
|
|
|
par->setFont(i, font);
|
|
|
|
|
}
|
|
|
|
|
++par;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-03-21 17:09:55 +00:00
|
|
|
|
string const InsetERT::editMessage() const
|
2000-04-04 00:19:15 +00:00
|
|
|
|
{
|
2006-09-09 15:27:44 +00:00
|
|
|
|
// FIXME UNICODE
|
|
|
|
|
return lyx::to_utf8(_("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::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
|
|
|
|
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_QUOTE_INSERT: {
|
2006-03-27 14:13:48 +00:00
|
|
|
|
// We need to bypass the fancy quotes in LyXText
|
2006-05-05 20:23:12 +00:00
|
|
|
|
FuncRequest f(LFUN_SELF_INSERT, "\"");
|
2006-03-27 14:13:48 +00:00
|
|
|
|
dispatch(cur, f);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2004-01-15 17:34:44 +00:00
|
|
|
|
case LFUN_INSET_MODIFY: {
|
|
|
|
|
InsetCollapsable::CollapseStatus st;
|
2006-09-01 15:41:38 +00:00
|
|
|
|
InsetERTMailer::string2params(lyx::to_utf8(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:
|
Split clipboard and X selection
* src/LyXAction.C
(LyXAction::init): handle new LFUN_CLIPBOARD_PASTE
* src/insets/insettabular.C
(InsetTabular::doDispatch): ditto
* src/insets/insetbox.C
(InsetBox::doDispatch): ditto
* src/insets/insetert.C
(InsetERT::doDispatch): ditto
(InsetERT::getStatus): ditto
* src/insets/insetcharstyle.C
(InsetCharStyle::doDispatch): ditto
* src/BufferView_pimpl.C
(BufferView::Pimpl::selectionRequest): stuff selection, not clipboard
* src/mathed/math_nestinset.C
(MathNestInset::lfunMousePress): get stuff selection, not clipboard
(MathNestInset::lfunMouseRelease): clipboard -> selection in
commented code
* src/CutAndPaste.C
(cutSelection): ditto
* src/frontends/{qt3,gtk}/GuiImplementation.C
(GuiImplementation::newWorkArea): create new selection, not clipboard,
since the clipboard is now an object
(GuiImplementation::destroyWorkArea): destroy selection, not clipboard
* src/frontends/{qt4,qt3,gtk}/GuiSelection.h: new, copied from
GuiClipboard.h
* src/frontends/{qt4,qt3,gtk}/GuiSelection.C: new, copied from
GuiClipboard.C
* src/frontends/{qt3,gtk}/GuiImplementation.h
(selection): new accessor for selection_
(selection_): new, the global selection object
* src/frontends/{qt4,qt3,gtk}/Makefile.am: add GuiSelection.C and
GuiSelection.h
* src/frontends/{qt4,qt3,gtk}/GuiClipboard.C
(GuiClipboard::get): return clipboard, not selection
(GuiClipboard::put): stuff clipboard, not selection
* src/frontends/{qt4,qt3,gtk}/GuiClipboard.h
(haveSelection): remove (this is now in GuiSelection)
* src/frontends/{qt3,gtk}/GuiClipboard.h
(old_work_area_): remove, since it is not needed anymore
* src/frontends/gtk/ghelpers.C
(getGTKStockIcon): handle LFUN_CLIPBOARD_PASTE
* src/frontends/Clipboard.h
(haveSelection): remove (this is now in Selection)
* src/frontends/qt4/GuiImplementation.[Ch]
(GuiImplementation::selection): new accessor for selection_
* src/frontends/Gui.h
(selection): New accessor for the global selection object
* src/frontends/Selection.h; new, copied from Clipboard.h
* src/frontends/Makefile.am: add Selection.h
* src/text3.C
(various): s/clipboard().haveSelection/selection().haveSelection/
(LyXText::dispatch): handle LFUN_CLIPBOARD_PASTE
(LyXText::getStatus): ditto
* src/lfuns.h: new lfun LFUN_CLIPBOARD_PASTE
* lib/ui/stdmenus.ui: add new lfun LFUN_CLIPBOARD_PASTE
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14408 a592a061-630c-0410-9148-cb99ea01b6c8
2006-07-10 11:32:25 +00:00
|
|
|
|
case LFUN_CLIPBOARD_PASTE:
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_PRIMARY_SELECTION_PASTE: {
|
2005-02-03 17:24:40 +00:00
|
|
|
|
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.
|
2006-03-30 12:43:32 +00:00
|
|
|
|
forceParagraphsToDefault(cur);
|
2005-02-03 17:24:40 +00:00
|
|
|
|
// FIXME: Change only the pasted paragraphs
|
|
|
|
|
|
|
|
|
|
BufferParams const & bp = cur.buffer().params();
|
|
|
|
|
LyXLayout_ptr const layout =
|
|
|
|
|
bp.getLyXTextClass().defaultLayout();
|
|
|
|
|
LyXFont font = layout->font;
|
2006-02-27 12:22:36 +00:00
|
|
|
|
// ERT contents has always latex_language
|
|
|
|
|
font.setLanguage(latex_language);
|
2005-02-03 17:24:40 +00:00
|
|
|
|
ParagraphList::iterator const end = paragraphs().end();
|
|
|
|
|
for (ParagraphList::iterator par = paragraphs().begin();
|
|
|
|
|
par != end; ++par) {
|
|
|
|
|
// 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:
|
2006-02-27 12:22:36 +00:00
|
|
|
|
// Force any new text to latex_language
|
|
|
|
|
// FIXME: This should only be necessary in init(), but
|
|
|
|
|
// new paragraphs that are created by pressing enter at the
|
|
|
|
|
// start of an existing paragraph get the buffer language
|
|
|
|
|
// and not latex_language, so we take this brute force
|
|
|
|
|
// approach.
|
|
|
|
|
text_.current_font.setLanguage(latex_language);
|
|
|
|
|
text_.real_current_font.setLanguage(latex_language);
|
|
|
|
|
|
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
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_ACCENT_ACUTE:
|
|
|
|
|
case LFUN_ACCENT_BREVE:
|
|
|
|
|
case LFUN_ACCENT_CARON:
|
|
|
|
|
case LFUN_ACCENT_CEDILLA:
|
|
|
|
|
case LFUN_ACCENT_CIRCLE:
|
|
|
|
|
case LFUN_ACCENT_CIRCUMFLEX:
|
|
|
|
|
case LFUN_ACCENT_DOT:
|
|
|
|
|
case LFUN_ACCENT_GRAVE:
|
|
|
|
|
case LFUN_ACCENT_HUNGARIAN_UMLAUT:
|
|
|
|
|
case LFUN_ACCENT_MACRON:
|
|
|
|
|
case LFUN_ACCENT_OGONEK:
|
|
|
|
|
case LFUN_ACCENT_SPECIAL_CARON:
|
|
|
|
|
case LFUN_ACCENT_TIE:
|
|
|
|
|
case LFUN_ACCENT_TILDE:
|
|
|
|
|
case LFUN_ACCENT_UMLAUT:
|
|
|
|
|
case LFUN_ACCENT_UNDERBAR:
|
|
|
|
|
case LFUN_ACCENT_UNDERDOT:
|
2005-02-03 17:24:40 +00:00
|
|
|
|
case LFUN_APPENDIX:
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_BREAK_LINE:
|
|
|
|
|
case LFUN_CAPTION_INSERT:
|
|
|
|
|
case LFUN_DEPTH_DECREMENT:
|
|
|
|
|
case LFUN_DEPTH_INCREMENT:
|
|
|
|
|
case LFUN_DOTS_INSERT:
|
2006-05-08 18:09:19 +00:00
|
|
|
|
case LFUN_END_OF_SENTENCE_PERIOD_INSERT:
|
2005-02-03 17:24:40 +00:00
|
|
|
|
case LFUN_ENVIRONMENT_INSERT:
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_ERT_INSERT:
|
2005-02-03 17:24:40 +00:00
|
|
|
|
case LFUN_FILE_INSERT:
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_FLOAT_INSERT:
|
|
|
|
|
case LFUN_FLOAT_WIDE_INSERT:
|
|
|
|
|
case LFUN_WRAP_INSERT:
|
|
|
|
|
case LFUN_FONT_BOLD:
|
|
|
|
|
case LFUN_FONT_CODE:
|
|
|
|
|
case LFUN_FONT_DEFAULT:
|
|
|
|
|
case LFUN_FONT_EMPH:
|
|
|
|
|
case LFUN_FONT_FREE_APPLY:
|
|
|
|
|
case LFUN_FONT_FREE_UPDATE:
|
|
|
|
|
case LFUN_FONT_NOUN:
|
|
|
|
|
case LFUN_FONT_ROMAN:
|
|
|
|
|
case LFUN_FONT_SANS:
|
|
|
|
|
case LFUN_FONT_FRAK:
|
|
|
|
|
case LFUN_FONT_ITAL:
|
2004-11-04 19:50:04 +00:00
|
|
|
|
case LFUN_FONT_SIZE:
|
|
|
|
|
case LFUN_FONT_STATE:
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_FONT_UNDERLINE:
|
|
|
|
|
case LFUN_FOOTNOTE_INSERT:
|
|
|
|
|
case LFUN_HFILL_INSERT:
|
|
|
|
|
case LFUN_HTML_INSERT:
|
|
|
|
|
case LFUN_HYPHENATION_POINT_INSERT:
|
|
|
|
|
case LFUN_LIGATURE_BREAK_INSERT:
|
2005-02-03 17:24:40 +00:00
|
|
|
|
case LFUN_INDEX_INSERT:
|
|
|
|
|
case LFUN_INDEX_PRINT:
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_LABEL_INSERT:
|
|
|
|
|
case LFUN_OPTIONAL_INSERT:
|
|
|
|
|
case LFUN_BIBITEM_INSERT:
|
|
|
|
|
case LFUN_LINE_INSERT:
|
|
|
|
|
case LFUN_PAGEBREAK_INSERT:
|
2005-02-03 17:24:40 +00:00
|
|
|
|
case LFUN_LANGUAGE:
|
|
|
|
|
case LFUN_LAYOUT:
|
|
|
|
|
case LFUN_LAYOUT_PARAGRAPH:
|
|
|
|
|
case LFUN_LAYOUT_TABULAR:
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_MARGINALNOTE_INSERT:
|
2005-02-03 17:24:40 +00:00
|
|
|
|
case LFUN_MATH_DISPLAY:
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_MATH_INSERT:
|
|
|
|
|
case LFUN_MATH_MATRIX:
|
2005-02-03 17:24:40 +00:00
|
|
|
|
case LFUN_MATH_MODE:
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_MENU_OPEN:
|
|
|
|
|
case LFUN_MENU_SEPARATOR_INSERT:
|
|
|
|
|
case LFUN_BRANCH_INSERT:
|
|
|
|
|
case LFUN_CHARSTYLE_INSERT:
|
|
|
|
|
case LFUN_NOTE_INSERT:
|
|
|
|
|
case LFUN_BOX_INSERT:
|
|
|
|
|
case LFUN_NOTE_NEXT:
|
2005-02-03 17:24:40 +00:00
|
|
|
|
case LFUN_PARAGRAPH_SPACING:
|
2005-05-08 10:02:38 +00:00
|
|
|
|
case LFUN_LABEL_GOTO:
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_REFERENCE_NEXT:
|
2005-02-03 17:24:40 +00:00
|
|
|
|
case LFUN_SPACE_INSERT:
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_SERVER_GOTO_FILE_ROW:
|
|
|
|
|
case LFUN_SERVER_NOTIFY:
|
|
|
|
|
case LFUN_SERVER_SET_XY:
|
2005-02-03 17:24:40 +00:00
|
|
|
|
case LFUN_TABULAR_INSERT:
|
|
|
|
|
case LFUN_TOC_INSERT:
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_URL_INSERT:
|
2005-02-03 17:24:40 +00:00
|
|
|
|
case LFUN_FLOAT_LIST:
|
|
|
|
|
case LFUN_INSET_INSERT:
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_PARAGRAPH_PARAMS_APPLY:
|
2005-02-03 17:24:40 +00:00
|
|
|
|
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
|
|
|
|
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_QUOTE_INSERT:
|
2005-04-22 08:57:22 +00:00
|
|
|
|
case LFUN_INSET_MODIFY:
|
|
|
|
|
case LFUN_PASTE:
|
Split clipboard and X selection
* src/LyXAction.C
(LyXAction::init): handle new LFUN_CLIPBOARD_PASTE
* src/insets/insettabular.C
(InsetTabular::doDispatch): ditto
* src/insets/insetbox.C
(InsetBox::doDispatch): ditto
* src/insets/insetert.C
(InsetERT::doDispatch): ditto
(InsetERT::getStatus): ditto
* src/insets/insetcharstyle.C
(InsetCharStyle::doDispatch): ditto
* src/BufferView_pimpl.C
(BufferView::Pimpl::selectionRequest): stuff selection, not clipboard
* src/mathed/math_nestinset.C
(MathNestInset::lfunMousePress): get stuff selection, not clipboard
(MathNestInset::lfunMouseRelease): clipboard -> selection in
commented code
* src/CutAndPaste.C
(cutSelection): ditto
* src/frontends/{qt3,gtk}/GuiImplementation.C
(GuiImplementation::newWorkArea): create new selection, not clipboard,
since the clipboard is now an object
(GuiImplementation::destroyWorkArea): destroy selection, not clipboard
* src/frontends/{qt4,qt3,gtk}/GuiSelection.h: new, copied from
GuiClipboard.h
* src/frontends/{qt4,qt3,gtk}/GuiSelection.C: new, copied from
GuiClipboard.C
* src/frontends/{qt3,gtk}/GuiImplementation.h
(selection): new accessor for selection_
(selection_): new, the global selection object
* src/frontends/{qt4,qt3,gtk}/Makefile.am: add GuiSelection.C and
GuiSelection.h
* src/frontends/{qt4,qt3,gtk}/GuiClipboard.C
(GuiClipboard::get): return clipboard, not selection
(GuiClipboard::put): stuff clipboard, not selection
* src/frontends/{qt4,qt3,gtk}/GuiClipboard.h
(haveSelection): remove (this is now in GuiSelection)
* src/frontends/{qt3,gtk}/GuiClipboard.h
(old_work_area_): remove, since it is not needed anymore
* src/frontends/gtk/ghelpers.C
(getGTKStockIcon): handle LFUN_CLIPBOARD_PASTE
* src/frontends/Clipboard.h
(haveSelection): remove (this is now in Selection)
* src/frontends/qt4/GuiImplementation.[Ch]
(GuiImplementation::selection): new accessor for selection_
* src/frontends/Gui.h
(selection): New accessor for the global selection object
* src/frontends/Selection.h; new, copied from Clipboard.h
* src/frontends/Makefile.am: add Selection.h
* src/text3.C
(various): s/clipboard().haveSelection/selection().haveSelection/
(LyXText::dispatch): handle LFUN_CLIPBOARD_PASTE
(LyXText::getStatus): ditto
* src/lfuns.h: new lfun LFUN_CLIPBOARD_PASTE
* lib/ui/stdmenus.ui: add new lfun LFUN_CLIPBOARD_PASTE
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14408 a592a061-630c-0410-9148-cb99ea01b6c8
2006-07-10 11:32:25 +00:00
|
|
|
|
case LFUN_CLIPBOARD_PASTE:
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_PRIMARY_SELECTION_PASTE:
|
2005-04-22 08:57:22 +00:00
|
|
|
|
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
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_COMMAND_SEQUENCE: {
|
2005-02-03 17:24:40 +00:00
|
|
|
|
// argument contains ';'-terminated commands
|
2006-09-01 15:41:38 +00:00
|
|
|
|
string const firstcmd = token(lyx::to_utf8(cmd.argument()), ';', 0);
|
2005-02-03 17:24:40 +00:00
|
|
|
|
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
|
|
|
|
{
|
2006-09-09 15:27:44 +00:00
|
|
|
|
// FIXME UNICODE
|
|
|
|
|
setLabel(isOpen() ? lyx::to_utf8(_("ERT")) : getNewLabel(lyx::to_utf8(_("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);
|
2006-02-27 12:22:36 +00:00
|
|
|
|
pi.base.font.realize(tmpfont);
|
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
|
|
|
|
}
|