]> git.lyx.org Git - lyx.git/blobdiff - src/cursor_slice.h
more cursor dispatch
[lyx.git] / src / cursor_slice.h
index 48a850b98f48345763d5ec001e866fc74540f27f..a06a374222015d7864e1ebbcd2a837358a9c2733 100644 (file)
 #ifndef CURSORSLICE_H
 #define CURSORSLICE_H
 
-#include <iosfwd>
 #include <cstddef>
+#include <iosfwd>
 
 #include "support/types.h"
 
+class BufferView;
 class InsetBase;
-class UpdatableInset;
 class MathInset;
-class LyXText;
 class MathArray;
+class LyXText;
+class Paragraph;
+class UpdatableInset;
 
 
 /// This encapsulates a single slice of a document iterator as used e.g.
@@ -44,48 +46,74 @@ public:
        typedef lyx::paroffset_type par_type;
        /// type for cursor positions within a cell
        typedef lyx::pos_type pos_type;
+       /// type for row indices
+       typedef size_t row_type;
+       /// type for col indices
+       typedef size_t col_type;
 
        ///
        CursorSlice();
        ///
        explicit CursorSlice(InsetBase *);
 
+       /// the current inset
+       InsetBase * inset() const { return inset_; }
        /// set the paragraph that contains this cursor
        void idx(idx_type idx);
-       /// return the paragraph this cursor is in
+       /// return the cell this cursor is in
        idx_type idx() const;
+       /// return the cell this cursor is in
+       idx_type & idx();
+       /// return the last cell in this inset
+       idx_type lastidx() const { return nargs() - 1; }
        /// set the paragraph that contains this cursor
        void par(par_type par);
        /// return the paragraph this cursor is in
        par_type par() const;
+       /// return the paragraph this cursor is in
+       par_type & par();
        /// set the position within the paragraph
        void pos(pos_type pos);
        /// return the position within the paragraph
        pos_type pos() const;
+       /// return the position within the paragraph
+       pos_type & pos();
+       /// return the last position within the paragraph
+       pos_type lastpos() const;
+       /// return the number of embedded cells
+       size_t nargs() const;
+       /// return the number of embedded cells
+       size_t ncols() const;
+       /// return the number of embedded cells
+       size_t nrows() const;
+       /// return the grid row of the current cell
+       row_type row() const;
+       /// return the grid row of the current cell
+       col_type col() const;
 
-       /// FIXME
-       void boundary(bool b);
-       /// FIXME
-       bool boundary() const;
        ///
        /// texted specific stuff
        ///
+       /// see comment for the member
+       void boundary(bool b);
+       /// see comment for the member
+       bool boundary() const;
+       /// see comment for the member
+       bool & boundary();
        ///
        LyXText * text() const;
        ///
        UpdatableInset * asUpdatableInset() const;
+       ///
+       Paragraph & paragraph();
+       ///
+       Paragraph const & paragraph() const;
 
        ///
        /// mathed specific stuff
        ///
        /// returns cell corresponding to this position
        MathArray & cell() const;
-       /// returns cell corresponding to this position
-       MathArray & cell(idx_type idx) const;
-       /// gets screen position of the thing
-       void getPos(int & x, int & y) const;
-       /// set position
-       void setPos(int pos);
        ///
        MathInset * asMathInset() const;
 
@@ -127,17 +155,4 @@ bool operator<(CursorSlice const &, CursorSlice const &);
 /// test for order
 bool operator>(CursorSlice const &, CursorSlice const &);
 
-#include <vector>
-
-
-// this is used for traversing math insets
-typedef std::vector<CursorSlice> CursorBase;
-/// move on one step
-void increment(CursorBase &);
-///
-CursorBase ibegin(InsetBase * p);
-///
-CursorBase iend(InsetBase * p);
-
-
 #endif