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 "TextClassPtr.h"
19 #include "support/docstring.h"
21 #include "frontends/Clipboard.h"
25 using lyx::frontend::Clipboard;
36 /// Get all elements of the cut buffer in plain text format.
37 std::vector<docstring> availableSelections();
38 /// Get the number of available elements in the cut buffer.
39 size_type numberOfSelections();
40 /// Get the sel_index-th element of the cut buffer in plain text format.
41 docstring selection(size_t sel_index);
44 * Replace using the font of the first selected character and select
45 * the new string. When \c backwards == false, set anchor before
46 * cursor; otherwise set cursor before anchor.
49 void replaceSelectionWithString(Cursor & cur, docstring const & str,
51 /// If a selection exists, delete it without pushing it to the cut buffer.
53 void replaceSelection(Cursor & cur);
56 * Cut the current selection and possibly push it to the cut buffer and
58 * Does handle undo. Calls saveSelection.
59 * \param doclear If this is true: Delete leading spaces in paragraphs before
61 * \param realcut If this is true: Push the selection to the cut buffer and
62 * system clipboard. Set this to false to only delete the
65 void cutSelection(Cursor & cur, bool doclear = true, bool realcut = true);
66 /// Push the current selection to the cut buffer and the system clipboard.
67 void copySelection(Cursor & cur);
69 * Push the current selection to the cut buffer and the system clipboard.
70 * \param plaintext plain text version of the selection for the system
73 void copySelection(Cursor & cur, docstring const & plaintext);
74 /// Push the selection buffer to the cut buffer.
75 void copySelectionToStack();
76 /// Store the current selection in the internal selection buffer
77 void saveSelection(Cursor & cur);
78 /// Is a selection available in our selection buffer?
80 /// Clear our selection buffer
81 void clearSelection();
82 /// Clear our cut stack.
84 /// Paste the current selection at \p cur
85 /// Does handle undo. Does only work in text, not mathed.
86 void pasteSelection(Cursor & cur, ErrorList &);
87 /// Replace the current selection with the clipboard contents as text
88 /// (internal or external: which is newer).
89 /// Does handle undo. Does only work in text, not mathed.
90 void pasteClipboardText(Cursor & cur, ErrorList & errorList,
91 bool asParagraphs = true);
92 /// Replace the current selection with the clipboard contents as graphic.
93 /// Does handle undo. Does only work in text, not mathed.
94 void pasteClipboardGraphics(Cursor & cur, ErrorList & errorList,
95 Clipboard::GraphicsType preferedType = Clipboard::AnyGraphicsType);
96 /// Replace the current selection with cut buffer \c sel_index
97 /// Does handle undo. Does only work in text, not mathed.
98 void pasteFromStack(Cursor & cur, ErrorList & errorList, size_t sel_index);
100 /// Paste the paragraph list \p parlist at the position given by \p cur.
101 /// Does not handle undo. Does only work in text, not mathed.
102 void pasteParagraphList(Cursor & cur, ParagraphList const & parlist,
103 TextClassPtr textclass, ErrorList & errorList);
106 /** Needed to switch between different classes. This works
107 * for a list of paragraphs beginning with the specified par.
108 * It changes layouts and character styles.
110 void switchBetweenClasses(TextClassPtr const & c1,
111 TextClassPtr const & c2, InsetText & in, ErrorList &);
113 /// Get the current selection as a string. Does not change the selection.
114 /// Does only work if the whole selection is in mathed.
115 docstring grabSelection(Cursor const & cur);
116 /// Erase the current selection.
117 /// Does not handle undo. Does only work if the whole selection is in mathed.
118 /// Calls saveSelection.
119 void eraseSelection(Cursor & cur);
120 /// Erase the selection and return it as a string.
121 /// Does not handle undo. Does only work if the whole selection is in mathed.
122 docstring grabAndEraseSelection(Cursor & cur);
123 // other selection methods
124 /// Erase the selection if one exists.
125 /// Does not handle undo. Does only work if the whole selection is in mathed.
126 void selDel(Cursor & cur);
127 /// Clear or delete the selection if one exists, depending on lyxrc setting.
128 /// Does not handle undo. Does only work if the whole selection is in mathed.
129 void selClearOrDel(Cursor & cur);
131 /** Tabular has its own paste stack for multiple cells
132 * but it needs to know whether there is a more recent
133 * ordinary paste. Therefore which one is newer.
135 //FIXME: this is a workaround for bug 1919. Replace this by
136 //an all-for-one-paste mechanism in 1.5
137 /// store whether tabular or ordinary paste stack is newer
138 void dirtyTabularStack(bool b);
139 /// is the tabular paste stack newer than the ordinary one?
140 bool tabularStackDirty();