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