]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_cursor.h
fix cursor positioning using the mouse
[lyx.git] / src / mathed / math_cursor.h
index 6404f494279a1d34f010bb962ad42cce4cf58593..34f93337891f9851ef2ed385b9fc0977e621b927 100644 (file)
@@ -24,6 +24,7 @@
 #include "math_defs.h"
 
 class MathInset;
+class MathAtom;
 class MathArrayInset;
 class MathFuncInset;
 class MathMatrixInset;
@@ -33,6 +34,7 @@ class InsetFormulaBase;
 class MathArray;
 class MathXArray;
 class Painter;
+class latexkeys;
 
 /// Description of a position 
 struct MathCursorPos {
@@ -64,10 +66,6 @@ public:
        ///
        explicit MathCursor(InsetFormulaBase *);
        ///
-       ~MathCursor();
-       ///
-       void insert(char, MathTextCodes t = LM_TC_MIN);
-       ///
        void insert(MathInset *);
        ///
        void insert(MathArray const &);
@@ -76,9 +74,9 @@ public:
        ///
        void backspace();
        ///
-       void home();
+       void home(bool sel = false);
        ///
-       void end();
+       void end(bool sel = false);
        ///
        bool right(bool sel = false);
        ///
@@ -91,18 +89,18 @@ public:
        void first();
        /// Put the cursor in the last position
        void last();
-       ///
+       /// moves cursor position one cell to the left
        bool posLeft();
-       ///
+       /// moves cursor position one cell to the right
        bool posRight();
-       /// moves position one cell to the left
+       /// moves cursor index one cell to the left
        bool idxLeft();
-       /// moves position one cell to the right
+       /// moves cursor index one cell to the right
        bool idxRight();
-       /// moves position one cell up
-       bool idxUp();
-       /// moves position one cell down
-       bool idxDown();
+       /// moves position somehow up
+       bool goUp();
+       /// moves position somehow down
+       bool goDown();
        ///
        void idxNext();
        ///
@@ -112,6 +110,8 @@ public:
        ///
        void plainInsert(MathInset * p);
        ///
+       void niceInsert(MathInset * p);
+       ///
        void delLine();
        /// This is in pixels from (maybe?) the top of inset
        void setPos(int, int);
@@ -137,8 +137,6 @@ public:
        bool toggleLimits();
        ///
        // Macro mode methods
-       void macroModeOpen();
-       ///
        void macroModeClose();
        ///
        bool inMacroMode() const;
@@ -163,15 +161,9 @@ public:
        ///
        void drawSelection(Painter & pain) const;
        ///
-       void clearLastCode();
-       ///
-       void setLastCode(MathTextCodes t);
-       ///
        void handleFont(MathTextCodes t);
        ///
-       void handleAccent(string const & name);
-       ///
-       void handleDelim(int l, int r);
+       void handleDelim(latexkeys const * l, latexkeys const * r);
        ///
        void handleNest(MathInset * p);
        /// Splits cells and shifts right part to the next cell
@@ -187,8 +179,6 @@ public:
        ///
        MathTextCodes nextCode() const;
        ///
-       MathTextCodes prevCode() const;
-       ///
        char valign() const;
        ///
        char halign() const;
@@ -215,13 +205,19 @@ public:
        MathArray & array() const;
        ///
        MathXArray & xarray() const;
+       ///
+       MathAtom const * prevAtom() const;
+       ///
+       MathAtom * prevAtom();
+       ///
+       MathAtom const * nextAtom() const;
+       ///
+       MathAtom * nextAtom();
 
        /// returns the selection
        void getSelection(MathCursorPos &, MathCursorPos &) const;
        /// returns the normalized anchor of the selection
        MathCursorPos normalAnchor() const;
-       /// returns the normalized anchor of the selection
-       bool openable(MathInset *, bool selection, bool useupdown) const;
 
        /// path of positions the cursor had to go if it were leving each inset
        std::vector<MathCursorPos> Cursor_;
@@ -245,11 +241,6 @@ public:
        ///
        void dump(char const * str) const;
 
-       ///
-       int xpos() const;
-       ///
-       void gotoX(int x);
-
        ///
        void merge(MathArray const & arr);
        ///
@@ -262,16 +253,32 @@ public:
        MathSpaceInset * prevSpaceInset() const;
 private:
        ///
-       int & pos();
+       string macroName() const;
        ///
+       void insert(char, MathTextCodes t = LM_TC_MIN);
+       /// can we enter the inset? 
+       bool openable(MathInset *, bool selection) const;
+       /// can the setPos routine enter that inset?
+       MathInset * positionable(MathAtom *, int x, int y) const;
+       /// write access to cursor cell position
+       int & pos();
+       /// write access to cursor cell index
        int & idx();
+       /// x-offset of current cell relative to par xo
+       int cellXOffset() const;
+       /// y-offset of current cell relative to par yo
+       int cellYOffset() const;
+       /// current x position relative to par xo
+       int xpos() const;
+       /// current y position relative to par yo
+       int ypos() const;
+       /// adjust position in current cell according to x. idx is not changed.
+       void gotoX(int x);
 
        ///
        InsetFormulaBase * const formula_;
        ///
        MathTextCodes lastcode_;
-       ///
-       MathFuncInset * imacro_;
        // Selection stuff
        /// do we currently select
        bool selection_;