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 par(par_type pit);
55 /// return the paragraph this cursor is in
57 /// set the position within the paragraph
59 /// return the position within the paragraph
63 void boundary(bool b);
65 bool boundary() const;
67 /// texted specific stuff
70 LyXText * text() const;
72 UpdatableInset * asUpdatableInset() const;
75 /// mathed specific stuff
77 /// returns cell corresponding to this position
78 MathArray & cell() const;
79 /// returns cell corresponding to this position
80 MathArray & cell(idx_type idx) const;
81 /// gets screen position of the thing
82 void getPos(int & x, int & y) const;
86 MathInset * asMathInset() const;
89 friend std::ostream & operator<<(std::ostream &, CursorSlice const &);
91 /// pointer to an inset
93 /// cell index of a position in this inset
95 /// paragraph in this cell (used by texted)
97 /// position in this cell
100 * When the cursor position is i, is the cursor is after the i-th char
101 * or before the i+1-th char ? Normally, these two interpretations are
102 * equivalent, except when the fonts of the i-th and i+1-th char
104 * We use boundary_ to distinguish between the two options:
105 * If boundary_=true, then the cursor is after the i-th char
106 * and if boundary_=false, then the cursor is before the i+1-th char.
108 * We currently use the boundary only when the language direction of
109 * the i-th char is different than the one of the i+1-th char.
110 * In this case it is important to distinguish between the two
111 * cursor interpretations, in order to give a reasonable behavior to
117 /// test for equality
118 bool operator==(CursorSlice const &, CursorSlice const &);
119 /// test for inequality
120 bool operator!=(CursorSlice const &, CursorSlice const &);
122 bool operator<(CursorSlice const &, CursorSlice const &);
124 bool operator>(CursorSlice const &, CursorSlice const &);