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 "TextClass.h"
19 #include "support/types.h"
20 #include "support/docstring.h"
35 /// Get all elements of the cut buffer in plain text format.
36 std::vector<docstring> const availableSelections(Buffer const & buffer);
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 getSelection(Buffer const & buffer, 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 (internal or
87 /// external: which is newer)
88 /// Does handle undo. Does only work in text, not mathed.
89 void pasteClipboard(Cursor & cur, ErrorList & errorList, bool asParagraphs = true);
90 /// Replace the current selection with cut buffer \c sel_index
91 /// Does handle undo. Does only work in text, not mathed.
92 void pasteFromStack(Cursor & cur, ErrorList & errorList, size_t sel_index);
94 /// Paste the paragraph list \p parlist at the position given by \p cur.
95 /// Does not handle undo. Does only work in text, not mathed.
96 void pasteParagraphList(Cursor & cur, ParagraphList const & parlist,
97 TextClassPtr textclass, ErrorList & errorList);
100 /** Needed to switch between different classes. This works
101 * for a list of paragraphs beginning with the specified par.
102 * It changes layouts and character styles.
104 void switchBetweenClasses(TextClassPtr const & c1,
105 TextClassPtr const & c2, InsetText & in, ErrorList &);
107 /// Get the current selection as a string. Does not change the selection.
108 /// Does only work if the whole selection is in mathed.
109 docstring grabSelection(Cursor const & cur);
110 /// Erase the current selection.
111 /// Does not handle undo. Does only work if the whole selection is in mathed.
112 /// Calls saveSelection.
113 void eraseSelection(Cursor & cur);
114 /// Erase the selection and return it as a string.
115 /// Does not handle undo. Does only work if the whole selection is in mathed.
116 docstring grabAndEraseSelection(Cursor & cur);
117 // other selection methods
118 /// Erase the selection if one exists.
119 /// Does not handle undo. Does only work if the whole selection is in mathed.
120 void selDel(Cursor & cur);
121 /// Clear or delete the selection if one exists, depending on lyxrc setting.
122 /// Does not handle undo. Does only work if the whole selection is in mathed.
123 void selClearOrDel(Cursor & cur);
125 /** Tabular has its own paste stack for multiple cells
126 * but it needs to know whether there is a more recent
127 * ordinary paste. Therefore which one is newer.
129 //FIXME: this is a workaround for bug 1919. Replace this by
130 //an all-for-one-paste mechanism in 1.5
131 /// store whether tabular or ordinary paste stack is newer
132 void dirtyTabularStack(bool b);
133 /// is the tabular paste stack newer than the ordinary one?
134 bool tabularStackDirty();