4 * Purpose: Math editor definitions
5 * Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
6 * Created: January 1996
7 * Description: Math paragraph and objects for a WYSIWYG math editor.
11 * Copyright: 1996, 1997 Alejandro Aguilar Sierra
13 * Version: 0.8beta, Mathed & Lyx project.
15 * You are free to use and modify this code under the terms of
16 * the GNU General Public Licence version 2 or later.
38 #define byte unsigned char
48 MATH_ALIGN_BOTTOM = 4,
53 static int const MATH_COLSEP = 8;
55 static int const MATH_ROWSEP = 8;
58 /// Standard Math Sizes (Math mode styles)
71 /** The restrictions of a standard LaTeX math paragraph
72 allows to get a small number of text codes (<30) */
73 enum MathedTextCodes {
76 /// Open and Close group
86 /// Super and sub scripts
90 /// Editable Math Inset
92 /// Editable Text Inset
96 /// Internal code for constants
98 /// Internal code for variables
114 /// Math mode TeX characters ",;:{}"
116 /// Special characters "{}&#_%"
118 /// Internal code for operators
120 /// Internal code for symbols
129 /// This must be < 32
134 std::ostream & operator<<(std::ostream &, MathedTextCodes mtc);
137 #define LM_TC_NORMAL LM_TC_VAR
140 /// Types of lyx-math insets
141 enum MathedInsetTypes {
144 /// A simple paragraph
146 /// A simple numbered paragraph
148 /// A multiline paragraph
150 /// A multiline numbered paragraph
204 enum MathedBinaryTypes {
212 LMB_BOP = (LMB_RELATION | LMB_OPERATOR)
218 /// Paragraph permissions
221 /// If false can use a non-standard size
223 /// If true can insert newlines
225 /// If true can use tabs
227 /// If true can insert new columns
228 LMPF_ALLOW_NEW_COL = 8,
229 /// Smaller than current size (frac)
231 /// Script size (subscript, stackrel)
239 /************************* Prototypes **********************************/
241 MathedArray * mathed_parse(unsigned flags, MathedArray * data,
244 void mathed_write(MathParInset *, std::ostream &, int *, bool fragile,
245 string const & label = string());
248 void mathed_parser_file(std::istream &, int);
250 int mathed_parser_lineno();
252 int MathedLookupBOP(short);
254 /************************ Inline functions ********************************/
258 bool MathIsInset(short x)
260 return LM_TC_INSET <= x && x <= LM_TC_ACTIVE_INSET;
265 bool MathIsFont(short x)
267 return LM_TC_CONST <= x && x <= LM_TC_BSYM;
272 bool MathIsAlphaFont(short x)
274 return LM_TC_VAR <= x && x <= LM_TC_TEXTRM;
279 bool MathIsActive(short x)
281 return LM_TC_INSET < x && x <= LM_TC_ACTIVE_INSET;
286 bool MathIsUp(short x)
288 return x == LM_TC_UP;
293 bool MathIsDown(short x)
295 return x == LM_TC_DOWN;
300 bool MathIsScript(short x)
302 return x == LM_TC_DOWN || x == LM_TC_UP;
307 bool MathIsBOPS(short x)
309 return MathedLookupBOP(x) > LMB_NONE;
314 bool MathIsBinary(short x)
316 return x == LM_TC_BOP || x == LM_TC_BOPS;
321 bool MathIsSymbol(short x) {
322 return LM_TC_SYMB <= x && x <= LM_TC_BSYM;
327 bool is_eqn_type(short int type)
329 return type >= LM_OT_MIN && type < LM_OT_MATRIX;
334 bool is_matrix_type(short int type)
336 return type == LM_OT_MATRIX;
340 bool is_multiline(short int type)
342 return type >= LM_OT_MPAR && type < LM_OT_MATRIX;
346 inline bool is_ams(short int type)
348 return type > LM_OT_MPARN && type < LM_OT_MATRIX;
352 bool is_singlely_numbered(short int type)
354 return type == LM_OT_PARN || type == LM_OT_MULTLINEN;
358 bool is_multi_numbered(short int type)
360 return type == LM_OT_MPARN || type == LM_OT_ALIGNN
361 || type == LM_OT_ALIGNATN;
365 bool is_numbered(short int type)
367 return is_singlely_numbered(type) || is_multi_numbered(type);
371 bool is_multicolumn(short int type)
373 return type == LM_OT_ALIGN || type == LM_OT_ALIGNN
374 || type == LM_OT_ALIGNAT || type == LM_OT_ALIGNATN;