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
64 /// This is in pixels from (maybe?) the top of inset
65 void SetPos(int, int);
67 void GetPos(int & x, int & y);
69 MathInset * par() const;
70 /// return the next enclosing par of the given type and the cursor's
72 MathInset * enclosing(MathInsetTypes, int &) const;
74 InsetFormulaBase const * formula();
78 void Interpret(string const &);
80 void SetSize(MathStyles);
87 void MacroModeClose();
89 bool InMacroMode() const;
91 // Local selection methods
93 bool Selection() const;
103 void SelHandle(bool);
109 void SelGetArea(int * xp, int * yp, int & n);
111 void clearLastCode();
113 void setLastCode(MathTextCodes t);
115 void handleFont(MathTextCodes t);
117 void handleAccent(string const & name, int code);
119 void handleDelim(int l, int r);
120 /// Splits cells and shifts right part to the next cell
122 /// Splits line and insert new row of cell
125 MathTextCodes getLastCode() const;
127 int idx() const { return idx_; }
135 bool isInside(MathInset *) const;
137 MathTextCodes nextCode() const;
139 MathTextCodes prevCode() const;
165 InsetFormulaBase * const formula_;
167 MathTextCodes lastcode;
170 MathArray & array() const;
172 MathXArray & xarray() const;
175 MathStyles style() const;
176 /// Make sure cursor position is valid
177 void normalize() const;
179 /// Enter a new MathInset from the front or the back
180 void push(MathInset * par, bool first);
181 /// Leave current MathInset
185 /// Description of a position
193 std::vector<MathIter> path_;
198 MathInset * parInset(int i) const;
200 void seldump(char const * str) const;
202 void dump(char const * str) const;
210 bool nextIsInset() const;
212 bool prevIsInset() const;
214 void merge(MathArray const & arr);
216 MathInset * nextInset() const;
218 MathInset * prevInset() const;
220 MathUpDownInset * nearbyUpDownInset() const;
223 MathFuncInset * imacro;
226 extern MathCursor * mathcursor;