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