#include "math_defs.h"
#include "math_inset.h"
+#include "math_pos.h"
#include "LString.h"
class InsetFormulaBase;
*/
-/// Description of a position
-class MathCursorPos {
-public:
- ///
- MathCursorPos();
- ///
- explicit MathCursorPos(MathInset * p);
-
- /// returns cell corresponding to this position
- MathArray & cell() const;
- /// returns cell corresponding to this position
- MathArray & cell(MathInset::idx_type idx) const;
- /// returns xcell corresponding to this position
- MathXArray & xcell() const;
- /// returns xcell corresponding to this position
- MathXArray & xcell(MathInset::idx_type idx) const;
- ///
- int xpos() const;
- ///
- int ypos() const;
-
-public:
- /// pointer to an inset
- MathInset * par_;
- /// cell index of a position in this inset
- MathInset::idx_type idx_;
- /// position in this cell
- MathInset::pos_type pos_;
-};
-
-/// test for equality
-bool operator==(MathCursorPos const &, MathCursorPos const &);
-/// test for inequality
-bool operator!=(MathCursorPos const &, MathCursorPos const &);
-/// test for order
-bool operator<(MathCursorPos const &, MathCursorPos const &);
-/// output
-std::ostream & operator<<(std::ostream &, MathCursorPos const &);
-
-
-/// see above
class MathCursor {
public:
/// short of anything else reasonable
void setPos(int x, int y);
/// in pixels from top of screen
void getPos(int & x, int & y);
- ///
+ /// current inset
MathInset * par() const;
/// return the next enclosing grid inset and the cursor's index in it
MathGridInset * enclosingGrid(idx_type &) const;
///
- InsetFormulaBase const * formula();
+ InsetFormulaBase * formula();
/// current offset in the current cell
pos_type pos() const;
/// current cell
/// size of current cell
size_type size() const;
///
+ bool script(bool);
+ ///
bool interpret(string const &);
///
bool interpret(char);
void breakLine();
/// read contents of line into an array
void readLine(MathArray & ar) const;
- ///
- MathTextCodes getLastCode() const;
+ /// remove this as soon as LyXFunc::getStatus is "localized"
+ MathTextCodes getLastCode() const { return lastcode_; }
///
void pullArg(bool goright);
///
///
char halign() const;
///
- col_type ncols() const;
+ col_type hullCol() const;
+ ///
+ row_type hullRow() const;
///
- col_type col() const;
+ col_type gridCol() const;
///
- row_type row() const;
+ row_type gridRow() const;
/// make sure cursor position is valid
- void normalize() const;
+ void normalize();
///
UpdatableInset * asHyperActiveInset() const;
/// path of positions the cursor had to go if it were leving each inset
cursor_type Cursor_;
/// path of positions the anchor had to go if it were leving each inset
- cursor_type Anchor_;
+ mutable cursor_type Anchor_;
/// reference to the last item of the path, i.e. "The Cursor"
MathCursorPos & cursor();
void dump(char const * str) const;
///
void stripFromLastEqualSign();
+ /// moves on
+ void setSelection(cursor_type const & where, size_type n);
///
friend class Selection;
bool idxLeft();
/// moves cursor index one cell to the right
bool idxRight();
- /// moves position somehow up
- bool goUp();
- /// moves position somehow down
- bool goDown();
- /// moves position somehow down
- bool bruteUpDown(int ylow, int yhigh);
+ /// moves position somehow up or down
+ bool goUpDown(bool up);
/// moves position into box
- bool bruteFind(int xlow, int xhigh, int ylow, int yhigh);
+ bool bruteFind(int xo, int yo, int xlow, int xhigh, int ylow, int yhigh);
///
string macroName() const;
///
- int macroNamePos() const;
+ MathInset::difference_type macroNamePos() const;
///
void insert(char, MathTextCodes t);
/// can we enter the inset?
bool openable(MathAtom const &, bool selection) const;
- /// can the setPos routine enter that inset?
- bool positionable(MathAtom const &, int x, int y) const;
/// write access to cursor cell position
pos_type & pos();
/// write access to cursor cell index
idx_type & idx();
///
- InsetFormulaBase * const formula_;
+ InsetFormulaBase * formula_;
///
MathTextCodes lastcode_;
// Selection stuff