2000-04-10 14:29:05 +00:00
|
|
|
|
// -*- C++ -*-
|
2003-08-23 00:17:00 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file CutAndPaste.h
|
2003-05-06 09:34:56 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-03-21 17:27:08 +00:00
|
|
|
|
*
|
2003-09-07 01:45:40 +00:00
|
|
|
|
* \author J<EFBFBD>rgen Vigna
|
2003-05-06 09:34:56 +00:00
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
2003-06-28 01:23:11 +00:00
|
|
|
|
* \author Alfredo Braunstein
|
2002-03-21 17:27:08 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2003-05-06 09:34:56 +00:00
|
|
|
|
*/
|
2000-04-10 14:29:05 +00:00
|
|
|
|
|
|
|
|
|
#ifndef CUTANDPASTE_H
|
|
|
|
|
#define CUTANDPASTE_H
|
|
|
|
|
|
2006-10-11 19:40:50 +00:00
|
|
|
|
#include "support/docstring.h"
|
This is one of a series of patches that will merge the layout modules development in personal/branches/rgheck back into the tree.
Design goal: Allow the use of layout "modules", which are to LaTeX packages as layout files are to LaTeX document classes. Thus, one could have a module that defined certain character styles, environments, commands, or what have you, and include it in various documents, each of which uses a different document class, without having to modify the layout files themselves. For example, a theorems.module could be used with article.layout to provide support for theorem-type environments, without having to modify article.layout itself, and the same module could be used with book.layout, etc.
This first patch does some reworking of the infrastructrue. We need to distinguish between the TextClass that a particular document is using and the layout of that document, since modules, in particular, can modify the layout. The solution adopted here is to add a TextClass pointer to BufferParams, which will hold the layout. The layout itself is then constructed from the TextClass the document is using. At present, this is completely trivial, but that will change when modules are added.
The pointer in question is a boost::shared_ptr. This is needed because CutAndPaste saves a copy of the layout with each cut or copied selection. We cannot assume the selection vanishes when the document is closed, so there are two options: (i) keep a list of all the layouts that have ever been used by any document; (ii) used some kind of smart pointer. The latter seems preferable, as the former would waste memory. More importantly, the use of a smart pointer allows modules to be modified on disk and then reloaded while LyX is running, and it will eventually allow the same for layout files.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19756 a592a061-630c-0410-9148-cb99ea01b6c8
2007-08-23 16:41:13 +00:00
|
|
|
|
#include "TextClass_ptr.h"
|
2000-04-10 14:29:05 +00:00
|
|
|
|
|
2003-06-17 15:33:49 +00:00
|
|
|
|
#include <vector>
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
namespace lyx {
|
|
|
|
|
|
2003-09-06 12:36:58 +00:00
|
|
|
|
class Buffer;
|
2003-05-20 16:51:31 +00:00
|
|
|
|
class ErrorList;
|
2006-05-21 17:33:03 +00:00
|
|
|
|
class InsetText;
|
2007-04-29 19:53:54 +00:00
|
|
|
|
class TextClass;
|
2007-04-26 14:56:30 +00:00
|
|
|
|
class Cursor;
|
2007-04-26 08:30:11 +00:00
|
|
|
|
class ParagraphList;
|
2000-04-10 14:29:05 +00:00
|
|
|
|
|
2004-03-25 09:16:36 +00:00
|
|
|
|
namespace cap {
|
2003-06-17 15:33:49 +00:00
|
|
|
|
|
2007-01-04 16:50:03 +00:00
|
|
|
|
/// Get all elements of the cut buffer in plain text format.
|
2006-10-21 00:16:43 +00:00
|
|
|
|
std::vector<docstring> const availableSelections(Buffer const & buffer);
|
2007-01-04 16:50:03 +00:00
|
|
|
|
/// Get the number of available elements in the cut buffer.
|
2006-10-21 00:16:43 +00:00
|
|
|
|
size_type numberOfSelections();
|
2007-01-04 16:50:03 +00:00
|
|
|
|
/// Get the sel_index-th element of the cut buffer in plain text format.
|
2006-10-21 00:16:43 +00:00
|
|
|
|
docstring getSelection(Buffer const & buffer, size_t sel_index);
|
2003-06-17 15:33:49 +00:00
|
|
|
|
|
2007-01-04 16:50:03 +00:00
|
|
|
|
/**
|
|
|
|
|
* Replace using the font of the first selected character and select
|
2006-08-16 21:12:20 +00:00
|
|
|
|
* the new string. When \c backwards == false, set anchor before
|
|
|
|
|
* cursor; otherwise set cursor before anchor.
|
2007-01-04 16:50:03 +00:00
|
|
|
|
* Does handle undo.
|
2004-03-25 09:16:36 +00:00
|
|
|
|
*/
|
2007-04-26 14:56:30 +00:00
|
|
|
|
void replaceSelectionWithString(Cursor & cur, docstring const & str,
|
2006-08-16 21:12:20 +00:00
|
|
|
|
bool backwards);
|
2007-02-08 10:40:46 +00:00
|
|
|
|
/// If a selection exists, delete it without pushing it to the cut buffer.
|
2007-01-04 16:50:03 +00:00
|
|
|
|
/// Does handle undo.
|
2007-04-26 14:56:30 +00:00
|
|
|
|
void replaceSelection(Cursor & cur);
|
2003-05-06 09:34:56 +00:00
|
|
|
|
|
2007-01-04 16:50:03 +00:00
|
|
|
|
/**
|
|
|
|
|
* Cut the current selection and possibly push it to the cut buffer and
|
|
|
|
|
* system clipboard.
|
2007-07-10 12:48:04 +00:00
|
|
|
|
* Does handle undo. Calls saveSelection.
|
2007-01-04 16:50:03 +00:00
|
|
|
|
* \param doclear If this is true: Delete leading spaces in paragraphs before
|
|
|
|
|
* they get merged.
|
|
|
|
|
* \param realcut If this is true: Push the selection to the cut buffer and
|
2007-02-08 10:40:46 +00:00
|
|
|
|
* system clipboard. Set this to false to only delete the
|
2007-05-28 22:27:45 +00:00
|
|
|
|
* selection.
|
2007-01-04 16:50:03 +00:00
|
|
|
|
*/
|
2007-04-26 14:56:30 +00:00
|
|
|
|
void cutSelection(Cursor & cur, bool doclear = true, bool realcut = true);
|
2007-01-04 16:50:03 +00:00
|
|
|
|
/// Push the current selection to the cut buffer and the system clipboard.
|
2007-04-26 14:56:30 +00:00
|
|
|
|
void copySelection(Cursor & cur);
|
2007-01-13 18:29:50 +00:00
|
|
|
|
/**
|
|
|
|
|
* Push the current selection to the cut buffer and the system clipboard.
|
|
|
|
|
* \param plaintext plain text version of the selection for the system
|
|
|
|
|
* clipboard
|
|
|
|
|
*/
|
2007-04-26 14:56:30 +00:00
|
|
|
|
void copySelection(Cursor & cur, docstring const & plaintext);
|
2007-02-02 03:10:15 +00:00
|
|
|
|
/// Push the selection buffer to the cut buffer.
|
|
|
|
|
void copySelectionToStack();
|
|
|
|
|
/// Store the current selection in the internal selection buffer
|
2007-04-26 14:56:30 +00:00
|
|
|
|
void saveSelection(Cursor & cur);
|
2007-02-02 03:10:15 +00:00
|
|
|
|
/// Is a selection available in our selection buffer?
|
|
|
|
|
bool selection();
|
|
|
|
|
/// Clear our selection buffer
|
|
|
|
|
void clearSelection();
|
|
|
|
|
/// Paste the current selection at \p cur
|
|
|
|
|
/// Does handle undo. Does only work in text, not mathed.
|
2007-04-26 14:56:30 +00:00
|
|
|
|
void pasteSelection(Cursor & cur, ErrorList &);
|
2007-01-13 18:29:50 +00:00
|
|
|
|
/// Replace the current selection with the clipboard contents (internal or
|
|
|
|
|
/// external: which is newer)
|
|
|
|
|
/// Does handle undo. Does only work in text, not mathed.
|
2007-04-26 14:56:30 +00:00
|
|
|
|
void pasteClipboard(Cursor & cur, ErrorList & errorList, bool asParagraphs = true);
|
2007-01-13 18:29:50 +00:00
|
|
|
|
/// Replace the current selection with cut buffer \c sel_index
|
2007-01-04 16:50:03 +00:00
|
|
|
|
/// Does handle undo. Does only work in text, not mathed.
|
2007-04-26 14:56:30 +00:00
|
|
|
|
void pasteFromStack(Cursor & cur, ErrorList & errorList, size_t sel_index);
|
2003-03-06 15:39:37 +00:00
|
|
|
|
|
2006-11-17 19:52:45 +00:00
|
|
|
|
/// Paste the paragraph list \p parlist at the position given by \p cur.
|
|
|
|
|
/// Does not handle undo. Does only work in text, not mathed.
|
2007-04-26 14:56:30 +00:00
|
|
|
|
void pasteParagraphList(Cursor & cur, ParagraphList const & parlist,
|
This is one of a series of patches that will merge the layout modules development in personal/branches/rgheck back into the tree.
Design goal: Allow the use of layout "modules", which are to LaTeX packages as layout files are to LaTeX document classes. Thus, one could have a module that defined certain character styles, environments, commands, or what have you, and include it in various documents, each of which uses a different document class, without having to modify the layout files themselves. For example, a theorems.module could be used with article.layout to provide support for theorem-type environments, without having to modify article.layout itself, and the same module could be used with book.layout, etc.
This first patch does some reworking of the infrastructrue. We need to distinguish between the TextClass that a particular document is using and the layout of that document, since modules, in particular, can modify the layout. The solution adopted here is to add a TextClass pointer to BufferParams, which will hold the layout. The layout itself is then constructed from the TextClass the document is using. At present, this is completely trivial, but that will change when modules are added.
The pointer in question is a boost::shared_ptr. This is needed because CutAndPaste saves a copy of the layout with each cut or copied selection. We cannot assume the selection vanishes when the document is closed, so there are two options: (i) keep a list of all the layouts that have ever been used by any document; (ii) used some kind of smart pointer. The latter seems preferable, as the former would waste memory. More importantly, the use of a smart pointer allows modules to be modified on disk and then reloaded while LyX is running, and it will eventually allow the same for layout files.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19756 a592a061-630c-0410-9148-cb99ea01b6c8
2007-08-23 16:41:13 +00:00
|
|
|
|
TextClass_ptr textclass, ErrorList & errorList);
|
2005-11-29 15:08:35 +00:00
|
|
|
|
|
|
|
|
|
|
2004-03-25 09:16:36 +00:00
|
|
|
|
/** Needed to switch between different classes. This works
|
2005-05-04 11:21:14 +00:00
|
|
|
|
* for a list of paragraphs beginning with the specified par.
|
|
|
|
|
* It changes layouts and character styles.
|
2004-10-05 10:11:42 +00:00
|
|
|
|
*/
|
This is one of a series of patches that will merge the layout modules development in personal/branches/rgheck back into the tree.
Design goal: Allow the use of layout "modules", which are to LaTeX packages as layout files are to LaTeX document classes. Thus, one could have a module that defined certain character styles, environments, commands, or what have you, and include it in various documents, each of which uses a different document class, without having to modify the layout files themselves. For example, a theorems.module could be used with article.layout to provide support for theorem-type environments, without having to modify article.layout itself, and the same module could be used with book.layout, etc.
This first patch does some reworking of the infrastructrue. We need to distinguish between the TextClass that a particular document is using and the layout of that document, since modules, in particular, can modify the layout. The solution adopted here is to add a TextClass pointer to BufferParams, which will hold the layout. The layout itself is then constructed from the TextClass the document is using. At present, this is completely trivial, but that will change when modules are added.
The pointer in question is a boost::shared_ptr. This is needed because CutAndPaste saves a copy of the layout with each cut or copied selection. We cannot assume the selection vanishes when the document is closed, so there are two options: (i) keep a list of all the layouts that have ever been used by any document; (ii) used some kind of smart pointer. The latter seems preferable, as the former would waste memory. More importantly, the use of a smart pointer allows modules to be modified on disk and then reloaded while LyX is running, and it will eventually allow the same for layout files.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19756 a592a061-630c-0410-9148-cb99ea01b6c8
2007-08-23 16:41:13 +00:00
|
|
|
|
void switchBetweenClasses(TextClass_ptr const & c1,
|
|
|
|
|
TextClass_ptr const & c2, InsetText & in, ErrorList &);
|
2003-03-06 15:39:37 +00:00
|
|
|
|
|
2007-01-04 16:50:03 +00:00
|
|
|
|
/// Get the current selection as a string. Does not change the selection.
|
|
|
|
|
/// Does only work if the whole selection is in mathed.
|
2007-04-26 14:56:30 +00:00
|
|
|
|
docstring grabSelection(Cursor const & cur);
|
2007-01-04 16:50:03 +00:00
|
|
|
|
/// Erase the current selection.
|
|
|
|
|
/// Does not handle undo. Does only work if the whole selection is in mathed.
|
2007-07-10 12:48:04 +00:00
|
|
|
|
/// Calls saveSelection.
|
2007-04-26 14:56:30 +00:00
|
|
|
|
void eraseSelection(Cursor & cur);
|
2007-01-04 16:50:03 +00:00
|
|
|
|
/// Erase the selection and return it as a string.
|
|
|
|
|
/// Does not handle undo. Does only work if the whole selection is in mathed.
|
2007-04-26 14:56:30 +00:00
|
|
|
|
docstring grabAndEraseSelection(Cursor & cur);
|
2004-04-18 07:32:34 +00:00
|
|
|
|
// other selection methods
|
2007-01-04 16:50:03 +00:00
|
|
|
|
/// Erase the selection if one exists.
|
|
|
|
|
/// Does not handle undo. Does only work if the whole selection is in mathed.
|
2007-04-26 14:56:30 +00:00
|
|
|
|
void selDel(Cursor & cur);
|
2007-01-04 16:50:03 +00:00
|
|
|
|
/// Clear or delete the selection if one exists, depending on lyxrc setting.
|
|
|
|
|
/// Does not handle undo. Does only work if the whole selection is in mathed.
|
2007-04-26 14:56:30 +00:00
|
|
|
|
void selClearOrDel(Cursor & cur);
|
2005-09-06 17:39:39 +00:00
|
|
|
|
|
|
|
|
|
/** Tabular has its own paste stack for multiple cells
|
2006-04-05 23:56:29 +00:00
|
|
|
|
* but it needs to know whether there is a more recent
|
2005-09-06 17:39:39 +00:00
|
|
|
|
* ordinary paste. Therefore which one is newer.
|
|
|
|
|
*/
|
|
|
|
|
//FIXME: this is a workaround for bug 1919. Replace this by
|
|
|
|
|
//an all-for-one-paste mechanism in 1.5
|
|
|
|
|
/// store whether tabular or ordinary paste stack is newer
|
|
|
|
|
void dirtyTabularStack(bool b);
|
|
|
|
|
/// is the tabular paste stack newer than the ordinary one?
|
|
|
|
|
bool tabularStackDirty();
|
2004-03-25 09:16:36 +00:00
|
|
|
|
} // namespace cap
|
|
|
|
|
} // namespce lyx
|
2000-04-10 14:29:05 +00:00
|
|
|
|
|
|
|
|
|
#endif
|