X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Flyxcursor.h;h=cc7cb9ef90b91f22d5755a4db3353a2b323314ca;hb=8d1c58af82d1fc356f470dff97878ab7c3e8a2fe;hp=12a25b08188b48681c53556e34a0a15a46fa57e3;hpb=dfe1bc44b44903faf77ef454c98c4c3e56c1d5e3;p=lyx.git diff --git a/src/lyxcursor.h b/src/lyxcursor.h index 12a25b0818..cc7cb9ef90 100644 --- a/src/lyxcursor.h +++ b/src/lyxcursor.h @@ -1,40 +1,121 @@ // -*- C++ -*- /* This file is part of - * ====================================================== + * ====================================================== * * LyX, The Document Processor * - * Copyright (C) 1995 Matthias Ettrich + * Copyright 1995 Matthias Ettrich + * Copyright 1995-2001 The LyX Team. * - *======================================================*/ + * ====================================================== */ #ifndef LYXCURSOR_H #define LYXCURSOR_H -#include "lyxparagraph.h" +#ifdef __GNUG__ +#pragma interface +#endif + +#include "support/types.h" -struct Row; +class Paragraph; +class Row; -/** All these variavles should be explained. Matthias? +/** All these variables should be explained. Matthias? */ -struct LyXCursor { +class LyXCursor { +public: /// - LyXParagraph * par; -#ifdef NEW_TEXT + LyXCursor(); /// - LyXParagraph::size_type pos; -#else + void par(Paragraph * p); /// - int pos; -#endif + Paragraph * par() const; + /// + void pos(lyx::pos_type p); + /// + lyx::pos_type pos() const; + /// + void boundary(bool b); + /// + bool boundary() const; + /// + void x(int i); + /// + int x() const; + /// + void x_fix(int i); + /// + int x_fix() const; + /// + void y(int i); /// - int x; + int y() const; /// - int x_fix; + void row(Row * r); /// - long y; + Row * row() const; +private: + /// The paragraph the cursor is in. + Paragraph * par_; + /// The position inside the paragraph + lyx::pos_type pos_; /// - Row * row; + bool boundary_; + /// + int x_; + /// + int x_fix_; + /// + int y_; + /// + Row * row_; }; +/// +inline +bool operator==(LyXCursor const & a, LyXCursor const & b) +{ + return (a.par() == b.par()) + && (a.pos() == b.pos()) + && a.boundary() == b.boundary(); +} + +/// +inline +bool operator!=(LyXCursor const & a, LyXCursor const & b) +{ + return !(a == b); +} + +/// +inline +bool operator<(LyXCursor const & a, LyXCursor const & b) +{ + // Can this be done in a nother way? + return (a.y() < b.y() && a.pos() < b.pos()); +} + +/// +inline +bool operator>(LyXCursor const & a, LyXCursor const & b) +{ + return b < a; +} + +/// +inline +bool operator>=(LyXCursor const & a, LyXCursor const & b) +{ + return !(a < b); +} + + +/// +inline +bool operator<=(LyXCursor const & a, LyXCursor const & b) +{ + return !(a > b); +} + #endif