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;
52 explicit CursorSlice(InsetBase *);
54 /// set the paragraph that contains this cursor
55 void idx(idx_type idx);
56 /// return the paragraph this cursor is in
58 /// set the paragraph that contains this cursor
59 void par(par_type par);
60 /// return the paragraph this cursor is in
62 /// set the position within the paragraph
63 void pos(pos_type pos);
64 /// return the position within the paragraph
68 void boundary(bool b);
70 bool boundary() const;
72 /// texted specific stuff
75 LyXText * text() const;
77 UpdatableInset * asUpdatableInset() const;
80 /// mathed specific stuff
82 /// returns cell corresponding to this position
83 MathArray & cell() const;
84 /// set cell corresponding to this position
85 void cell(idx_type idx) const;
86 /// gets screen position of the thing
87 void getScreenPos(int & x, int & y) const;
89 MathInset * asMathInset() const;
92 friend std::ostream & operator<<(std::ostream &, CursorSlice const &);
94 /// pointer to an inset
96 /// cell index of a position in this inset
98 /// paragraph in this cell (used by texted)
100 /// position in this cell
103 * When the cursor position is i, is the cursor is after the i-th char
104 * or before the i+1-th char ? Normally, these two interpretations are
105 * equivalent, except when the fonts of the i-th and i+1-th char
107 * We use boundary_ to distinguish between the two options:
108 * If boundary_=true, then the cursor is after the i-th char
109 * and if boundary_=false, then the cursor is before the i+1-th char.
111 * We currently use the boundary only when the language direction of
112 * the i-th char is different than the one of the i+1-th char.
113 * In this case it is important to distinguish between the two
114 * cursor interpretations, in order to give a reasonable behavior to
120 /// test for equality
121 bool operator==(CursorSlice const &, CursorSlice const &);
122 /// test for inequality
123 bool operator!=(CursorSlice const &, CursorSlice const &);
125 bool operator<(CursorSlice const &, CursorSlice const &);
127 bool operator>(CursorSlice const &, CursorSlice const &);
132 // this is used for traversing math insets
133 typedef std::vector<CursorSlice> CursorBase;
135 void increment(CursorBase &);
137 CursorBase ibegin(InsetBase * p);
139 CursorBase iend(InsetBase * p);
141 CursorSlice & cursorTip(BufferView &);