2001-02-13 Lars Gullik Bjønnes <larsbj@lyx.org>
+ * math_spaceinset.C (GetSpace): move here
+
+ * math_parinset.C: add debug.h, move several prev. inlined methods
+ here.
+
+ * math_macrotable.C math_xiter.C support.C: add debug.h
+
+ * math_macro.h: remove debug.h, remove typedefs
+
+ * math_macro.C: remove FORMS_H_LOCATION, and LString.h, remove
+ extern decls.
+
+ * math_hash.C: change some defines to int const. change use of
+ LM_TC_NORMAL to LM_TC_VAR
+
+ * math_draw.C: delete file
+
+ * math_defs.h (MATH_DEFS): dont define byte here, remove unneded
+ forward decls. remove LM_TC_NORMAL, move inline methods to
+ support.C (and support.h)
+
+ * math_cursor.C: move several previous inlined methods here
+
+ * math_bigopinset.h math_dotsinset.h math_funcinset.h
+ math_parinset.h math_spaceinset.h: add math_defs.h
+
+ * math_accentinset.h: add support.h and math_defs.h
+
+ * formulamacro.C math_cursor.C math_iter.h math_write.C: add support.h
+
+ * formula.h: remove unused func decl: OpenMathInset
+
+ * formula.C math_inset.h: get rid of math_defs.h
+
+ * array.h: switch to support.h instead of math_defs.h
+
+ * array.C: remove one include
+
+ * Makefile.am (libmathed_la_SOURCES): remove math_draw.C
+
+ * math_panel.C (deco_cb): move the sizeof/sizeof to a const int.
+
* math_parser.C: include macrotable and macrotemplate
* math_macrotemplate.[Ch]: new files
math_deliminset.h \
math_dotsinset.C \
math_dotsinset.h \
- math_draw.C \
math_forms.C \
math_forms.h \
math_fracinset.C \
#endif
#include "array.h"
-#include "math_defs.h"
-
// Is this still needed? (Lgb)
static inline
#include <vector>
-#include "math_defs.h"
+#include "mathed/support.h"
class MathedInset;
#include "font.h"
#include "support/lyxlib.h"
#include "lyxrc.h"
-#include "math_defs.h"
#include "math_inset.h"
#include "math_parinset.h"
#include "math_matrixinset.h"
#include "math_rowst.h"
#include "math_spaceinset.h"
#include "math_deliminset.h"
-#include "support.h"
+#include "mathed/support.h"
using std::ostream;
using std::istream;
///
string label;
};
-
-
-// If a mathinset exist at cursor pos, just lock it.
-// Otherwise create a new one, and lock it.
-bool OpenMathInset(Buffer *);
-
#endif
#include "Painter.h"
#include "font.h"
#include "support/lyxlib.h"
+#include "mathed/support.h"
using std::ostream;
using std::istream;
#include <config.h>
#include "math_accentinset.h"
-#include "support.h"
+#include "mathed/support.h"
#include "math_parser.h"
#define MATH_ACCENTINSET_H
#include "math_inset.h"
+#include "mathed/support.h"
+#include "math_defs.h"
/// Accents
class MathAccentInset: public MathedInset {
#define MATH_BIGOPINSET_H
#include "math_inset.h"
+#include "math_defs.h"
/// big operators
class MathBigopInset: public MathedInset {
#include "math_decorationinset.h"
#include "math_dotsinset.h"
#include "math_accentinset.h"
+#include "mathed/support.h"
static MathedArray * selarray = 0;
return mt;
}
+
void MathedCursor::Insert(byte c, MathedTextCodes t)
{
if (selection) SelDel();
else
lastcode = t;
}
+
+
+void MathedCursor::GetPos(int & x, int & y)
+{
+ cursor->GetPos(x, y);
+}
+
+
+short MathedCursor::GetFCode()
+{
+ return cursor->FCode();
+}
+
+
+MathParInset * MathedCursor::GetPar()
+{
+ return par;
+}
+
+
+MathParInset * MathedCursor::getCurrentPar() const
+{
+ return cursor->p;
+}
+
+
+string const & MathedCursor::getLabel() const
+{
+ return cursor->getLabel();
+}
+
+
+bool MathedCursor::IsEnd() const
+{
+ return !cursor->OK();
+}
+
+
+bool MathedCursor::InMacroMode()
+{
+ return macro_mode;
+}
+
+
+bool MathedCursor::Selection()
+{
+ return selection;
+}
+
+
+void MathedCursor::clearLastCode()
+{
+ lastcode = LM_TC_MIN;
+}
+
+
+void MathedCursor::setLastCode(MathedTextCodes t)
+{
+ lastcode = t;
+}
+
+
+MathedTextCodes MathedCursor::getLastCode() const
+{
+ return lastcode;
+}
#pragma interface
#endif
-#include "math_iter.h"
-//#include "math_inset.h"
#include "math_xiter.h"
class MathFuncInset;
+class MathParInset;
+class Painter;
/// This is the external interface of Mathed's subkernel
///
void SetPos(int, int);
///
- void GetPos(int & x, int & y) { cursor->GetPos(x, y); }
+ void GetPos(int & x, int & y);
///
- short GetFCode() { return cursor->FCode(); }
+ short GetFCode();
///
- MathParInset * GetPar() { return par; }
+ MathParInset * GetPar();
///
- MathParInset * getCurrentPar() const { return cursor->p; }
+ MathParInset * getCurrentPar() const;
///
void SetPar(MathParInset *);
///
///
void setLabel(string const &);
///
- string const & getLabel() const {
- return cursor->getLabel();
- }
+ string const & getLabel() const;
///
bool Limits();
/// Set accent: if argument = 0 it's considered consumed
/// Returns last accent
int getAccent() const;
///
- bool IsEnd() const { return !cursor->OK(); }
+ bool IsEnd() const;
// Macro mode methods
///
void MacroModeOpen();
///
void MacroModeClose();
///
- bool InMacroMode() { return macro_mode; }
+ bool InMacroMode();
// Local selection methods
///
- bool Selection() { return selection; }
+ bool Selection();
///
void SelCopy();
///
///
void SelGetArea(int ** xp, int ** yp, int & n);
///
- void clearLastCode() { lastcode = LM_TC_MIN; }
+ void clearLastCode();
///
- void setLastCode(MathedTextCodes t) { lastcode = t; }
+ void setLastCode(MathedTextCodes t);
///
void toggleLastCode(MathedTextCodes t);
///
- MathedTextCodes getLastCode() const { return lastcode; }
+ MathedTextCodes getLastCode() const;
protected:
///
#include <iosfwd>
#include "LString.h"
-#include "debug.h"
-
-//#include "array.h"
-
-class MathedArray;
-class Painter;
-
-#ifndef byte
-#define byte unsigned char
-#endif
///
enum math_align {
///
std::ostream & operator<<(std::ostream &, MathedTextCodes mtc);
-///
-#define LM_TC_NORMAL LM_TC_VAR
-
-
+
/// Types of lyx-math insets
enum MathedInsetTypes {
///
LM_OT_MAX
};
+
///
enum MathedBinaryTypes {
///
LMB_BOP = (LMB_RELATION | LMB_OPERATOR)
};
-class MathParInset;
-
/// Paragraph permissions
enum MathedParFlag {
LMPF_SCRIPT = 32
};
-
-
-
-
-/************************* Prototypes **********************************/
-///
-MathedArray * mathed_parse(unsigned flags, MathedArray * data,
- MathParInset ** mt);
-///
-void mathed_write(MathParInset *, std::ostream &, int *, bool fragile,
- string const & label = string());
-
-///
-void mathed_parser_file(std::istream &, int);
-///
-int mathed_parser_lineno();
-///
-int MathedLookupBOP(short);
-
-/************************ Inline functions ********************************/
-
-///
-inline
-bool MathIsInset(short x)
-{
- return LM_TC_INSET <= x && x <= LM_TC_ACTIVE_INSET;
-}
-
-///
-inline
-bool MathIsFont(short x)
-{
- return LM_TC_CONST <= x && x <= LM_TC_BSYM;
-}
-
-///
-inline
-bool MathIsAlphaFont(short x)
-{
- return LM_TC_VAR <= x && x <= LM_TC_TEXTRM;
-}
-
-///
-inline
-bool MathIsActive(short x)
-{
- return LM_TC_INSET < x && x <= LM_TC_ACTIVE_INSET;
-}
-
-///
-inline
-bool MathIsUp(short x)
-{
- return x == LM_TC_UP;
-}
-
-///
-inline
-bool MathIsDown(short x)
-{
- return x == LM_TC_DOWN;
-}
-
-///
-inline
-bool MathIsScript(short x)
-{
- return x == LM_TC_DOWN || x == LM_TC_UP;
-}
-
-///
-inline
-bool MathIsBOPS(short x)
-{
- return MathedLookupBOP(x) > LMB_NONE;
-}
-
-///
-inline
-bool MathIsBinary(short x)
-{
- return x == LM_TC_BOP || x == LM_TC_BOPS;
-}
-
-///
-inline
-bool MathIsSymbol(short x) {
- return LM_TC_SYMB <= x && x <= LM_TC_BSYM;
-}
-
-
-inline
-bool is_eqn_type(short int type)
-{
- return type >= LM_OT_MIN && type < LM_OT_MATRIX;
-}
-
-
-inline
-bool is_matrix_type(short int type)
-{
- return type == LM_OT_MATRIX;
-}
-
-inline
-bool is_multiline(short int type)
-{
- return type >= LM_OT_MPAR && type < LM_OT_MATRIX;
-}
-
-
-inline bool is_ams(short int type)
-{
- return type > LM_OT_MPARN && type < LM_OT_MATRIX;
-}
-
-inline
-bool is_singlely_numbered(short int type)
-{
- return type == LM_OT_PARN || type == LM_OT_MULTLINEN;
-}
-
-inline
-bool is_multi_numbered(short int type)
-{
- return type == LM_OT_MPARN || type == LM_OT_ALIGNN
- || type == LM_OT_ALIGNATN;
-}
-
-inline
-bool is_numbered(short int type)
-{
- return is_singlely_numbered(type) || is_multi_numbered(type);
-}
-
-inline
-bool is_multicolumn(short int type)
-{
- return type == LM_OT_ALIGN || type == LM_OT_ALIGNN
- || type == LM_OT_ALIGNAT || type == LM_OT_ALIGNATN;
-}
-
#endif
#define MATH_DOTSINSET_H
#include "math_inset.h"
+#include "math_defs.h"
///
class MathDotsInset: public MathedInset {
using std::endl;
-extern LyXFont const mathed_get_font(short type, int size);
-extern int mathed_char_width(short type, int style, byte c);
-extern int mathed_string_width(short type, int style, string const &);
-extern int mathed_string_height(short, int, string const &, int &, int &);
-extern int mathed_char_height(short, int, byte, int &, int &);
+//extern LyXFont const mathed_get_font(short type, int size);
+//extern int mathed_char_width(short type, int style, byte c);
+//extern int mathed_string_width(short type, int style, string const &);
+//extern int mathed_string_height(short, int, string const &, int &, int &);
+//extern int mathed_char_height(short, int, byte, int &, int &);
#define MATH_FUNCINSET_H
#include "math_inset.h"
+#include "math_defs.h"
/**
Functions or LaTeX names for objects that I don't know how to draw.
#include "math_defs.h"
#include "math_parser.h"
-//struct latexkeys { char* name; short token; int id; };
+#if 0
#define TOTAL_KEYWORDS 269
#define MIN_WORD_LENGTH 2
#define MAX_WORD_LENGTH 18
#define MIN_HASH_VALUE 8
#define MAX_HASH_VALUE 490
+#else
+int const TOTAL_KEYWORDS = 269;
+int const MIN_WORD_LENGTH = 2;
+int const MAX_WORD_LENGTH = 18;
+int const MIN_HASH_VALUE = 8;
+int const MAX_HASH_VALUE = 490;
+#endif
+
/* maximum key range = 483, duplicates = 40 */
static
{"cap", LM_TK_SYM, LM_cap},
{"cup", LM_TK_SYM, LM_cup},
{"prec", LM_TK_SYM, LM_prec},
- {"mathnormal", LM_TK_FONT, LM_TC_NORMAL},
+ {"mathnormal", LM_TK_FONT, LM_TC_VAR},
{"wr", LM_TK_SYM, LM_wr},
{"inf", LM_TK_FUNCLIM, 0},
{"bigoplus", LM_TK_BIGSYM, LM_oplus},
#endif
#include "LString.h"
-#include "math_defs.h"
#include "symbol_def.h"
+class Painter;
+
/** Abstract base class for all math objects.
A math insets is for use of the math editor only, it isn't a
general LyX inset. It's used to represent all the math objects.
#pragma interface
#endif
+#include "mathed/support.h"
#include "math_defs.h"
class MathedInset;
+class MathedArray;
+class MathParInset;
///
enum mathIterFlags {
*/
#include <config.h>
-#include FORMS_H_LOCATION
#ifdef __GNUG__
#pragma implementation
#endif
-#include "LString.h"
#include "math_macro.h"
#include "array.h"
#include "math_iter.h"
}
-//extern int mathed_string_width(short type, int style, string const & s);
-//extern int mathed_string_height(short, int, string const &, int &, int &);
-
MathMacro::MathMacro(MathMacroTemplate * t):
MathParInset(LM_ST_TEXT, "", LM_OT_MACRO), tmplate(t)
{
}
}
+
MathMacro::~MathMacro()
{
for (idx = 0; idx < nargs; ++idx) {
void MathMacro::draw(Painter & pain, int x, int y)
{
- xo = x; yo = y;
+ xo = x;
+ yo = y;
Metrics();
tmplate->update(this);
tmplate->SetStyle(size);
void MathMacro::GetXY(int & x, int & y) const
{
- x = args_[idx].x; y = args_[idx].y;
+ x = args_[idx].x;
+ y = args_[idx].y;
}
#endif
#include <vector>
-
#include "math_parinset.h"
-#include "debug.h"
class MathMacroTemplate;
MathedTextCodes getTCode() const;
///
bool Permit(short) const;
-
private:
///
MathMacroTemplate * tmplate;
///
struct MacroArgumentBase {
/// Position of the macro
- int x, y;
+ int x;
+ ///
+ int y;
///
MathedRowSt * row;
///
///
friend class MathMacroTemplate;
};
-
-///
-//typedef MathMacro * MathMacroP;
-///
-//typedef MathMacroTemplate * MathMacroTemplateP;
-
#endif
#include "math_deliminset.h"
#include "math_fracinset.h"
#include "math_parinset.h"
+#include "debug.h"
MathMacroTable MathMacroTable::mathMTable;
case MM_APPLY:
case MM_OK:
{
- int i = fl_get_bmtable(fd_deco->menu);
+ int const i = fl_get_bmtable(fd_deco->menu);
+ int const l = sizeof(deco_code)/sizeof(deco_code[0]);
// ideally the callback should not be called if the index is
// greater than the maxitem of the bmtable, but I do not know
// how to enforce that (JMarc)
- if (i <= sizeof(deco_code)/sizeof(deco_code[0])) {
+ if (i <= l) {
lyxfunc->Dispatch(LFUN_INSERT_MATH, deco_code[i]);
if (data == MM_APPLY) break;
}
#include "math_parser.h"
#include "math_rowst.h"
#include "math_parinset.h"
+#include "debug.h"
using std::endl;
if (brace > 0)
os << string(brace, '}');
}
+
+
+bool MathParInset::Inside(int x, int y)
+{
+ return (x >= xo && x <= xo + width
+ && y <= yo + descent && y >= yo - ascent);
+}
+
+
+void MathParInset::GetXY(int & x, int & y) const
+{
+ x = xo;
+ y = yo;
+}
+
+
+void MathParInset::UserSetSize(short sz)
+{
+ if (sz >= 0) {
+ size = sz;
+ flag = flag & ~LMPF_FIXED_SIZE;
+ }
+}
+
+
+void MathParInset::SetStyle(short sz)
+{
+ if (Permit(LMPF_FIXED_SIZE)) {
+ if (Permit(LMPF_SCRIPT))
+ sz = (sz < LM_ST_SCRIPT) ? LM_ST_SCRIPT: LM_ST_SCRIPTSCRIPT;
+ if (Permit(LMPF_SMALLER) && sz < LM_ST_SCRIPTSCRIPT) {
+ ++sz;
+ }
+ MathedInset::SetStyle(sz);
+ }
+}
+
+
+void MathParInset::setFlag(MathedParFlag f)
+{
+ flag |= f;
+}
+
+
+bool MathParInset::Permit(short f) const
+{
+ return bool(f & flag);
+}
+
+
+MathedArray * MathParInset::GetData()
+{
+ return array;
+}
+
+
+void MathParInset::setXY(int x, int y)
+{
+ xo = x;
+ yo = y;
+}
#define MATH_PARINSET_H
#include "math_inset.h"
+#include "math_defs.h"
struct MathedRowSt;
+class MathedArray;
/** The math paragraph base class, base to all editable math objects */
/// Data is stored in a LyXArray
virtual void SetData(MathedArray *);
///
- virtual MathedArray * GetData() { return array; }
+ virtual MathedArray * GetData();
/// Paragraph position
virtual void GetXY(int &, int &) const;
///
- virtual void setXY(int x, int y) { xo = x; yo = y; }
+ virtual void setXY(int x, int y);
///
virtual void SetFocus(int, int) {}
///
///
virtual void setRowSt(MathedRowSt *) {}
///
- virtual bool Permit(short f) const { return bool(f & flag); }
+ virtual bool Permit(short f) const;
protected:
/// Paragraph data is stored here
MathedArray * array;
short flag;
private:
///
- virtual void setFlag(MathedParFlag f) { flag |= f; }
+ virtual void setFlag(MathedParFlag f);
///
friend class InsetFormula;
///
};
-inline
-bool MathParInset::Inside(int x, int y)
-{
- return (x >= xo && x <= xo + width && y <= yo + descent && y >= yo - ascent);
-}
-
-
-inline
-void MathParInset::GetXY(int & x, int & y) const
-{
- x = xo; y = yo;
-}
-
-
-inline
-void MathParInset::UserSetSize(short sz)
-{
- if (sz >= 0) {
- size = sz;
- flag = flag & ~LMPF_FIXED_SIZE;
- }
-}
-
-
-inline
-void MathParInset::SetStyle(short sz)
-{
- if (Permit(LMPF_FIXED_SIZE)) {
- if (Permit(LMPF_SCRIPT))
- sz = (sz < LM_ST_SCRIPT) ? LM_ST_SCRIPT: LM_ST_SCRIPTSCRIPT;
- if (Permit(LMPF_SMALLER) && sz < LM_ST_SCRIPTSCRIPT) {
- ++sz;
- }
- MathedInset::SetStyle(sz);
- }
-}
#endif
os << '\\' << latex_mathspace[space] << ' ';
}
}
+
+
+int MathSpaceInset::GetSpace()
+{
+ return space;
+}
#define MATH_SPACEINSET_H
#include "math_inset.h"
+#include "math_defs.h"
/// Smart spaces
class MathSpaceInset: public MathedInset {
///
void SetSpace(int sp);
///
- int GetSpace() { return space; }
+ int GetSpace();
protected:
///
int space;
#include "math_iter.h"
#include "math_parser.h"
#include "math_parinset.h"
+#include "mathed/support.h"
#include "support/lstrings.h"
#include "debug.h"
using std::endl;
extern char const * latex_mathenv[];
-extern char * latex_mathspace[];
// quite a hack i know. Should be done with return values...
int number_of_newlines = 0;
#include "math_rowst.h"
#include "array.h"
#include "mathed/support.h"
+#include "debug.h"
using std::endl;
#include "math_iter.h"
struct MathedRowSt;
+class MathParInset;
/**
A graphic iterator (updates position.) Used for
#include "Painter.h"
#include "matriz.h"
#include "symbol_def.h"
+#include "debug.h"
using std::sort;
using std::lower_bound;
return 0;
}
#endif
+
+
+bool MathIsInset(short x)
+{
+ return LM_TC_INSET <= x && x <= LM_TC_ACTIVE_INSET;
+}
+
+
+bool MathIsFont(short x)
+{
+ return LM_TC_CONST <= x && x <= LM_TC_BSYM;
+}
+
+
+bool MathIsAlphaFont(short x)
+{
+ return LM_TC_VAR <= x && x <= LM_TC_TEXTRM;
+}
+
+
+bool MathIsActive(short x)
+{
+ return LM_TC_INSET < x && x <= LM_TC_ACTIVE_INSET;
+}
+
+
+bool MathIsUp(short x)
+{
+ return x == LM_TC_UP;
+}
+
+
+bool MathIsDown(short x)
+{
+ return x == LM_TC_DOWN;
+}
+
+
+bool MathIsScript(short x)
+{
+ return x == LM_TC_DOWN || x == LM_TC_UP;
+}
+
+
+bool MathIsBOPS(short x)
+{
+ return MathedLookupBOP(x) > LMB_NONE;
+}
+
+
+bool MathIsBinary(short x)
+{
+ return x == LM_TC_BOP || x == LM_TC_BOPS;
+}
+
+
+bool MathIsSymbol(short x) {
+ return LM_TC_SYMB <= x && x <= LM_TC_BSYM;
+}
+
+
+bool is_eqn_type(short int type)
+{
+ return type >= LM_OT_MIN && type < LM_OT_MATRIX;
+}
+
+
+bool is_matrix_type(short int type)
+{
+ return type == LM_OT_MATRIX;
+}
+
+
+bool is_multiline(short int type)
+{
+ return type >= LM_OT_MPAR && type < LM_OT_MATRIX;
+}
+
+
+bool is_ams(short int type)
+{
+ return type > LM_OT_MPARN && type < LM_OT_MATRIX;
+}
+
+
+bool is_singlely_numbered(short int type)
+{
+ return type == LM_OT_PARN || type == LM_OT_MULTLINEN;
+}
+
+
+bool is_multi_numbered(short int type)
+{
+ return type == LM_OT_MPARN || type == LM_OT_ALIGNN
+ || type == LM_OT_ALIGNATN;
+}
+
+
+bool is_numbered(short int type)
+{
+ return is_singlely_numbered(type) || is_multi_numbered(type);
+}
+
+
+bool is_multicolumn(short int type)
+{
+ return type == LM_OT_ALIGN || type == LM_OT_ALIGNN
+ || type == LM_OT_ALIGNAT || type == LM_OT_ALIGNATN;
+}
#endif
class Painter;
+class MathedArray;
+class MathParInset;
struct math_deco_struct {
int code;
int & asc, int & des);
extern int mathed_string_width(short type, int size, string const & s);
extern math_deco_struct const * search_deco(int code);
+
+/// math_parser.C
+extern
+MathedArray * mathed_parse(unsigned flags, MathedArray * data,
+ MathParInset ** mt);
+/// math_write.C
+extern
+void mathed_write(MathParInset *, std::ostream &, int *, bool fragile,
+ string const & label = string());
+
+/// math_parser.C
+extern
+void mathed_parser_file(std::istream &, int);
+/// math_parser.C
+extern
+int mathed_parser_lineno();
+/// math_utils.C
+extern
+int MathedLookupBOP(short);
+
+extern
+bool MathIsInset(short x);
+
+extern
+bool MathIsFont(short x);
+
+extern
+bool MathIsAlphaFont(short x);
+
+extern
+bool MathIsActive(short x);
+
+extern
+bool MathIsUp(short x);
+
+extern
+bool MathIsDown(short x);
+
+extern
+bool MathIsScript(short x);
+
+extern
+bool MathIsBOPS(short x);
+
+extern
+bool MathIsBinary(short x);
+
+extern
+bool MathIsSymbol(short x);
+
+extern
+bool is_eqn_type(short int type);
+
+extern
+bool is_matrix_type(short int type);
+
+extern
+bool is_multiline(short int type);
+
+extern
+bool is_ams(short int type);
+
+extern
+bool is_singlely_numbered(short int type);
+
+extern
+bool is_multi_numbered(short int type);
+
+extern
+bool is_numbered(short int type);
+
+extern
+bool is_multicolumn(short int type);
+
#endif