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 *);
58 /// set the paragraph that contains this cursor
59 void idx(idx_type idx);
60 /// return the paragraph this cursor is in
62 /// return the paragraph this cursor is in
64 /// set the paragraph that contains this cursor
65 void par(par_type par);
66 /// return the paragraph this cursor is in
68 /// return the paragraph this cursor is in
70 /// set the position within the paragraph
71 void pos(pos_type pos);
72 /// return the position within the paragraph
74 /// return the position within the paragraph
76 /// return the last position within the paragraph
77 pos_type lastpos() const;
78 /// return the grid row of the current cell
80 /// return the grid row of the current cell
84 void boundary(bool b);
86 bool boundary() const;
88 /// texted specific stuff
91 LyXText * text() const;
93 UpdatableInset * asUpdatableInset() const;
96 /// mathed specific stuff
98 /// returns cell corresponding to this position
99 MathArray & cell() const;
100 /// gets screen position of the thing
101 void getScreenPos(int & x, int & y) const;
103 MathInset * asMathInset() const;
106 friend std::ostream & operator<<(std::ostream &, CursorSlice const &);
108 /// pointer to an inset
110 /// cell index of a position in this inset
112 /// paragraph in this cell (used by texted)
114 /// position in this cell
117 * When the cursor position is i, is the cursor is after the i-th char
118 * or before the i+1-th char ? Normally, these two interpretations are
119 * equivalent, except when the fonts of the i-th and i+1-th char
121 * We use boundary_ to distinguish between the two options:
122 * If boundary_=true, then the cursor is after the i-th char
123 * and if boundary_=false, then the cursor is before the i+1-th char.
125 * We currently use the boundary only when the language direction of
126 * the i-th char is different than the one of the i+1-th char.
127 * In this case it is important to distinguish between the two
128 * cursor interpretations, in order to give a reasonable behavior to
134 /// test for equality
135 bool operator==(CursorSlice const &, CursorSlice const &);
136 /// test for inequality
137 bool operator!=(CursorSlice const &, CursorSlice const &);
139 bool operator<(CursorSlice const &, CursorSlice const &);
141 bool operator>(CursorSlice const &, CursorSlice const &);
146 // this is used for traversing math insets
147 typedef std::vector<CursorSlice> CursorBase;
149 void increment(CursorBase &);
151 CursorBase ibegin(InsetBase * p);
153 CursorBase iend(InsetBase * p);
155 CursorSlice & cursorTip(BufferView &);