]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_cursor.h
use stream-like syntax for LaTeX output
[lyx.git] / src / mathed / math_cursor.h
index b59c376894384eeb0ae019c34f60706c6e4ea2ff..ce9c89cc970261000833ac97303cb28cebd89e36 100644 (file)
@@ -23,6 +23,7 @@
 
 #include "math_defs.h"
 #include "math_inset.h"
+#include "LString.h"
 
 class MathInset;
 class MathAtom;
@@ -35,18 +36,17 @@ class InsetFormulaBase;
 class MathArray;
 class MathXArray;
 class Painter;
+class Selection;
 class latexkeys;
 
 /// Description of a position 
 struct MathCursorPos {
        /// inset
-       MathInset * par_;
+       MathAtom * par_;
        /// cell index
        MathInset::idx_type idx_;
        /// cell position
        MathInset::pos_type pos_;
-       /// faked position "inside an atom"
-       bool inner_;
 
        /// returns cell corresponding to this position
        MathArray & cell() const;
@@ -56,9 +56,6 @@ struct MathCursorPos {
        MathXArray & xcell() const;
        /// returns xcell corresponding to this position
        MathXArray & xcell(MathInset::idx_type idx) const;
-
-       /// returns atom corresponding to this position
-       MathAtom * at() const;
 };
 
 /// 
@@ -82,12 +79,14 @@ public:
        typedef MathInset::col_type     col_type;
 
        ///
-       explicit MathCursor(InsetFormulaBase *);
+       explicit MathCursor(InsetFormulaBase *, bool left);
        ///
-       void insert(MathInset *);
+       void insert(MathAtom const &);
        ///
        void insert(MathArray const &);
        ///
+       void paste(MathArray const &);
+       ///
        void erase();
        ///
        void backspace();
@@ -114,9 +113,9 @@ public:
        ///
        void plainErase();
        ///
-       void plainInsert(MathInset * p);
+       void plainInsert(MathAtom const &);
        ///
-       void niceInsert(MathInset * p);
+       void niceInsert(MathAtom const &);
 
        ///
        void delLine();
@@ -125,14 +124,12 @@ public:
        ///
        void getPos(int & x, int & y);
        ///
-       MathInset * par() const;
+       MathAtom & par() const;
        /// return the next enclosing grid inset and the cursor's index in it
        MathArrayInset * enclosingArray(idx_type &) const;
        ///
        InsetFormulaBase const * formula();
        ///
-       bool inner() const;
-       ///
        pos_type pos() const;
        ///
        idx_type idx() const;
@@ -141,6 +138,8 @@ public:
        ///
        void interpret(string const &);
        ///
+       void interpret(char);
+       ///
        void setSize(MathStyles);
        ///
        bool toggleLimits();
@@ -200,11 +199,13 @@ public:
        MathStyles style() const;
        /// Make sure cursor position is valid
        void normalize() const;
-       
+
+       /// enter a MathInset 
+       void push(MathAtom & par);
        /// enter a MathInset from the front
-       void pushLeft(MathInset * par);
+       void pushLeft(MathAtom & par);
        /// enter a MathInset from the back
-       void pushRight(MathInset * par);
+       void pushRight(MathAtom & par);
        /// leave current MathInset to the left
        bool popLeft();
        /// leave current MathInset to the left
@@ -215,13 +216,17 @@ public:
        ///
        MathXArray & xarray() const;
        ///
-       MathAtom const * prevAtom() const;
+       bool hasPrevAtom() const;
+       ///
+       bool hasNextAtom() const;
+       ///
+       MathAtom const & prevAtom() const;
        ///
-       MathAtom * prevAtom();
+       MathAtom & prevAtom();
        ///
-       MathAtom const * nextAtom() const;
+       MathAtom const & nextAtom() const;
        ///
-       MathAtom * nextAtom();
+       MathAtom & nextAtom();
 
        /// returns the selection
        void getSelection(MathCursorPos &, MathCursorPos &) const;
@@ -238,26 +243,13 @@ public:
        ///
        MathCursorPos const & cursor() const;
 
-
-       ///  
-       pos_type last() const;
-       ///
-       MathMatrixInset * outerPar() const;
        ///
        void seldump(char const * str) const;
        ///
        void dump(char const * str) const;
 
        ///
-       void merge(MathArray const & arr);
-       ///
-       MathInset * nextInset() const;
-       ///
-       MathInset * prevInset() const;
-       ///
-       MathScriptInset * prevScriptInset() const;
-       ///
-       MathSpaceInset * prevSpaceInset() const;
+       friend class Selection;
 
 private:
        /// moves cursor position one cell to the left
@@ -272,19 +264,17 @@ private:
        bool goUp();
        /// moves position somehow down
        bool goDown();
-       /// glue adjacent atoms if possible
-       void glueAdjacentAtoms();
 
        ///
        string macroName() const;
        ///
+       int macroNamePos() const;
+       ///
        void insert(char, MathTextCodes t);
        /// can we enter the inset? 
-       bool openable(MathInset *, bool selection) const;
+       bool openable(MathAtom const &, bool selection) const;
        /// can the setPos routine enter that inset?
-       MathInset * positionable(MathAtom *, int x, int y) const;
-       /// write access to "inner" flag
-       bool & inner();
+       bool positionable(MathAtom const &, int x, int y) const;
        /// write access to cursor cell position
        pos_type & pos();
        /// write access to cursor cell index