]> git.lyx.org Git - lyx.git/blob - src/textcursor.h
cosmetic fix
[lyx.git] / src / textcursor.h
1 // -*- C++ -*-
2 /**
3  * \file cursor.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  *
11  * Full author contact details are available in file CREDITS
12  */
13
14 #include "lyxcursor.h"
15
16 #ifndef TEXTCURSOR_H
17 #define TEXTCURSOR_H
18
19 // Do not even think of forward declaring LyXText/BufferView etc here!
20 // If you need Paragraph proper, go to text_func.h
21
22 /** The cursor.
23         Later this variable has to be removed. There should be now internal
24         cursor in a text (and thus not in a buffer). By keeping this it is
25         (I think) impossible to have several views with the same buffer, but
26         the cursor placed at different places.
27         [later]
28         Since the LyXText now has been moved from Buffer to BufferView
29         it should not be absolutely needed to move the cursor...
30         [even later]
31         It should neverthe less to keep classes and intedependencies small 
32         */
33
34 // The structure that keeps track of the selections set.
35 struct Selection {
36         Selection()
37                 : set_(false), mark_(false)
38                 {}
39         bool set() const {
40                 return set_;
41         }
42         void set(bool s) {
43                 set_ = s;
44         }
45         bool mark() const {
46                 return mark_;
47         }
48         void mark(bool m) {
49                 mark_ = m;
50         }
51         LyXCursor cursor; // temporary cursor to hold a cursor position
52                                 // until setSelection is called!
53         LyXCursor start;  // start of a REAL selection
54         LyXCursor end;    // end of a REAL selection
55 private:
56         bool set_; // former selection
57         bool mark_; // former mark_set
58
59 };
60
61 struct TextCursor {
62         /// returns true if selection was set previously
63         bool setSelection();
64         ///
65         void clearSelection();
66         ///
67         string const selectionAsString(Buffer const * buffer, bool label) const;
68
69         // actual cursor position
70         LyXCursor cursor;
71
72         Selection selection;
73         // this is used to handle XSelection events in the right manner
74         Selection xsel_cache;
75
76         /// needed for the toggling (cursor position on last selection made)
77         LyXCursor last_sel_cursor;
78         /// needed for toggling the selection in screen.C
79         LyXCursor toggle_cursor;
80         /// needed for toggling the selection in screen.C
81         LyXCursor toggle_end_cursor;
82 };
83
84 #endif