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