]> git.lyx.org Git - lyx.git/blob - src/CutAndPaste.h
* gcc does not like missing characters in keywords
[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 "TextClass.h"
18
19 #include "support/types.h"
20 #include "support/docstring.h"
21
22 #include <vector>
23
24 namespace lyx {
25
26 class Buffer;
27 class ErrorList;
28 class InsetText;
29 class TextClass;
30 class Cursor;
31 class ParagraphList;
32
33 namespace cap {
34
35 /// Get all elements of the cut buffer in plain text format.
36 std::vector<docstring> const availableSelections(Buffer const & buffer);
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 getSelection(Buffer const & buffer, size_t sel_index);
41
42 /**
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.
46  * Does handle undo.
47  */
48 void replaceSelectionWithString(Cursor & cur, docstring const & str,
49                                 bool backwards);
50 /// If a selection exists, delete it without pushing it to the cut buffer.
51 /// Does handle undo.
52 void replaceSelection(Cursor & cur);
53
54 /**
55  * Cut the current selection and possibly push it to the cut buffer and
56  * system clipboard.
57  * Does handle undo. Calls saveSelection.
58  * \param doclear If this is true: Delete leading spaces in paragraphs before
59  *                they get merged.
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
62  *                selection.
63  */
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);
67 /**
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
70  *        clipboard
71  */
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?
78 bool selection();
79 /// Clear our selection buffer
80 void clearSelection();
81 /// Clear our cut stack.
82 void clearCutStack();
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 (internal or
87 /// external: which is newer)
88 /// Does handle undo. Does only work in text, not mathed.
89 void pasteClipboard(Cursor & cur, ErrorList & errorList, bool asParagraphs = true);
90 /// Replace the current selection with cut buffer \c sel_index
91 /// Does handle undo. Does only work in text, not mathed.
92 void pasteFromStack(Cursor & cur, ErrorList & errorList, size_t sel_index);
93
94 /// Paste the paragraph list \p parlist at the position given by \p cur.
95 /// Does not handle undo. Does only work in text, not mathed.
96 void pasteParagraphList(Cursor & cur, ParagraphList const & parlist,
97                         TextClassPtr textclass, ErrorList & errorList);
98
99
100 /** Needed to switch between different classes. This works
101  *  for a list of paragraphs beginning with the specified par.
102  *  It changes layouts and character styles.
103  */
104 void switchBetweenClasses(TextClassPtr const & c1, 
105         TextClassPtr const & c2, InsetText & in, ErrorList &);
106
107 /// Get the current selection as a string. Does not change the selection.
108 /// Does only work if the whole selection is in mathed.
109 docstring grabSelection(Cursor const & cur);
110 /// Erase the current selection.
111 /// Does not handle undo. Does only work if the whole selection is in mathed.
112 /// Calls saveSelection.
113 void eraseSelection(Cursor & cur);
114 /// Erase the selection and return it as a string.
115 /// Does not handle undo. Does only work if the whole selection is in mathed.
116 docstring grabAndEraseSelection(Cursor & cur);
117 // other selection methods
118 /// Erase the selection if one exists.
119 /// Does not handle undo. Does only work if the whole selection is in mathed.
120 void selDel(Cursor & cur);
121 /// Clear or delete the selection if one exists, depending on lyxrc setting.
122 /// Does not handle undo. Does only work if the whole selection is in mathed.
123 void selClearOrDel(Cursor & cur);
124
125 /** Tabular has its own paste stack for multiple cells
126  *  but it needs to know whether there is a more recent
127  *  ordinary paste. Therefore which one is newer.
128  */
129 //FIXME: this is a workaround for bug 1919. Replace this by
130 //an all-for-one-paste mechanism in 1.5
131 /// store whether tabular or ordinary paste stack is newer
132 void dirtyTabularStack(bool b);
133 /// is the tabular paste stack newer than the ordinary one?
134 bool tabularStackDirty();
135 } // namespace cap
136 } // namespce lyx
137
138 #endif