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-03-23 20:11:06 +00:00
|
|
|
|
#include "ParagraphList_fwd.h"
|
|
|
|
|
|
2006-10-11 19:40:50 +00:00
|
|
|
|
#include "support/docstring.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;
|
2003-09-06 12:36:58 +00:00
|
|
|
|
class LyXTextClass;
|
2004-03-25 09:16:36 +00:00
|
|
|
|
class LCursor;
|
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
|
|
|
|
*/
|
2006-12-08 19:46:16 +00:00
|
|
|
|
void replaceSelectionWithString(LCursor & 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.
|
2004-03-25 09:16:36 +00:00
|
|
|
|
void replaceSelection(LCursor & 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.
|
|
|
|
|
* Does handle undo.
|
|
|
|
|
* \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
|
|
|
|
|
* selection.
|
2007-01-04 16:50:03 +00:00
|
|
|
|
*/
|
2004-03-25 09:16:36 +00:00
|
|
|
|
void cutSelection(LCursor & 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.
|
2004-03-25 09:16:36 +00:00
|
|
|
|
void copySelection(LCursor & 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
|
|
|
|
|
*/
|
|
|
|
|
void copySelection(LCursor & 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
|
|
|
|
|
void saveSelection(LCursor & cur);
|
|
|
|
|
/// 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.
|
|
|
|
|
void pasteSelection(LCursor & 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.
|
|
|
|
|
void pasteClipboard(LCursor & cur, ErrorList & errorList, bool asParagraphs = true);
|
|
|
|
|
/// 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-02-02 03:10:15 +00:00
|
|
|
|
void pasteFromStack(LCursor & 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.
|
2006-04-05 23:56:29 +00:00
|
|
|
|
void pasteParagraphList(LCursor & cur, ParagraphList const & parlist,
|
2006-08-13 16:16:43 +00:00
|
|
|
|
textclass_type 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
|
|
|
|
*/
|
2006-10-21 00:16:43 +00:00
|
|
|
|
void switchBetweenClasses(textclass_type c1, textclass_type c2,
|
2006-05-21 17:33:03 +00:00
|
|
|
|
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.
|
2006-10-22 10:15:23 +00:00
|
|
|
|
docstring grabSelection(LCursor 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.
|
2004-04-18 07:32:34 +00:00
|
|
|
|
void eraseSelection(LCursor & 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.
|
2006-10-22 10:15:23 +00:00
|
|
|
|
docstring grabAndEraseSelection(LCursor & 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.
|
2004-04-18 07:32:34 +00:00
|
|
|
|
void selDel(LCursor & 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.
|
2004-04-18 07:32:34 +00:00
|
|
|
|
void selClearOrDel(LCursor & 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
|