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
|
|
|
|
|
|
2007-10-31 22:40:34 +00:00
|
|
|
|
#include "support/docstring.h"
|
|
|
|
|
|
2008-02-03 10:43:03 +00:00
|
|
|
|
#include "frontends/Clipboard.h"
|
|
|
|
|
|
2003-06-17 15:33:49 +00:00
|
|
|
|
#include <vector>
|
|
|
|
|
|
2008-02-03 10:43:03 +00:00
|
|
|
|
using lyx::frontend::Clipboard;
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
namespace lyx {
|
|
|
|
|
|
2008-02-28 01:42:02 +00:00
|
|
|
|
class DocumentClass;
|
2003-05-20 16:51:31 +00:00
|
|
|
|
class ErrorList;
|
2006-05-21 17:33:03 +00:00
|
|
|
|
class InsetText;
|
2008-02-24 14:59:23 +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.
|
2008-02-27 20:43:16 +00:00
|
|
|
|
std::vector<docstring> availableSelections();
|
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.
|
2008-02-27 20:43:16 +00:00
|
|
|
|
docstring selection(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();
|
2007-09-15 17:24:08 +00:00
|
|
|
|
/// Clear our cut stack.
|
|
|
|
|
void clearCutStack();
|
2007-02-02 03:10:15 +00:00
|
|
|
|
/// 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 &);
|
2008-02-03 10:43:03 +00:00
|
|
|
|
/// Replace the current selection with the clipboard contents as text
|
|
|
|
|
/// (internal or external: which is newer).
|
|
|
|
|
/// Does handle undo. Does only work in text, not mathed.
|
|
|
|
|
void pasteClipboardText(Cursor & cur, ErrorList & errorList,
|
|
|
|
|
bool asParagraphs = true);
|
|
|
|
|
/// Replace the current selection with the clipboard contents as graphic.
|
2007-01-13 18:29:50 +00:00
|
|
|
|
/// Does handle undo. Does only work in text, not mathed.
|
2008-02-03 10:43:03 +00:00
|
|
|
|
void pasteClipboardGraphics(Cursor & cur, ErrorList & errorList,
|
|
|
|
|
Clipboard::GraphicsType preferedType = Clipboard::AnyGraphicsType);
|
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,
|
2008-02-28 01:42:02 +00:00
|
|
|
|
DocumentClass const * const 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
|
|
|
|
*/
|
2008-02-28 01:42:02 +00:00
|
|
|
|
void switchBetweenClasses(DocumentClass const * const c1,
|
|
|
|
|
DocumentClass const * 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);
|
2008-03-12 00:18:39 +00:00
|
|
|
|
/// Reduce the selected text in mathed to only one cell. If it spans multiple
|
|
|
|
|
/// cells, the cursor is moved the end of the current cell and the anchor to the
|
|
|
|
|
/// start. If the selection is inside only one cell, nothing is done. Return
|
|
|
|
|
/// true if the selection now does not span multiple cells anymore.
|
|
|
|
|
bool reduceSelectionToOneCell(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
|
2008-03-12 00:19:18 +00:00
|
|
|
|
//an all-for-one-paste mechanism in 1.7
|
2005-09-06 17:39:39 +00:00
|
|
|
|
/// 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
|