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);
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;
141 void selArray(MathArray &) const;
167 InsetFormulaBase * const formula_;
169 void doAccent(char c, MathTextCodes t);
171 void doAccent(MathInset * p);
177 MathTextCodes lastcode;
180 MathArray & array() const;
182 MathXArray & xarray() const;
185 MathStyles style() const;
186 /// Make sure cursor position is valid
187 void normalize() const;
189 /// Enter a new MathInset from the front or the back
190 void push(MathInset * par, bool first);
191 /// Leave current MathInset
195 /// Description of a position
203 std::vector<MathIter> path_;
208 MathInset * parInset(int i) const;
210 void seldump(char const * str) const;
212 void dump(char const * str) const;
220 bool nextIsInset() const;
222 bool prevIsInset() const;
226 bool IsScript() const;
228 void merge(MathArray const & arr);
230 MathInset * nextInset() const;
232 MathInset * prevInset() const;
234 MathScriptInset * nearbyScriptInset() const;
237 MathFuncInset * imacro;
240 extern MathCursor * mathcursor;