]> git.lyx.org Git - lyx.git/blob - src/textcursor.h
Small clean-up.
[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 #include "support/std_string.h"
20
21 class Buffer;
22
23 // Do not even think of forward declaring LyXText/BufferView etc here!
24 // If you need Paragraph proper, go to text_func.h
25
26 /** The cursor.
27         Later this variable has to be removed. There should be no internal
28         cursor in a text (and thus not in a buffer). By keeping this it is
29         (I think) impossible to have several views with the same buffer, but
30         the cursor placed at different places.
31         [later]
32         Since the LyXText now has been moved from Buffer to BufferView
33         it should not be absolutely needed to move the cursor...
34         [even later]
35         Nevertheless, it should still be moved, in order to keep classes
36         and interdependencies small.
37         */
38
39 // The structure that keeps track of the selections set.
40 struct Selection {
41         Selection()
42                 : set_(false), mark_(false)
43                 {}
44         bool set() const {
45                 return set_;
46         }
47         void set(bool s) {
48                 set_ = s;
49         }
50         bool mark() const {
51                 return mark_;
52         }
53         void mark(bool m) {
54                 mark_ = m;
55         }
56         LyXCursor cursor; // temporary cursor to hold a cursor position
57                                 // until setSelection is called!
58         LyXCursor start;  // start of a REAL selection
59         LyXCursor end;    // end of a REAL selection
60 private:
61         bool set_; // former selection
62         bool mark_; // former mark_set
63
64 };
65
66 struct TextCursor {
67         ///
68         void setSelection();
69         ///
70         void clearSelection();
71         ///
72         string const selectionAsString(Buffer const & buffer, bool label) const;
73
74         // actual cursor position
75         LyXCursor cursor;
76
77         Selection selection;
78         // this is used to handle XSelection events in the right manner
79         Selection xsel_cache;
80 };
81
82 #endif