X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FCursor.h;h=d84db92b409826f9f1508d1409d25e09014ac5b6;hb=90f7007a2e6c78ffd031e4636ff909ab1bc2ddec;hp=0d7441967866c2635fd9d6eea34a83355127f35c;hpb=210a440609df23bf48ca1b469cbead7e445e8b6d;p=lyx.git diff --git a/src/Cursor.h b/src/Cursor.h index 0d74419678..d84db92b40 100644 --- a/src/Cursor.h +++ b/src/Cursor.h @@ -34,9 +34,59 @@ class Row; class InsetMathUnknown; class Encoding; +/** + * This class describes the position of a cursor within a document, + * but does not contain any detail about the view. It is currently + * only used to save cursor position in Undo, but culd be extended to + * handle the methods that only need this data. + **/ +class CursorData : public DocIterator +{ +public: + /// + CursorData(); + /// + explicit CursorData(Buffer * buffer); + /// + explicit CursorData(DocIterator const & dit); +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: + /// the current font settings + Font current_font; + /// the current font + Font real_current_font; + +protected: + + // + // math specific stuff that could be promoted to "global" later + // + /// do we allow autocorrection + bool autocorrect_; + /// are we entering a macro name? + bool macromode_; +}; + /// The cursor class describes the position of a cursor within a document. -class Cursor : public DocIterator +class Cursor : public CursorData { public: /// create the cursor of a BufferView @@ -60,6 +110,8 @@ public: bool popForward(); /// make sure we are outside of given inset void leaveInset(Inset const & inset); + /// set the cursor data + void setCursorData(CursorData const & data); /// sets cursor part void setCursor(DocIterator const & it); /// sets the cursor to the normalized selection anchor @@ -252,6 +304,9 @@ public: /// fix cursor in circumstances that should never happen. /// \retval true if a fix occured. 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); @@ -320,10 +375,6 @@ private: private: /// BufferView * bv_; - /// the anchor position - DocIterator anchor_; - /// the start of the new born word - DocIterator new_word_; /// mutable DispatchResult disp_; /** @@ -341,42 +392,14 @@ private: int x_target_; /// if a x_target cannot be hit exactly in a text, put the difference here int textTargetOffset_; - /// 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_; + /// the start of the new born word + DocIterator new_word_; /// position before dispatch started DocIterator beforeDispatchCursor_; /// cursor screen coordinates before dispatch started int beforeDispatchPosX_; int beforeDispatchPosY_; - -// FIXME: make them private. -public: - /// the current font settings - Font current_font; - /// the current font - Font real_current_font; - -private: - - // - // math specific stuff that could be promoted to "global" later - // - /// do we allow autocorrection - bool autocorrect_; - /// are we entering a macro name? - bool macromode_; - - /////////////////////////////////////////////////////////////////// // // The part below is the non-integrated rest of the original math