]> git.lyx.org Git - lyx.git/blob - src/cursor.h
4eae0a69d093881caec7fe1d9eb1271aad954e88
[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 #include "cursor_slice.h"
17
18 #include "support/types.h"
19
20 #include <iosfwd>
21 #include <vector>
22
23 class BufferView;
24 class UpdatableInset;
25 class DispatchResult;
26 class FuncRequest;
27 class LyXText;
28 class InsetTabular;
29
30
31 /**
32  * The cursor class describes the position of a cursor within a document.
33  */
34
35
36 class LCursor {
37 public:
38         /// create 'empty' cursor
39         explicit LCursor(BufferView * bv);
40         /// dispatch from innermost inset upwards
41         DispatchResult dispatch(FuncRequest const & cmd);
42         ///
43         void push(UpdatableInset * inset);
44         /// restrict cursor nesting to given size
45         void pop(int depth);
46         /// pop one level off the cursor
47         void pop();
48         /// set the cell the cursor is in
49         void cell(int);
50         /// return the cell this cursor is in
51         int cell() const;
52         ///
53         UpdatableInset * innerInset() const;
54         ///
55         UpdatableInset * innerInsetOfType(int code) const;
56         ///
57         InsetTabular * innerInsetTabular() const;
58         ///
59         LyXText * innerText() const;
60         /// returns x,y position
61         void getPos(int & x, int & y) const;
62         /// returns cursor dimension
63         void getDim(int & asc, int & desc) const;
64         /// cache the absolute coordinate from the top inset
65         void updatePos();
66         ///
67         friend std::ostream & operator<<(std::ostream &, LCursor const &);
68 public:
69         /// mainly used as stack, but wee need random access
70         std::vector<CursorSlice> data_;
71         ///
72         BufferView * bv_;
73 private:
74         ///
75         int cached_y_;
76 };
77
78 #endif // LYXCURSOR_H