]> git.lyx.org Git - lyx.git/blob - src/cursor.h
some integer type changes for inset unification
[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 <iosfwd>
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
34 class LCursor {
35 public:
36         /// type for cell number in inset
37         typedef CursorSlice::idx_type idx_type;
38         /// type for paragraph numbers positions within a cell
39         typedef CursorSlice::par_type par_type;
40         /// type for cursor positions within a cell
41         typedef CursorSlice::pos_type pos_type;
42
43         /// create 'empty' cursor
44         explicit LCursor(BufferView * bv);
45         /// dispatch from innermost inset upwards
46         DispatchResult dispatch(FuncRequest const & cmd);
47         ///
48         void push(UpdatableInset * inset);
49         /// restrict cursor nesting to given size
50         void pop(int depth);
51         /// pop one level off the cursor
52         void pop();
53         /// access to cursor 'tip'
54         CursorSlice & top() { return data_.back(); }
55         /// access to cursor 'tip'
56         CursorSlice const & top() const { return data_.back(); }
57
58         /// set the cell the cursor is in
59         void cell(int);
60         /// return the cell this cursor is in
61         int cell() const;
62         ///
63         UpdatableInset * innerInset() const;
64         ///
65         UpdatableInset * innerInsetOfType(int code) const;
66         ///
67         InsetTabular * innerInsetTabular() const;
68         ///
69         LyXText * innerText() const;
70         /// returns x,y position
71         void getPos(int & x, int & y) const;
72         /// returns cursor dimension
73         void getDim(int & asc, int & desc) const;
74         /// cache the absolute coordinate from the top inset
75         void updatePos();
76         ///
77         friend std::ostream & operator<<(std::ostream &, LCursor const &);
78 public:
79         /// mainly used as stack, but wee need random access
80         std::vector<CursorSlice> data_;
81         ///
82         BufferView * bv_;
83 private:
84         ///
85         int cached_y_;
86 };
87
88 #endif // LYXCURSOR_H