]> git.lyx.org Git - lyx.git/blob - src/CutAndPaste.h
rename MathArray into MathData
[lyx.git] / src / CutAndPaste.h
1 // -*- C++ -*-
2 /**
3  * \file CutAndPaste.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Jürgen Vigna
8  * \author Lars Gullik Bjønnes
9  * \author Alfredo Braunstein
10  *
11  * Full author contact details are available in file CREDITS.
12  */
13
14 #ifndef CUTANDPASTE_H
15 #define CUTANDPASTE_H
16
17 #include "support/docstring.h"
18
19 #include <vector>
20
21 namespace lyx {
22
23 class Buffer;
24 class ErrorList;
25 class InsetText;
26 class LyXTextClass;
27 class Cursor;
28 class ParagraphList;
29
30 namespace cap {
31
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);
38
39 /**
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.
43  * Does handle undo.
44  */
45 void replaceSelectionWithString(Cursor & cur, docstring const & str,
46                                 bool backwards);
47 /// If a selection exists, delete it without pushing it to the cut buffer.
48 /// Does handle undo.
49 void replaceSelection(Cursor & cur);
50
51 /**
52  * Cut the current selection and possibly push it to the cut buffer and
53  * system clipboard.
54  * Does handle undo.
55  * \param doclear If this is true: Delete leading spaces in paragraphs before
56  *                they get merged.
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
59  *                selection. 
60  */
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);
64 /**
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
67  *        clipboard
68  */
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?
75 bool selection();
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);
88
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);
93
94
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.
98  */
99 void switchBetweenClasses(textclass_type c1, textclass_type c2,
100                           InsetText & in, ErrorList &);
101
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);
118
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.
122  */
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();
129 } // namespace cap
130 } // namespce lyx
131
132 #endif