]> git.lyx.org Git - lyx.git/blob - src/cursor.h
d34954d89491b8ee29f8fe15c865dd546128cedb
[lyx.git] / src / cursor.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 André Pönitz
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef CURSOR_H
13 #define CURSOR_H
14
15 #include "textcursor.h"
16
17 #include "support/types.h"
18
19 #include <vector>
20
21 class BufferView;
22 class InsetOld;
23 class DispatchResult;
24 class FuncRequest;
25 class LyXText;
26
27
28 /**
29  * The cursor class describes the position of a cursor within a document.
30  */
31
32 class CursorItem {
33 public:
34         ///
35         CursorItem() : inset_(0), text_(0), idx_(0), par_(0), pos_(0) {}
36         ///
37         CursorItem(InsetOld * inset, LyXText * text)
38                 : inset_(inset), text_(text), idx_(0), par_(0), pos_(0)
39         {}
40         ///
41         friend std::ostream & operator<<(std::ostream &, CursorItem const &);
42 public:
43         ///
44         InsetOld * inset_;
45         ///
46         LyXText * text_;
47         ///
48         int idx_;
49         ///
50         int par_;
51         ///
52         int pos_;
53 };
54
55
56 class LCursor {
57 public:
58         ///
59         LCursor(BufferView * bv);
60         ///
61         DispatchResult dispatch(FuncRequest const & cmd);
62         ///
63         void push(InsetOld *, LyXText *);
64         ///
65         void pop();
66         ///
67         InsetOld * innerInset() const;
68         ///
69         LyXText * innerText() const;
70         ///
71         friend std::ostream & operator<<(std::ostream &, LCursor const &);
72 public:
73         /// mainly used as stack, but wee need random access
74         std::vector<CursorItem> data_;
75         ///
76         BufferView * bv_;
77 };
78
79 #endif // LYXCURSOR_H