4 * Purpose: Declaration of interaction classes for mathed
5 * Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
6 * Created: January 1996
7 * Description: MathCursor control all user interaction
9 * Dependencies: Xlib, XForms
11 * Copyright: 1996, Alejandro Aguilar Sierra
13 * You are free to use and modify this code under the terms of
14 * the GNU General Public Licence version 2 or later.
24 #include "math_defs.h"
28 class MathUpDownInset;
29 class InsetFormulaBase;
33 /// This is the external interface of Math's subkernel
37 explicit MathCursor(InsetFormulaBase *);
39 void insert(char, MathTextCodes t = LM_TC_MIN);
41 void insert(MathInset *);
47 bool Right(bool sel = false);
49 bool Left(bool sel = false);
51 bool Up(bool sel = false);
53 bool Down(bool sel = false);
54 /// Put the cursor in the first position
56 /// Put the cursor in the last position
66 /// This is in pixels from (maybe?) the top of inset
67 void SetPos(int, int);
69 void GetPos(int & x, int & y);
71 MathInset * par() const;
72 /// return the next enclosing par of the given type and the cursor's
74 MathInset * enclosing(MathInsetTypes, int &) const;
76 InsetFormulaBase const * formula();
80 void Interpret(string const &);
82 void SetSize(MathStyles);
89 void MacroModeClose();
91 bool InMacroMode() const;
93 // Local selection methods
95 bool Selection() const;
105 void SelHandle(bool);
111 void SelGetArea(int * xp, int * yp, int & n);
113 void clearLastCode();
115 void setLastCode(MathTextCodes t);
117 void handleFont(MathTextCodes t);
119 void handleAccent(string const & name, int code);
121 void handleDelim(int l, int r);
122 /// Splits cells and shifts right part to the next cell
124 /// Splits line and insert new row of cell
127 MathTextCodes getLastCode() const;
129 int idx() const { return cursor_.idx_; }
137 bool isInside(MathInset *) const;
139 MathTextCodes nextCode() const;
141 MathTextCodes prevCode() const;
156 /// do we currently select
160 InsetFormulaBase * const formula_;
162 MathTextCodes lastcode;
165 MathArray & array() const;
167 MathXArray & xarray() const;
170 MathStyles style() const;
171 /// Make sure cursor position is valid
172 void normalize() const;
174 /// Enter a new MathInset from the front or the back
175 void push(MathInset * par, bool first);
176 /// Leave current MathInset
180 /// Description of a position
190 /// path of positions the cursor had to go if it were leving each inset
191 std::vector<MathIter> path_;
193 /// reference to the last item of the path
204 MathInset * parInset(int i) const;
206 void seldump(char const * str) const;
208 void dump(char const * str) const;
216 bool nextIsInset() const;
218 bool prevIsInset() const;
220 void merge(MathArray const & arr);
222 MathInset * nextInset() const;
224 MathInset * prevInset() const;
226 MathUpDownInset * nearbyUpDownInset() const;
229 MathFuncInset * imacro;
232 extern MathCursor * mathcursor;