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"
34 /// This encapsulates a single slice of a document iterator as used e.g.
37 // After IU, the distinction of MathInset and UpdatableInset as well as
38 // that of MathArray and LyXText should vanish. They are conceptually the
43 /// type for cell number in inset
44 typedef size_t idx_type;
45 /// type for paragraph numbers positions within a cell
46 typedef lyx::paroffset_type par_type;
47 /// type for cursor positions within a cell
48 typedef lyx::pos_type pos_type;
49 /// type for row indices
50 typedef size_t row_type;
51 /// type for col indices
52 typedef size_t col_type;
57 explicit CursorSlice(InsetBase *);
60 InsetBase * inset() const { return inset_; }
61 /// set the paragraph that contains this cursor
62 void idx(idx_type idx);
63 /// return the paragraph this cursor is in
65 /// return the paragraph this cursor is in
67 /// set the paragraph that contains this cursor
68 void par(par_type par);
69 /// return the paragraph this cursor is in
71 /// return the paragraph this cursor is in
73 /// set the position within the paragraph
74 void pos(pos_type pos);
75 /// return the position within the paragraph
77 /// return the position within the paragraph
79 /// return the last position within the paragraph
80 pos_type lastpos() const;
81 /// return the number of embedded cells
83 /// return the number of embedded cells
85 /// return the number of embedded cells
87 /// return the grid row of the current cell
89 /// return the grid row of the current cell
93 void boundary(bool b);
95 bool boundary() const;
97 /// texted specific stuff
100 LyXText * text() const;
102 UpdatableInset * asUpdatableInset() const;
104 Paragraph & paragraph();
106 Paragraph const & paragraph() const;
109 /// mathed specific stuff
111 /// returns cell corresponding to this position
112 MathArray & cell() const;
113 /// gets screen position of the thing
114 void getScreenPos(int & x, int & y) const;
116 MathInset * asMathInset() const;
119 friend std::ostream & operator<<(std::ostream &, CursorSlice const &);
121 /// pointer to an inset
123 /// cell index of a position in this inset
125 /// paragraph in this cell (used by texted)
127 /// position in this cell
130 * When the cursor position is i, is the cursor is after the i-th char
131 * or before the i+1-th char ? Normally, these two interpretations are
132 * equivalent, except when the fonts of the i-th and i+1-th char
134 * We use boundary_ to distinguish between the two options:
135 * If boundary_=true, then the cursor is after the i-th char
136 * and if boundary_=false, then the cursor is before the i+1-th char.
138 * We currently use the boundary only when the language direction of
139 * the i-th char is different than the one of the i+1-th char.
140 * In this case it is important to distinguish between the two
141 * cursor interpretations, in order to give a reasonable behavior to
147 /// test for equality
148 bool operator==(CursorSlice const &, CursorSlice const &);
149 /// test for inequality
150 bool operator!=(CursorSlice const &, CursorSlice const &);
152 bool operator<(CursorSlice const &, CursorSlice const &);
154 bool operator>(CursorSlice const &, CursorSlice const &);