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"
19 #include "frontends/Clipboard.h"
23 using lyx::frontend::Clipboard
;
35 /// Get all elements of the cut buffer in plain text format.
36 std::vector
<docstring
> availableSelections();
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
selection(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 as text
87 /// (internal or external: which is newer).
88 /// Does handle undo. Does only work in text, not mathed.
89 void pasteClipboardText(Cursor
& cur
, ErrorList
& errorList
,
90 bool asParagraphs
= true);
91 /// Replace the current selection with the clipboard contents as graphic.
92 /// Does handle undo. Does only work in text, not mathed.
93 void pasteClipboardGraphics(Cursor
& cur
, ErrorList
& errorList
,
94 Clipboard::GraphicsType preferedType
= Clipboard::AnyGraphicsType
);
95 /// Replace the current selection with cut buffer \c sel_index
96 /// Does handle undo. Does only work in text, not mathed.
97 void pasteFromStack(Cursor
& cur
, ErrorList
& errorList
, size_t sel_index
);
99 /// Paste the paragraph list \p parlist at the position given by \p cur.
100 /// Does not handle undo. Does only work in text, not mathed.
101 void pasteParagraphList(Cursor
& cur
, ParagraphList
const & parlist
,
102 DocumentClass
const * const textclass
, ErrorList
& errorList
);
105 /** Needed to switch between different classes. This works
106 * for a list of paragraphs beginning with the specified par.
107 * It changes layouts and character styles.
109 void switchBetweenClasses(DocumentClass
const * const c1
,
110 DocumentClass
const * const c2
, InsetText
& in
, ErrorList
&);
112 /// Get the current selection as a string. Does not change the selection.
113 /// Does only work if the whole selection is in mathed.
114 docstring
grabSelection(Cursor
const & cur
);
115 /// Erase the current selection.
116 /// Does not handle undo. Does only work if the whole selection is in mathed.
117 /// Calls saveSelection.
118 void eraseSelection(Cursor
& cur
);
119 /// Reduce the selected text in mathed to only one cell. If it spans multiple
120 /// cells, the cursor is moved the end of the current cell and the anchor to the
121 /// start. If the selection is inside only one cell, nothing is done. Return
122 /// true if the selection now does not span multiple cells anymore.
123 bool reduceSelectionToOneCell(Cursor
& cur
);
124 /// Returns true if multiple cells are selected in mathed.
125 bool multipleCellsSelected(Cursor
const & cur
);
126 /// Erase the selection and return it as a string.
127 /// Does not handle undo. Does only work if the whole selection is in mathed.
128 docstring
grabAndEraseSelection(Cursor
& cur
);
129 // other selection methods
130 /// Erase the selection if one exists.
131 /// Does not handle undo. Does only work if the whole selection is in mathed.
132 void selDel(Cursor
& cur
);
133 /// Clear or delete the selection if one exists, depending on lyxrc setting.
134 /// Does not handle undo. Does only work if the whole selection is in mathed.
135 void selClearOrDel(Cursor
& cur
);
136 /// Calculate rectangular region of cell between \c i1 and \c i2.
137 void region(CursorSlice
const & i1
, CursorSlice
const & i2
,
138 Inset::row_type
& r1
, Inset::row_type
& r2
,
139 Inset::col_type
& c1
, Inset::col_type
& c2
);
140 /** Tabular has its own paste stack for multiple cells
141 * but it needs to know whether there is a more recent
142 * ordinary paste. Therefore which one is newer.
144 //FIXME: this is a workaround for bug 1919. Replace this by
145 //an all-for-one-paste mechanism in 1.7
146 /// store whether tabular or ordinary paste stack is newer
147 void dirtyTabularStack(bool b
);
148 /// is the tabular paste stack newer than the ordinary one?
149 bool tabularStackDirty();