X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmathed%2Fmath_cursor.h;h=90519bec17aa0cd1327c11cf083eac80e7adf45b;hb=aea21e8cacad73e0d5df58637994b87b3eabc30e;hp=8b796cc82a6168ad308c62a0d16203d48c1462c4;hpb=50ea0354bd72ba454eeda41df968a7df380ed7ce;p=lyx.git diff --git a/src/mathed/math_cursor.h b/src/mathed/math_cursor.h index 8b796cc82a..90519bec17 100644 --- a/src/mathed/math_cursor.h +++ b/src/mathed/math_cursor.h @@ -24,13 +24,16 @@ #include "math_defs.h" class MathInset; +class MathArrayInset; class MathFuncInset; +class MathMatrixInset; class MathScriptInset; class MathSpaceInset; class InsetFormulaBase; class MathArray; class MathXArray; class Painter; +class latexkeys; /// Description of a position struct MathCursorPos { @@ -48,14 +51,6 @@ struct MathCursorPos { MathXArray & xcell() const; /// returns xcell corresponding to this position MathXArray & xcell(int idx) const; - /// moves position on cell to the left - bool idxLeft(); - /// moves position on cell to the right - bool idxRight(); - /// moves position on cell up - bool idxUp(); - /// moves position on cell up - bool idxDown(); }; /// @@ -70,14 +65,14 @@ public: /// explicit MathCursor(InsetFormulaBase *); /// - void insert(char, MathTextCodes t = LM_TC_MIN); - /// void insert(MathInset *); /// void insert(MathArray const &); /// void erase(); /// + void backspace(); + /// void home(); /// void end(); @@ -93,13 +88,29 @@ 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 cursor index one cell to the left + bool idxLeft(); + /// moves cursor index one cell to the right + bool idxRight(); + /// moves position somehow up + bool goUp(); + /// moves position somehow down + bool goDown(); /// - bool plainLeft(); + void idxNext(); /// - bool plainRight(); + void idxPrev(); /// void plainErase(); /// + void plainInsert(MathInset * p); + /// + void niceInsert(MathInset * p); + /// void delLine(); /// This is in pixels from (maybe?) the top of inset void setPos(int, int); @@ -107,14 +118,17 @@ public: void getPos(int & x, int & y); /// MathInset * par() const; - /// return the next enclosing par of the given type and the cursor's - //index in it - MathInset * enclosing(MathInsetTypes, int &) const; + /// return the next enclosing grid inset and the cursor's index in it + MathArrayInset * enclosingArray(int &) const; /// InsetFormulaBase const * formula(); /// int pos() const; /// + int idx() const; + /// + int size() const; + /// void interpret(string const &); /// void setSize(MathStyles); @@ -122,8 +136,6 @@ public: bool toggleLimits(); /// // Macro mode methods - void macroModeOpen(); - /// void macroModeClose(); /// bool inMacroMode() const; @@ -148,15 +160,11 @@ public: /// void drawSelection(Painter & pain) const; /// - void clearLastCode(); - /// - void setLastCode(MathTextCodes t); - /// void handleFont(MathTextCodes t); /// - void handleAccent(string const & name, int code); + void handleDelim(latexkeys const * l, latexkeys const * r); /// - void handleDelim(int l, int r); + void handleNest(MathInset * p); /// Splits cells and shifts right part to the next cell void splitCell(); /// Splits line and insert new row of cell @@ -164,20 +172,12 @@ public: /// MathTextCodes getLastCode() const; /// - int idx() const { return cursor().idx_; } - /// - void idxNext(); - /// - void idxPrev(); - /// void pullArg(bool goright); /// - bool isInside(MathInset *) const; + bool isInside(MathInset const *) const; /// MathTextCodes nextCode() const; /// - MathTextCodes prevCode() const; - /// char valign() const; /// char halign() const; @@ -191,37 +191,24 @@ public: /// Make sure cursor position is valid void normalize() const; - /// Enter a new MathInset from the front or the back - void push(MathInset * par, bool first); - /// Leave current MathInset - bool pop(); - -//private: - /// - InsetFormulaBase * const formula_; - /// - MathTextCodes lastcode_; - /// - MathFuncInset * imacro_; - // Selection stuff - /// do we currently select - bool selection_; + /// enter a MathInset from the front + void pushLeft(MathInset * par); + /// enter a MathInset from the back + void pushRight(MathInset * par); + /// leave current MathInset to the left + bool popLeft(); + /// leave current MathInset to the left + bool popRight(); /// MathArray & array() const; /// MathXArray & xarray() const; - /// returns the first position of the (normalized) selection - MathCursorPos firstSelectionPos() const; - /// returns the last position of the (normalized) selection - MathCursorPos lastSelectionPos() const; /// 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 Cursor_; @@ -239,19 +226,12 @@ public: /// MathInset * parInset(int i) const; /// + MathMatrixInset * outerPar() const; + /// void seldump(char const * str) const; /// void dump(char const * str) const; - /// - int xpos() const; - /// - void gotoX(int x); - - /// - bool nextIsInset() const; - /// - bool prevIsInset() const; /// void merge(MathArray const & arr); /// @@ -262,6 +242,37 @@ public: MathScriptInset * prevScriptInset() const; /// MathSpaceInset * prevSpaceInset() const; +private: + /// + 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? + bool positionable(MathInset *, bool selection) 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_; + // Selection stuff + /// do we currently select + bool selection_; }; extern MathCursor * mathcursor;