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 MathScriptInset;
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);
83 /// Set accent: if argument = 0 it's considered consumed
84 void setAccent(int ac = 0);
85 /// Returns last accent
86 int getAccent() const;
91 void MacroModeClose();
93 bool InMacroMode() const;
95 // Local selection methods
97 bool Selection() const;
107 void SelHandle(bool);
113 void SelGetArea(int * xp, int * yp, int & n);
115 void clearLastCode();
117 void setLastCode(MathTextCodes t);
119 void handleFont(MathTextCodes t);
121 MathTextCodes getLastCode() const;
123 int idx() const { return idx_; }
129 bool isInside(MathInset *) const;
131 MathTextCodes nextCode() const;
133 MathTextCodes prevCode() const;
135 void selArray(MathArray &) const;
161 InsetFormulaBase * const formula_;
163 void doAccent(char c, MathTextCodes t);
165 void doAccent(MathInset * p);
171 MathTextCodes lastcode;
174 MathArray & array() const;
176 MathXArray & xarray() const;
179 MathStyles style() const;
180 /// Make sure cursor position is valid
181 void normalize() const;
183 /// Enter a new MathInset from the front or the back
184 void push(MathInset * par, bool first);
185 /// Leave current MathInset
189 /// Description of a position
197 std::vector<MathIter> path_;
202 MathInset * parInset(int i) const;
204 void seldump(char const * str) const;
206 void dump(char const * str) const;
214 bool nextIsInset() const;
216 bool nextIsActive() const;
218 bool prevIsInset() const;
220 bool prevIsActive() const;
224 bool IsScript() const;
226 void merge(MathArray const & arr);
228 MathInset * nextInset() const;
230 MathInset * nextActiveInset() const;
232 MathInset * prevInset() const;
234 MathInset * prevActiveInset() const;
236 MathScriptInset * nearbyScriptInset() const;
239 MathFuncInset * imacro;
242 extern MathCursor * mathcursor;