X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Flyxcursor.h;h=1032055f0e5006f217dfe3fe6ee165907d9a3214;hb=ef9cb74104a464e6484fe819329cee9d3c6c706e;hp=322dd38dc9375edd268cfaff51d5d01db2c73c87;hpb=27de1486ca34aaad446adb798d71a77d6f6304da;p=lyx.git diff --git a/src/lyxcursor.h b/src/lyxcursor.h index 322dd38dc9..1032055f0e 100644 --- a/src/lyxcursor.h +++ b/src/lyxcursor.h @@ -1,33 +1,119 @@ // -*- 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 + * ====================================================== */ + +#ifndef LYXCURSOR_H +#define LYXCURSOR_H + +#ifdef __GNUG__ +#pragma interface +#endif + +#include "paragraph.h" -class LyXParagraph; struct Row; -/** All these variavles should be explained. Matthias? +/** All these variables should be explained. Matthias? */ -struct LyXCursor { +class LyXCursor { +public: + LyXCursor(); + /// + void par(Paragraph * p); + /// + Paragraph * par() const; + /// + void pos(Paragraph::size_type p); + /// + Paragraph::size_type pos() const; + /// + void boundary(bool b); + /// + bool boundary() const; + /// + void x(int i); + /// + int x() const; /// - LyXParagraph *par; + void x_fix(int i); /// - int pos; + int x_fix() const; /// - int x; + void y(int i); /// - int x_fix; + int y() const; /// - long y; + void row(Row * r); /// - Row *row; + Row * row() const; +private: + /// The paragraph the cursor is in. + Paragraph * par_; + /// The position inside the paragraph + Paragraph::size_type pos_; + /// + 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