4 * Copyright 1995-2001 the LyX Team
5 * Read the file COPYING
7 * \author Matthias Ettrich
13 #include "support/types.h"
19 * The cursor class describes the position of a cursor within a document.
20 * Several cursors exist within LyX; for example, when locking an inset,
21 * the position of the cursor in the containing inset is stored.
28 /// set the paragraph that contains this cursor
29 void par(Paragraph * p);
30 /// return the paragraph this cursor is in
31 Paragraph * par() const;
32 /// set the position within the paragraph
33 void pos(lyx::pos_type p);
34 /// return the position within the paragraph
35 lyx::pos_type pos() const;
37 void boundary(bool b);
39 bool boundary() const;
40 /// set the x position in pixels
42 /// return the x position in pixels
44 /// set the stored next-line position when at the end of a row
47 * Return the x position of the start of the next row, when this
48 * cursor is at the end of the previous row, for insets that take
51 * FIXME: explain why we need this ?
54 /// set the cached x position
57 * Return the cached x position of the cursor. This is used for when
60 * blah blah blah blah| blah blah blah
62 * blah blah blah blah blah blah
64 * When we move onto row 3, we would like to be vertically aligned
65 * with where we were in row 1, despite the fact that row 2 is
69 /// set the y position in pixels
71 /// return the y position in pixels
73 /// set the stored next-line y position when at the end of a row
76 * Return the y position of the start of the next row, when this
77 * cursor is at the end of the previous row, for insets that take
80 * FIXME: explain why we need this ? especially for y...
83 /// set the row of the paragraph the cursor is in
85 /// return the row of the paragraph this cursor is in
87 /// set the stored next row
90 * Return the next row, when this
91 * cursor is at the end of the previous row, for insets that take
94 * FIXME: explain why we need this ? especially for y...
98 /// The paragraph the cursor is in.
100 /// The position inside the paragraph
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
118 /// the pixel x position
120 /// the stored next-row x position
122 /// the cached x position
124 /// the pixel y position
126 /// the stored next-row y position
128 /// the containing row
130 /// the containing row for the next line
134 /// these three dictate the others
136 bool operator==(LyXCursor const & a, LyXCursor const & b)
138 return (a.par() == b.par())
139 && (a.pos() == b.pos())
140 && a.boundary() == b.boundary();
144 bool operator!=(LyXCursor const & a, LyXCursor const & b)
149 /// only compares y() and pos(). Can this be done in another way?
151 bool operator<(LyXCursor const & a, LyXCursor const & b)
153 return (a.y() < b.y() && a.pos() < b.pos());
157 bool operator>(LyXCursor const & a, LyXCursor const & b)
163 bool operator>=(LyXCursor const & a, LyXCursor const & b)
170 bool operator<=(LyXCursor const & a, LyXCursor const & b)
175 #endif // LYXCURSOR_H