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"
32 /// This encapsulates a single slice of a document iterator as used e.g.
35 // After IU, the distinction of MathInset and UpdatableInset as well as
36 // that of MathArray and LyXText should vanish. They are conceptually the
41 /// type for cell number in inset
42 typedef size_t idx_type;
43 /// type for paragraph numbers positions within a cell
44 typedef lyx::paroffset_type par_type;
45 /// type for cursor positions within a cell
46 typedef lyx::pos_type pos_type;
51 explicit CursorSlice(InsetBase *);
53 /// set the paragraph that contains this cursor
54 void idx(idx_type idx);
55 /// return the paragraph this cursor is in
57 /// set the paragraph that contains this cursor
58 void par(par_type par);
59 /// return the paragraph this cursor is in
61 /// set the position within the paragraph
62 void pos(pos_type pos);
63 /// return the position within the paragraph
67 void boundary(bool b);
69 bool boundary() const;
71 /// texted specific stuff
74 LyXText * text() const;
76 UpdatableInset * asUpdatableInset() const;
79 /// mathed specific stuff
81 /// returns cell corresponding to this position
82 MathArray & cell() const;
83 /// returns cell corresponding to this position
84 MathArray & cell(idx_type idx) const;
85 /// gets screen position of the thing
86 void getPos(int & x, int & y) const;
90 MathInset * asMathInset() const;
93 friend std::ostream & operator<<(std::ostream &, CursorSlice const &);
95 /// pointer to an inset
97 /// cell index of a position in this inset
99 /// paragraph in this cell (used by texted)
101 /// position in this cell
104 * When the cursor position is i, is the cursor is after the i-th char
105 * or before the i+1-th char ? Normally, these two interpretations are
106 * equivalent, except when the fonts of the i-th and i+1-th char
108 * We use boundary_ to distinguish between the two options:
109 * If boundary_=true, then the cursor is after the i-th char
110 * and if boundary_=false, then the cursor is before the i+1-th char.
112 * We currently use the boundary only when the language direction of
113 * the i-th char is different than the one of the i+1-th char.
114 * In this case it is important to distinguish between the two
115 * cursor interpretations, in order to give a reasonable behavior to
121 /// test for equality
122 bool operator==(CursorSlice const &, CursorSlice const &);
123 /// test for inequality
124 bool operator!=(CursorSlice const &, CursorSlice const &);
126 bool operator<(CursorSlice const &, CursorSlice const &);
128 bool operator>(CursorSlice const &, CursorSlice const &);
133 // this is used for traversing math insets
134 typedef std::vector<CursorSlice> CursorBase;
136 void increment(CursorBase &);
138 CursorBase ibegin(InsetBase * p);
140 CursorBase iend(InsetBase * p);