]> git.lyx.org Git - lyx.git/blobdiff - src/Cursor.h
Merge branch 'master' of git.lyx.org:lyx
[lyx.git] / src / Cursor.h
index c3ae44888db2fbac087a3a5a55084ff20240dd9d..aa31f91c96b5592d951b8e649463213dc8ebd91f 100644 (file)
@@ -88,22 +88,19 @@ public:
        explicit CursorData(Buffer * buffer);
        ///
        explicit CursorData(DocIterator const & dit);
+       /// output
+       friend std::ostream & operator<<(std::ostream & os, CursorData const & cur);
+       friend LyXErr & operator<<(LyXErr & os, CursorData const & cur);
+
 protected:
        /// the anchor position
        DocIterator anchor_;
-       ///
-       mutable DispatchResult disp_;
        /// do we have a selection?
        bool selection_;
        /// are we on the way to get one?
        bool mark_;
        /// are we in word-selection mode? This is set when double clicking.
        bool word_selection_;
-       /// If true, we are behind the previous char, otherwise we are in front
-       // of the next char. This only make a difference when we are in front
-       // of a big inset spanning a whole row and computing coordinates for
-       // displaying the cursor.
-       bool logicalpos_;
 
 // FIXME: make them protected.
 public:
@@ -164,8 +161,8 @@ public:
        //
        /// selection active?
        bool selection() const { return selection_; }
-       /// set selection;
-       void setSelection(bool sel) { selection_ = sel; }
+       /// set selection; this is lower level than (set|clear)Selection
+       void selection(bool sel) { selection_ = sel; }
        /// do we have a multicell selection?
        bool selIsMultiCell() const 
                { return selection_ && selBegin().idx() != selEnd().idx(); }
@@ -214,6 +211,9 @@ public:
        bool macromode() const { return macromode_; }
        /// are we entering a macro name?
        bool & macromode() { return macromode_; }
+
+       /// returns true when all insets in cursor stack are in cache
+       bool inCoordCache() const;
        /// returns x,y position
        void getPos(int & x, int & y) const;
        /// return logical positions between which the cursor is situated
@@ -221,7 +221,7 @@ public:
         * If the cursor is at the edge of a row, the position which is "over the 
         * edge" will be returned as -1.
         */
-       void getSurroundingPos(pos_type & left_pos, pos_type & right_pos);
+       void getSurroundingPos(pos_type & left_pos, pos_type & right_pos) const;
        /// the row in the paragraph we're in
        Row const & textRow() const;
 
@@ -264,6 +264,8 @@ public:
        bool posVisToNewRow(bool movingLeft);
        /// move to right or left extremity of the current row
        void posVisToRowExtremity(bool left);
+       /// Should interpretation of the arrow keys be reversed?
+       bool reverseDirectionNeeded() const;
 
        /// insert an inset
        void insert(Inset *);
@@ -290,10 +292,9 @@ public:
 
        /// access to normalized selection anchor
        CursorSlice normalAnchor() const;
-       // FIXME: this can't be a const & and a const function because
-       // LFUN_TAB_* wants to move the real anchor.
        /// access to real selection anchor
-       DocIterator & realAnchor();
+       DocIterator const & realAnchor() const { return anchor_; }
+       DocIterator & realAnchor() { return anchor_; }
        /// sets anchor to cursor position
        void resetAnchor();
        /// access to owning BufferView
@@ -339,16 +340,12 @@ public:
         */
        void noScreenUpdate() const;
        /// fix cursor in circumstances that should never happen.
-       /// \retval true if a fix occured.
+       /// \retval true if a fix occurred.
        bool fixIfBroken();
        /// Repopulate the slices insets from bottom to top. Useful
        /// for stable iterators or Undo data.
        void sanitize();
 
-       /// output
-       friend std::ostream & operator<<(std::ostream & os, Cursor const & cur);
-       friend LyXErr & operator<<(LyXErr & os, Cursor const & cur);
-
        ///
        bool textUndo();
        ///
@@ -364,21 +361,23 @@ public:
        void endUndoGroup() const;
 
        /// The general case: prepare undo for an arbitrary range.
-       void recordUndo(UndoKind kind, pit_type from, pit_type to) const;
+       void recordUndo(pit_type from, pit_type to) const;
 
        /// Convenience: prepare undo for the range between 'from' and cursor.
-       void recordUndo(UndoKind kind, pit_type from) const;
+       void recordUndo(pit_type from) const;
 
        /// Convenience: prepare undo for the single paragraph or cell
        /// containing the cursor
        void recordUndo(UndoKind kind = ATOMIC_UNDO) const;
 
        /// Convenience: prepare undo for the inset containing the cursor
-       void recordUndoInset(UndoKind kind = ATOMIC_UNDO,
-                            Inset const * inset = 0) const;
+       void recordUndoInset(Inset const * inset = 0) const;
 
        /// Convenience: prepare undo for the whole buffer
-       void recordUndoFullDocument() const;
+       void recordUndoFullBuffer() const;
+
+       /// Convenience: prepare undo for buffer parameters
+       void recordUndoBufferParams() const;
 
        /// Convenience: prepare undo for the selected paragraphs or cells
        void recordUndoSelection() const;
@@ -534,10 +533,11 @@ public:
 
 
 /**
- * Notifies all insets which appear in old, but not in cur. And then
- * notify all insets which appear in cur, but not in old.
- * Make sure that the cursor old is valid, i.e. all inset pointers
- * point to valid insets! Use Cursor::fixIfBroken if necessary.
+ * Notifies all insets which appear in \c old, but not in \c cur. And then
+ * notify all insets which appear in \c cur, but not in \c old.
+ * \returns true if cursor is now invalid, e.g. if some insets in
+ *   higher cursor slices of \c old do not exist anymore. In this case
+ *   it may be necessary to use Use Cursor::fixIfBroken.
  */
 bool notifyCursorLeavesOrEnters(Cursor const & old, Cursor & cur);