From: Lars Gullik Bjønnes Date: Tue, 13 Feb 2001 19:10:18 +0000 (+0000) Subject: more mathed cleanup X-Git-Tag: 1.6.10~21623 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=84b7ffa3473faa9cfe66a974d2e0a5f9d6641187;p=features.git more mathed cleanup git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1500 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/mathed/ChangeLog b/src/mathed/ChangeLog index f05e4cf95c..9ae6438a2a 100644 --- a/src/mathed/ChangeLog +++ b/src/mathed/ChangeLog @@ -1,5 +1,47 @@ 2001-02-13 Lars Gullik Bjønnes + * 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 diff --git a/src/mathed/Makefile.am b/src/mathed/Makefile.am index 07c84fe53b..3b3e30b32e 100644 --- a/src/mathed/Makefile.am +++ b/src/mathed/Makefile.am @@ -31,7 +31,6 @@ libmathed_la_SOURCES = \ math_deliminset.h \ math_dotsinset.C \ math_dotsinset.h \ - math_draw.C \ math_forms.C \ math_forms.h \ math_fracinset.C \ diff --git a/src/mathed/array.C b/src/mathed/array.C index 41bf1f4e4e..060effb046 100644 --- a/src/mathed/array.C +++ b/src/mathed/array.C @@ -6,8 +6,6 @@ #endif #include "array.h" -#include "math_defs.h" - // Is this still needed? (Lgb) static inline diff --git a/src/mathed/array.h b/src/mathed/array.h index 0f3257951a..7801fcd7dd 100644 --- a/src/mathed/array.h +++ b/src/mathed/array.h @@ -18,7 +18,7 @@ #include -#include "math_defs.h" +#include "mathed/support.h" class MathedInset; diff --git a/src/mathed/formula.C b/src/mathed/formula.C index 67363caa0c..0997160e22 100644 --- a/src/mathed/formula.C +++ b/src/mathed/formula.C @@ -39,14 +39,13 @@ #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; diff --git a/src/mathed/formula.h b/src/mathed/formula.h index f1dc758789..aa350a3f85 100644 --- a/src/mathed/formula.h +++ b/src/mathed/formula.h @@ -128,10 +128,4 @@ private: /// string label; }; - - -// If a mathinset exist at cursor pos, just lock it. -// Otherwise create a new one, and lock it. -bool OpenMathInset(Buffer *); - #endif diff --git a/src/mathed/formulamacro.C b/src/mathed/formulamacro.C index 73af819f5e..2dfdbbf658 100644 --- a/src/mathed/formulamacro.C +++ b/src/mathed/formulamacro.C @@ -33,6 +33,7 @@ #include "Painter.h" #include "font.h" #include "support/lyxlib.h" +#include "mathed/support.h" using std::ostream; using std::istream; diff --git a/src/mathed/math_accentinset.C b/src/mathed/math_accentinset.C index ac0fd1af21..e16b59be22 100644 --- a/src/mathed/math_accentinset.C +++ b/src/mathed/math_accentinset.C @@ -1,7 +1,7 @@ #include #include "math_accentinset.h" -#include "support.h" +#include "mathed/support.h" #include "math_parser.h" diff --git a/src/mathed/math_accentinset.h b/src/mathed/math_accentinset.h index b6d29b4de8..d2b71402a2 100644 --- a/src/mathed/math_accentinset.h +++ b/src/mathed/math_accentinset.h @@ -3,6 +3,8 @@ #define MATH_ACCENTINSET_H #include "math_inset.h" +#include "mathed/support.h" +#include "math_defs.h" /// Accents class MathAccentInset: public MathedInset { diff --git a/src/mathed/math_bigopinset.h b/src/mathed/math_bigopinset.h index 85c1e0b324..68aa22964e 100644 --- a/src/mathed/math_bigopinset.h +++ b/src/mathed/math_bigopinset.h @@ -3,6 +3,7 @@ #define MATH_BIGOPINSET_H #include "math_inset.h" +#include "math_defs.h" /// big operators class MathBigopInset: public MathedInset { diff --git a/src/mathed/math_cursor.C b/src/mathed/math_cursor.C index e91201eb7b..93479f7c23 100644 --- a/src/mathed/math_cursor.C +++ b/src/mathed/math_cursor.C @@ -40,6 +40,7 @@ #include "math_decorationinset.h" #include "math_dotsinset.h" #include "math_accentinset.h" +#include "mathed/support.h" static MathedArray * selarray = 0; @@ -377,6 +378,7 @@ MathMatrixInset * create_multiline(short int type, int cols) return mt; } + void MathedCursor::Insert(byte c, MathedTextCodes t) { if (selection) SelDel(); @@ -1100,3 +1102,69 @@ void MathedCursor::toggleLastCode(MathedTextCodes t) 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; +} diff --git a/src/mathed/math_cursor.h b/src/mathed/math_cursor.h index 5f6721553d..60f76d2512 100644 --- a/src/mathed/math_cursor.h +++ b/src/mathed/math_cursor.h @@ -23,11 +23,11 @@ #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 @@ -69,13 +69,13 @@ public: /// 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 *); /// @@ -87,9 +87,7 @@ public: /// 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 @@ -97,18 +95,18 @@ public: /// 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(); /// @@ -126,13 +124,13 @@ public: /// 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: /// diff --git a/src/mathed/math_defs.h b/src/mathed/math_defs.h index 5491594183..c207d821fa 100644 --- a/src/mathed/math_defs.h +++ b/src/mathed/math_defs.h @@ -27,16 +27,6 @@ #include #include "LString.h" -#include "debug.h" - -//#include "array.h" - -class MathedArray; -class Painter; - -#ifndef byte -#define byte unsigned char -#endif /// enum math_align { @@ -133,10 +123,7 @@ enum MathedTextCodes { /// std::ostream & operator<<(std::ostream &, MathedTextCodes mtc); -/// -#define LM_TC_NORMAL LM_TC_VAR - - + /// Types of lyx-math insets enum MathedInsetTypes { /// @@ -200,6 +187,7 @@ enum MathedInsetTypes { LM_OT_MAX }; + /// enum MathedBinaryTypes { /// @@ -212,8 +200,6 @@ enum MathedBinaryTypes { LMB_BOP = (LMB_RELATION | LMB_OPERATOR) }; -class MathParInset; - /// Paragraph permissions enum MathedParFlag { @@ -232,146 +218,4 @@ 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 diff --git a/src/mathed/math_dotsinset.h b/src/mathed/math_dotsinset.h index 0e848087a3..e605aaa6e2 100644 --- a/src/mathed/math_dotsinset.h +++ b/src/mathed/math_dotsinset.h @@ -2,6 +2,7 @@ #define MATH_DOTSINSET_H #include "math_inset.h" +#include "math_defs.h" /// class MathDotsInset: public MathedInset { diff --git a/src/mathed/math_draw.C b/src/mathed/math_draw.C index 1ec03491f5..05decd171d 100644 --- a/src/mathed/math_draw.C +++ b/src/mathed/math_draw.C @@ -25,11 +25,11 @@ 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 &); diff --git a/src/mathed/math_funcinset.h b/src/mathed/math_funcinset.h index b08fefa026..3758907e88 100644 --- a/src/mathed/math_funcinset.h +++ b/src/mathed/math_funcinset.h @@ -2,6 +2,7 @@ #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. diff --git a/src/mathed/math_hash.C b/src/mathed/math_hash.C index 66af12bcdb..ae083544dd 100644 --- a/src/mathed/math_hash.C +++ b/src/mathed/math_hash.C @@ -7,13 +7,21 @@ #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 @@ -179,7 +187,7 @@ latexkeys wordlist[] = {"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}, diff --git a/src/mathed/math_inset.h b/src/mathed/math_inset.h index fa759c5af6..530b82ff86 100644 --- a/src/mathed/math_inset.h +++ b/src/mathed/math_inset.h @@ -27,9 +27,10 @@ #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. diff --git a/src/mathed/math_iter.h b/src/mathed/math_iter.h index bdf8c676c6..0973415f61 100644 --- a/src/mathed/math_iter.h +++ b/src/mathed/math_iter.h @@ -24,9 +24,12 @@ #pragma interface #endif +#include "mathed/support.h" #include "math_defs.h" class MathedInset; +class MathedArray; +class MathParInset; /// enum mathIterFlags { diff --git a/src/mathed/math_macro.C b/src/mathed/math_macro.C index 632c3d7676..79d4d7c37f 100644 --- a/src/mathed/math_macro.C +++ b/src/mathed/math_macro.C @@ -16,13 +16,11 @@ */ #include -#include FORMS_H_LOCATION #ifdef __GNUG__ #pragma implementation #endif -#include "LString.h" #include "math_macro.h" #include "array.h" #include "math_iter.h" @@ -46,9 +44,6 @@ ostream & operator<<(ostream & o, MathedTextCodes mtc) } -//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) { @@ -80,6 +75,7 @@ MathMacro::MathMacro(MathMacro * m): } } + MathMacro::~MathMacro() { for (idx = 0; idx < nargs; ++idx) { @@ -110,7 +106,8 @@ void MathMacro::Metrics() void MathMacro::draw(Painter & pain, int x, int y) { - xo = x; yo = y; + xo = x; + yo = y; Metrics(); tmplate->update(this); tmplate->SetStyle(size); @@ -157,7 +154,8 @@ int MathMacro::GetColumns() const void MathMacro::GetXY(int & x, int & y) const { - x = args_[idx].x; y = args_[idx].y; + x = args_[idx].x; + y = args_[idx].y; } diff --git a/src/mathed/math_macro.h b/src/mathed/math_macro.h index f63466cd0b..a250e98299 100644 --- a/src/mathed/math_macro.h +++ b/src/mathed/math_macro.h @@ -22,9 +22,7 @@ #endif #include - #include "math_parinset.h" -#include "debug.h" class MathMacroTemplate; @@ -71,14 +69,15 @@ public: 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; /// @@ -96,10 +95,4 @@ private: /// friend class MathMacroTemplate; }; - -/// -//typedef MathMacro * MathMacroP; -/// -//typedef MathMacroTemplate * MathMacroTemplateP; - #endif diff --git a/src/mathed/math_macrotable.C b/src/mathed/math_macrotable.C index f39799459e..b34ac612c8 100644 --- a/src/mathed/math_macrotable.C +++ b/src/mathed/math_macrotable.C @@ -9,6 +9,7 @@ #include "math_deliminset.h" #include "math_fracinset.h" #include "math_parinset.h" +#include "debug.h" MathMacroTable MathMacroTable::mathMTable; diff --git a/src/mathed/math_panel.C b/src/mathed/math_panel.C index 22471c2f51..e81521bdbb 100644 --- a/src/mathed/math_panel.C +++ b/src/mathed/math_panel.C @@ -241,11 +241,12 @@ void deco_cb(FL_OBJECT *, long data) 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; } diff --git a/src/mathed/math_parinset.C b/src/mathed/math_parinset.C index a676e9ebad..ea10c0baf9 100644 --- a/src/mathed/math_parinset.C +++ b/src/mathed/math_parinset.C @@ -10,6 +10,7 @@ #include "math_parser.h" #include "math_rowst.h" #include "math_parinset.h" +#include "debug.h" using std::endl; @@ -392,3 +393,64 @@ void MathParInset::Write(ostream & os, bool fragile) 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; +} diff --git a/src/mathed/math_parinset.h b/src/mathed/math_parinset.h index 0493894291..52ab59ad2d 100644 --- a/src/mathed/math_parinset.h +++ b/src/mathed/math_parinset.h @@ -3,8 +3,10 @@ #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 */ @@ -31,11 +33,11 @@ class MathParInset: public MathedInset { /// 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) {} /// @@ -65,7 +67,7 @@ class MathParInset: public MathedInset { /// 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; @@ -77,7 +79,7 @@ class MathParInset: public MathedInset { short flag; private: /// - virtual void setFlag(MathedParFlag f) { flag |= f; } + virtual void setFlag(MathedParFlag f); /// friend class InsetFormula; /// @@ -91,40 +93,4 @@ class MathParInset: public MathedInset { }; -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 diff --git a/src/mathed/math_spaceinset.C b/src/mathed/math_spaceinset.C index 11a51d9228..c7561ccda3 100644 --- a/src/mathed/math_spaceinset.C +++ b/src/mathed/math_spaceinset.C @@ -61,3 +61,9 @@ MathSpaceInset::Write(ostream & os, bool /* fragile */) os << '\\' << latex_mathspace[space] << ' '; } } + + +int MathSpaceInset::GetSpace() +{ + return space; +} diff --git a/src/mathed/math_spaceinset.h b/src/mathed/math_spaceinset.h index fb91b26d12..31343c3fed 100644 --- a/src/mathed/math_spaceinset.h +++ b/src/mathed/math_spaceinset.h @@ -2,6 +2,7 @@ #define MATH_SPACEINSET_H #include "math_inset.h" +#include "math_defs.h" /// Smart spaces class MathSpaceInset: public MathedInset { @@ -19,7 +20,7 @@ public: /// void SetSpace(int sp); /// - int GetSpace() { return space; } + int GetSpace(); protected: /// int space; diff --git a/src/mathed/math_write.C b/src/mathed/math_write.C index 97cfd6d548..b340523ed6 100644 --- a/src/mathed/math_write.C +++ b/src/mathed/math_write.C @@ -22,6 +22,7 @@ #include "math_iter.h" #include "math_parser.h" #include "math_parinset.h" +#include "mathed/support.h" #include "support/lstrings.h" #include "debug.h" @@ -29,7 +30,6 @@ using std::ostream; 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; diff --git a/src/mathed/math_xiter.C b/src/mathed/math_xiter.C index ba56a48408..046257659f 100644 --- a/src/mathed/math_xiter.C +++ b/src/mathed/math_xiter.C @@ -5,6 +5,7 @@ #include "math_rowst.h" #include "array.h" #include "mathed/support.h" +#include "debug.h" using std::endl; diff --git a/src/mathed/math_xiter.h b/src/mathed/math_xiter.h index d11e55e58e..77d6324282 100644 --- a/src/mathed/math_xiter.h +++ b/src/mathed/math_xiter.h @@ -5,6 +5,7 @@ #include "math_iter.h" struct MathedRowSt; +class MathParInset; /** A graphic iterator (updates position.) Used for diff --git a/src/mathed/support.C b/src/mathed/support.C index b815aaf537..2e2e48a709 100644 --- a/src/mathed/support.C +++ b/src/mathed/support.C @@ -9,6 +9,7 @@ #include "Painter.h" #include "matriz.h" #include "symbol_def.h" +#include "debug.h" using std::sort; using std::lower_bound; @@ -456,3 +457,112 @@ math_deco_struct const * search_deco(int code) 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; +} diff --git a/src/mathed/support.h b/src/mathed/support.h index ee74a90ac5..3273d1e25f 100644 --- a/src/mathed/support.h +++ b/src/mathed/support.h @@ -10,6 +10,8 @@ #endif class Painter; +class MathedArray; +class MathParInset; struct math_deco_struct { int code; @@ -31,4 +33,78 @@ extern int mathed_string_height(short type, int size, string const & s, 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