4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
8 * \author Lars Gullik Bjønnes
9 * \author Alfredo Braunstein
11 * Full author contact details are available in file CREDITS.
17 #include "support/docstring.h"
19 #include "frontends/Clipboard.h"
23 using lyx::frontend::Clipboard;
35 /// Get all elements of the cut buffer in plain text format.
36 std::vector<docstring> availableSelections();
37 /// Get the number of available elements in the cut buffer.
38 size_type numberOfSelections();
39 /// Get the sel_index-th element of the cut buffer in plain text format.
40 docstring selection(size_t sel_index);
43 * Replace using the font of the first selected character and select
44 * the new string. When \c backwards == false, set anchor before
45 * cursor; otherwise set cursor before anchor.
48 void replaceSelectionWithString(Cursor & cur, docstring const & str,
50 /// If a selection exists, delete it without pushing it to the cut buffer.
52 void replaceSelection(Cursor & cur);
55 * Cut the current selection and possibly push it to the cut buffer and
57 * Does handle undo. Calls saveSelection.
58 * \param doclear If this is true: Delete leading spaces in paragraphs before
60 * \param realcut If this is true: Push the selection to the cut buffer and
61 * system clipboard. Set this to false to only delete the
64 void cutSelection(Cursor & cur, bool doclear = true, bool realcut = true);
65 /// Push the current selection to the cut buffer and the system clipboard.
66 void copySelection(Cursor & cur);
68 * Push the current selection to the cut buffer and the system clipboard.
69 * \param plaintext plain text version of the selection for the system
72 void copySelection(Cursor & cur, docstring const & plaintext);
73 /// Push the selection buffer to the cut buffer.
74 void copySelectionToStack();
75 /// Store the current selection in the internal selection buffer
76 void saveSelection(Cursor & cur);
77 /// Is a selection available in our selection buffer?
79 /// Clear our selection buffer
80 void clearSelection();
81 /// Clear our cut stack.
83 /// Paste the current selection at \p cur
84 /// Does handle undo. Does only work in text, not mathed.
85 void pasteSelection(Cursor & cur, ErrorList &);
86 /// Replace the current selection with the clipboard contents as text
87 /// (internal or external: which is newer).
88 /// Does handle undo. Does only work in text, not mathed.
89 void pasteClipboardText(Cursor & cur, ErrorList & errorList,
90 bool asParagraphs = true);
91 /// Replace the current selection with the clipboard contents as graphic.
92 /// Does handle undo. Does only work in text, not mathed.
93 void pasteClipboardGraphics(Cursor & cur, ErrorList & errorList,
94 Clipboard::GraphicsType preferedType = Clipboard::AnyGraphicsType);
95 /// Replace the current selection with cut buffer \c sel_index
96 /// Does handle undo. Does only work in text, not mathed.
97 void pasteFromStack(Cursor & cur, ErrorList & errorList, size_t sel_index);
99 /// Paste the paragraph list \p parlist at the position given by \p cur.
100 /// Does not handle undo. Does only work in text, not mathed.
101 void pasteParagraphList(Cursor & cur, ParagraphList const & parlist,
102 DocumentClass const * const textclass, ErrorList & errorList);
105 /** Needed to switch between different classes. This works
106 * for a list of paragraphs beginning with the specified par.
107 * It changes layouts and character styles.
109 void switchBetweenClasses(DocumentClass const * const c1,
110 DocumentClass const * const c2, InsetText & in, ErrorList &);
112 /// Get the current selection as a string. Does not change the selection.
113 /// Does only work if the whole selection is in mathed.
114 docstring grabSelection(Cursor const & cur);
115 /// Erase the current selection.
116 /// Does not handle undo. Does only work if the whole selection is in mathed.
117 /// Calls saveSelection.
118 void eraseSelection(Cursor & cur);
119 /// Erase the selection and return it as a string.
120 /// Does not handle undo. Does only work if the whole selection is in mathed.
121 docstring grabAndEraseSelection(Cursor & cur);
122 // other selection methods
123 /// Erase the selection if one exists.
124 /// Does not handle undo. Does only work if the whole selection is in mathed.
125 void selDel(Cursor & cur);
126 /// Clear or delete the selection if one exists, depending on lyxrc setting.
127 /// Does not handle undo. Does only work if the whole selection is in mathed.
128 void selClearOrDel(Cursor & cur);
130 /** Tabular has its own paste stack for multiple cells
131 * but it needs to know whether there is a more recent
132 * ordinary paste. Therefore which one is newer.
134 //FIXME: this is a workaround for bug 1919. Replace this by
135 //an all-for-one-paste mechanism in 1.5
136 /// store whether tabular or ordinary paste stack is newer
137 void dirtyTabularStack(bool b);
138 /// is the tabular paste stack newer than the ordinary one?
139 bool tabularStackDirty();