]> git.lyx.org Git - lyx.git/blobdiff - src/DocIterator.h
start using FileName::exists()
[lyx.git] / src / DocIterator.h
index fd4050cec8c40e23bb70b1621d3ff279392070b8..fe05e398c841ac228094beba4af124abfc7b66cb 100644 (file)
@@ -20,7 +20,7 @@
 
 namespace lyx {
 
-class LyXText;
+class Text;
 class MathAtom;
 class Paragraph;
 
@@ -49,7 +49,7 @@ public:
        ///
        DocIterator();
        ///
-       explicit DocIterator(InsetBase & inset);
+       explicit DocIterator(Inset & inset);
 
        /// access slice at position \p i
        CursorSlice const & operator[](size_t i) const { return slices_[i]; }
@@ -80,7 +80,7 @@ public:
        /// how many nested insets do we have?
        size_t depth() const { return slices_.size(); }
        /// the containing inset
-       InsetBase & inset() const { return top().inset(); }
+       Inset & inset() const { return top().inset(); }
        /// return the cell of the inset this cursor is in
        idx_type idx() const { return top().idx(); }
        /// return the cell of the inset this cursor is in
@@ -115,11 +115,9 @@ public:
        /// return the last column of the top grid
        col_type lastcol() const { return ncols() - 1; }
        /// the inset just behind the cursor
-       InsetBase * nextInset();
+       Inset * nextInset() const;
        /// the inset just in front of the cursor
-       InsetBase * prevInset();
-       /// the inset just in front of the cursor
-       InsetBase const * prevInset() const;
+       Inset * prevInset() const;
        ///
        bool boundary() const { return boundary_; }
        ///
@@ -138,43 +136,35 @@ public:
        // math-specific part
        //
        /// return the mathed cell this cursor is in
-       MathData const & cell() const;
-       /// return the mathed cell this cursor is in
-       MathData & cell();
+       MathData & cell() const;
        /// the mathatom left of the cursor
-       MathAtom const & prevAtom() const;
-       /// the mathatom left of the cursor
-       MathAtom & prevAtom();
-       /// the mathatom right of the cursor
-       MathAtom const & nextAtom() const;
+       MathAtom & prevAtom() const;
        /// the mathatom right of the cursor
-       MathAtom & nextAtom();
+       MathAtom & nextAtom() const;
 
-       //
        // text-specific part
        //
-       /// the paragraph we're in
-       Paragraph & paragraph();
-       /// the paragraph we're in
-       Paragraph const & paragraph() const;
-       ///
-       LyXText * text();
+       /// the paragraph we're in in text mode.
+       /// \warning only works within text!
+       Paragraph & paragraph() const;
+       /// the paragraph we're in in any case.
+       /// This method will give the containing paragraph even
+       /// if not in text mode (ex: in mathed).
+       Paragraph & innerParagraph() const;
+       /// return the inner text slice.
+       CursorSlice const & innerTextSlice() const;
        ///
-       LyXText const * text() const;
+       Text * text() const;
        /// the containing inset or the cell, respectively
-       InsetBase * realInset() const;
-       ///
-       InsetBase * innerInsetOfType(int code) const;
+       Inset * realInset() const;
        ///
-       LyXText * innerText();
+       Inset * innerInsetOfType(int code) const;
        ///
-       LyXText const * innerText() const;
+       Text * innerText() const;
 
        //
        // elementary moving
        //
-       /// move on one logical position, do not descend into nested insets
-       void forwardPosNoDescend();
        /**
         * move on one logical position, descend into nested insets
         * skip collapsed insets if \p ignorecollapsed is true
@@ -184,8 +174,6 @@ public:
        void forwardChar();
        /// move on one paragraph
        void forwardPar();
-       /// move on one cell
-       void forwardIdx();
        /// move on one inset
        void forwardInset();
        /// move backward one logical position
@@ -194,8 +182,6 @@ public:
        void backwardChar();
        /// move backward one paragraph
        void backwardPar();
-       /// move backward one cell
-       void backwardIdx();
        /// move backward one inset
        /// FIXME: This is not implemented!
        //void backwardInset();
@@ -208,6 +194,9 @@ public:
        operator<<(std::ostream & os, DocIterator const & cur);
        ///
        friend bool operator==(DocIterator const &, DocIterator const &);
+       friend bool operator<(DocIterator const &, DocIterator const &);
+       friend bool operator>(DocIterator const &, DocIterator const &);
+       friend bool operator<=(DocIterator const &, DocIterator const &);
        ///
        friend class StableDocIterator;
 //protected:
@@ -218,7 +207,10 @@ public:
        ///
        void pop_back() { slices_.pop_back(); }
        /// recompute the inset parts of the cursor from the document data
-       void updateInsets(InsetBase * inset);
+       void updateInsets(Inset * inset);
+       /// fix DocIterator in circumstances that should never happen.
+       /// \return true if the DocIterator was fixed.
+       bool fixIfBroken();
 
 private:
        /**
@@ -244,12 +236,12 @@ private:
        ///
        std::vector<CursorSlice> slices_;
        ///
-       InsetBase * inset_;
+       Inset * inset_;
 };
 
 
-DocIterator doc_iterator_begin(InsetBase & inset);
-DocIterator doc_iterator_end(InsetBase & inset);
+DocIterator doc_iterator_begin(Inset & inset);
+DocIterator doc_iterator_end(Inset & inset);
 
 
 inline
@@ -277,7 +269,7 @@ public:
        /// non-explicit intended
        StableDocIterator(const DocIterator & it);
        ///
-       DocIterator asDocIterator(InsetBase * start) const;
+       DocIterator asDocIterator(Inset * start) const;
        ///
        size_t size() const { return data_.size(); }
        ///  return the position within the paragraph