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