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