4 * Copyright 1995-2001 the LyX Team
5 * Read the file COPYING
7 * \author Matthias Ettrich
17 #include "support/types.h"
23 * The cursor class describes the position of a cursor within a document.
24 * Several cursors exist within LyX; for example, when locking an inset,
25 * the position of the cursor in the containing inset is stored.
32 /// set the paragraph that contains this cursor
33 void par(Paragraph * p);
34 /// return the paragraph this cursor is in
35 Paragraph * par() const;
36 /// set the position within the paragraph
37 void pos(lyx::pos_type p);
38 /// return the position within the paragraph
39 lyx::pos_type pos() const;
41 void boundary(bool b);
43 bool boundary() const;
44 /// set the x position in pixels
46 /// return the x position in pixels
48 /// set the stored next-line position when at the end of a row
51 * Return the x position of the start of the next row, when this
52 * cursor is at the end of the previous row, for insets that take
55 * FIXME: explain why we need this ?
58 /// set the cached x position
61 * Return the cached x position of the cursor. This is used for when
64 * blah blah blah blah| blah blah blah
66 * blah blah blah blah blah blah
68 * When we move onto row 3, we would like to be vertically aligned
69 * with where we were in row 1, despite the fact that row 2 is
73 /// set the y position in pixels
75 /// return the y position in pixels
77 /// set the stored next-line y position when at the end of a row
80 * Return the y position of the start of the next row, when this
81 * cursor is at the end of the previous row, for insets that take
84 * FIXME: explain why we need this ? especially for y...
87 /// set the row of the paragraph the cursor is in
89 /// return the row of the paragraph this cursor is in
91 /// set the stored next row
94 * Return the next row, when this
95 * cursor is at the end of the previous row, for insets that take
98 * FIXME: explain why we need this ? especially for y...
102 /// The paragraph the cursor is in.
104 /// The position inside the paragraph
107 * When the cursor position is i, is the cursor is after the i-th char
108 * or before the i+1-th char ? Normally, these two interpretations are
109 * equivalent, except when the fonts of the i-th and i+1-th char
111 * We use boundary_ to distinguish between the two options:
112 * If boundary_=true, then the cursor is after the i-th char
113 * and if boundary_=false, then the cursor is before the i+1-th char.
115 * We currently use the boundary only when the language direction of
116 * the i-th char is different than the one of the i+1-th char.
117 * In this case it is important to distinguish between the two
118 * cursor interpretations, in order to give a reasonable behavior to
122 /// the pixel x position
124 /// the stored next-row x position
126 /// the cached x position
128 /// the pixel y position
130 /// the stored next-row y position
132 /// the containing row
134 /// the containing row for the next line
138 /// these three dictate the others
140 bool operator==(LyXCursor const & a, LyXCursor const & b)
142 return (a.par() == b.par())
143 && (a.pos() == b.pos())
144 && a.boundary() == b.boundary();
148 bool operator!=(LyXCursor const & a, LyXCursor const & b)
153 /// only compares y() and pos(). Can this be done in another way?
155 bool operator<(LyXCursor const & a, LyXCursor const & b)
157 return (a.y() < b.y() && a.pos() < b.pos());
161 bool operator>(LyXCursor const & a, LyXCursor const & b)
167 bool operator>=(LyXCursor const & a, LyXCursor const & b)
174 bool operator<=(LyXCursor const & a, LyXCursor const & b)
179 #endif // LYXCURSOR_H