4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Lars Gullik Bjønnes
8 * \author Matthias Ettrich
10 * \author André Pönitz
12 * \author Jürgen Vigna
14 * Full author contact details are available in file CREDITS.
23 #include "support/types.h"
33 /// This encapsulates a single slice of a document iterator as used e.g.
36 // After IU, the distinction of MathInset and UpdatableInset as well as
37 // that of MathArray and LyXText should vanish. They are conceptually the
42 /// type for cell number in inset
43 typedef size_t idx_type;
44 /// type for paragraph numbers positions within a cell
45 typedef lyx::paroffset_type par_type;
46 /// type for cursor positions within a cell
47 typedef lyx::pos_type pos_type;
48 /// type for row indices
49 typedef size_t row_type;
50 /// type for col indices
51 typedef size_t col_type;
56 explicit CursorSlice(InsetBase *);
59 InsetBase * inset() const { return inset_; }
60 /// set the paragraph that contains this cursor
61 void idx(idx_type idx);
62 /// return the paragraph this cursor is in
64 /// return the paragraph this cursor is in
66 /// set the paragraph that contains this cursor
67 void par(par_type par);
68 /// return the paragraph this cursor is in
70 /// return the paragraph this cursor is in
72 /// set the position within the paragraph
73 void pos(pos_type pos);
74 /// return the position within the paragraph
76 /// return the position within the paragraph
78 /// return the last position within the paragraph
79 pos_type lastpos() const;
80 /// return the number of embedded cells
82 /// return the number of embedded cells
84 /// return the number of embedded cells
86 /// return the grid row of the current cell
88 /// return the grid row of the current cell
92 void boundary(bool b);
94 bool boundary() const;
96 /// texted specific stuff
99 LyXText * text() const;
101 UpdatableInset * asUpdatableInset() const;
104 /// mathed specific stuff
106 /// returns cell corresponding to this position
107 MathArray & cell() const;
108 /// gets screen position of the thing
109 void getScreenPos(int & x, int & y) const;
111 MathInset * asMathInset() const;
114 friend std::ostream & operator<<(std::ostream &, CursorSlice const &);
116 /// pointer to an inset
118 /// cell index of a position in this inset
120 /// paragraph in this cell (used by texted)
122 /// position in this cell
125 * When the cursor position is i, is the cursor is after the i-th char
126 * or before the i+1-th char ? Normally, these two interpretations are
127 * equivalent, except when the fonts of the i-th and i+1-th char
129 * We use boundary_ to distinguish between the two options:
130 * If boundary_=true, then the cursor is after the i-th char
131 * and if boundary_=false, then the cursor is before the i+1-th char.
133 * We currently use the boundary only when the language direction of
134 * the i-th char is different than the one of the i+1-th char.
135 * In this case it is important to distinguish between the two
136 * cursor interpretations, in order to give a reasonable behavior to
142 /// test for equality
143 bool operator==(CursorSlice const &, CursorSlice const &);
144 /// test for inequality
145 bool operator!=(CursorSlice const &, CursorSlice const &);
147 bool operator<(CursorSlice const &, CursorSlice const &);
149 bool operator>(CursorSlice const &, CursorSlice const &);
154 // this is used for traversing math insets
155 typedef std::vector<CursorSlice> CursorBase;
157 void increment(CursorBase &);
159 CursorBase ibegin(InsetBase * p);
161 CursorBase iend(InsetBase * p);
163 CursorSlice & cursorTip(BufferView &);