]> git.lyx.org Git - lyx.git/blob - src/textcursor.h
support for \dfrac
[lyx.git] / src / textcursor.h
1 // -*- C++ -*-
2 /**
3  * \file textcursor.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author unknown
8  * \author Lars Gullik Bjønnes
9  * \author John Levon
10  * \author André Pönitz
11  *
12  * Full author contact details are available in file CREDITS.
13  */
14
15 #ifndef TEXTCURSOR_H
16 #define TEXTCURSOR_H
17
18 #include "lyxcursor.h"
19
20 #include <string>
21
22 class Buffer;
23
24 // Do not even think of forward declaring LyXText/BufferView etc here!
25 // If you need Paragraph proper, go to text_func.h
26
27 /** The cursor.
28         Later this variable has to be removed. There should be no internal
29         cursor in a text (and thus not in a buffer). By keeping this it is
30         (I think) impossible to have several views with the same buffer, but
31         the cursor placed at different places.
32         [later]
33         Since the LyXText now has been moved from Buffer to BufferView
34         it should not be absolutely needed to move the cursor...
35         [even later]
36         Nevertheless, it should still be moved, in order to keep classes
37         and interdependencies small.
38         */
39
40 // The structure that keeps track of the selections set.
41 struct Selection {
42         Selection()
43                 : set_(false), mark_(false)
44                 {}
45         bool set() const {
46                 return set_;
47         }
48         void set(bool s) {
49                 set_ = s;
50         }
51         bool mark() const {
52                 return mark_;
53         }
54         void mark(bool m) {
55                 mark_ = m;
56         }
57         LyXCursor cursor; // temporary cursor to hold a cursor position
58                                 // until setSelection is called!
59         LyXCursor start;  // start of a REAL selection
60         LyXCursor end;    // end of a REAL selection
61 private:
62         bool set_; // former selection
63         bool mark_; // former mark_set
64
65 };
66
67 struct TextCursor {
68         ///
69         void setSelection();
70         ///
71         void clearSelection();
72         ///
73         std::string const selectionAsString(Buffer const & buffer, bool label) const;
74
75         // actual cursor position
76         LyXCursor cursor;
77
78         Selection selection;
79         // this is used to handle XSelection events in the right manner
80         Selection xsel_cache;
81 };
82
83 #endif