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