]> git.lyx.org Git - lyx.git/blob - src/cursor.h
9929c87a978afde1775e9a9d7ef3c14ce41949f9
[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 UpdatableInset;
23 class DispatchResult;
24 class FuncRequest;
25 class LyXText;
26 class InsetTabular;
27
28
29 /**
30  * The cursor class describes the position of a cursor within a document.
31  */
32
33 class CursorItem {
34 public:
35         ///
36         CursorItem() : inset_(0), par_(0), pos_(0) {}
37         ///
38         explicit CursorItem(UpdatableInset * inset)
39                 : inset_(inset), par_(0), pos_(0)
40         {}
41         ///
42         LyXText * text() const;
43         ///
44         friend std::ostream & operator<<(std::ostream &, CursorItem const &);
45 public:
46         ///
47         UpdatableInset * inset_;
48         ///
49         int par_;
50         ///
51         int pos_;
52 };
53
54
55 class LCursor {
56 public:
57         /// create 'empty' cursor
58         explicit LCursor(BufferView * bv);
59         /// dispatch from innermost inset upwards
60         DispatchResult dispatch(FuncRequest const & cmd);
61         ///
62         void push(UpdatableInset * inset);
63         /// restrict cursor nesting to given size
64         void pop(int depth);
65         /// pop one level off the cursor
66         void pop();
67         ///
68         UpdatableInset * innerInset() const;
69         ///
70         UpdatableInset * innerInsetOfType(int code) const;
71         ///
72         InsetTabular * innerInsetTabular() const;
73         ///
74         LyXText * innerText() const;
75         /// returns x,y position
76         void getPos(int & x, int & y) const;
77         ///
78         friend std::ostream & operator<<(std::ostream &, LCursor const &);
79 public:
80         /// mainly used as stack, but wee need random access
81         std::vector<CursorItem> data_;
82         ///
83         BufferView * bv_;
84 };
85
86 #endif // LYXCURSOR_H