]> git.lyx.org Git - features.git/blob - src/CutAndPaste.h
Add some documentation. Yes I know that some functions are misnamed :-(
[features.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 "ParagraphList_fwd.h"
18
19 #include "support/docstring.h"
20
21 #include <vector>
22
23 namespace lyx {
24
25 class Buffer;
26 class ErrorList;
27 class InsetText;
28 class LyXTextClass;
29 class LCursor;
30
31 namespace cap {
32
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);
39
40 /**
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.
44  * Does handle undo.
45  */
46 void replaceSelectionWithString(LCursor & cur, docstring const & str,
47                                 bool backwards);
48 /// If a selection exists, cut it and push it to the cut buffer.
49 /// Does handle undo.
50 void replaceSelection(LCursor & cur);
51
52 /**
53  * Cut the current selection and possibly push it to the cut buffer and
54  * system clipboard.
55  * Does handle undo.
56  * \param doclear If this is true: Delete leading spaces in paragraphs before
57  *                they get merged.
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.
61  */
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);
65 /// Paste the sel_index-th element of the cut buffer.
66 /// Does handle undo. Does only work in text, not mathed.
67 void pasteSelection(LCursor & cur, ErrorList &, size_t sel_index = 0);
68
69 /// Paste the paragraph list \p parlist at the position given by \p cur.
70 /// Does not handle undo. Does only work in text, not mathed.
71 void pasteParagraphList(LCursor & cur, ParagraphList const & parlist,
72                         textclass_type textclass, ErrorList & errorList);
73
74
75 /** Needed to switch between different classes. This works
76  *  for a list of paragraphs beginning with the specified par.
77  *  It changes layouts and character styles.
78  */
79 void switchBetweenClasses(textclass_type c1, textclass_type c2,
80                           InsetText & in, ErrorList &);
81
82 /// Get the current selection as a string. Does not change the selection.
83 /// Does only work if the whole selection is in mathed.
84 docstring grabSelection(LCursor const & cur);
85 /// Erase the current selection.
86 /// Does not handle undo. Does only work if the whole selection is in mathed.
87 void eraseSelection(LCursor & cur);
88 /// Erase the selection and return it as a string.
89 /// Does not handle undo. Does only work if the whole selection is in mathed.
90 docstring grabAndEraseSelection(LCursor & cur);
91 // other selection methods
92 /// Erase the selection if one exists.
93 /// Does not handle undo. Does only work if the whole selection is in mathed.
94 void selDel(LCursor & cur);
95 /// Clear or delete the selection if one exists, depending on lyxrc setting.
96 /// Does not handle undo. Does only work if the whole selection is in mathed.
97 void selClearOrDel(LCursor & cur);
98
99 /** Tabular has its own paste stack for multiple cells
100  *  but it needs to know whether there is a more recent
101  *  ordinary paste. Therefore which one is newer.
102  */
103 //FIXME: this is a workaround for bug 1919. Replace this by
104 //an all-for-one-paste mechanism in 1.5
105 /// store whether tabular or ordinary paste stack is newer
106 void dirtyTabularStack(bool b);
107 /// is the tabular paste stack newer than the ordinary one?
108 bool tabularStackDirty();
109 } // namespace cap
110 } // namespce lyx
111
112 #endif