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