bool needEqnArray(string const & extra)
{
- return false;
return extra == "dsolve";
}
int MathCursor::macroNamePos() const
{
- for (int i = pos() - 1; i >= 0; --i) {
+ for (MathInset::difference_type i = pos() - 1; i >= 0; --i) {
MathAtom & p = array().at(i);
if (p->code() == LM_TC_TEX && p->getChar() == '\\')
return i;
string MathCursor::macroName() const
{
string s;
- for (int i = macroNamePos(); i >= 0 && i < int(pos()); ++i)
+ MathInset::difference_type i = macroNamePos();
+ for ( ; i >= 0 && i < int(pos()); ++i)
s += array().at(i)->getChar();
return s;
}
///
typedef buffer_type::size_type size_type;
///
+ typedef buffer_type::difference_type difference_type;
+ ///
typedef buffer_type::size_type idx_type;
///
typedef buffer_type::size_type pos_type;
case LM_TK_FUNCLIM:
return MathAtom(new MathFuncLimInset(l->name));
case LM_TK_SPECIAL:
- return MathAtom(new MathSpecialCharInset(l->id));
+ return MathAtom(new MathSpecialCharInset(static_cast<char>(l->id)));
case LM_TK_SYM:
case LM_TK_CMR:
case LM_TK_CMSY:
namespace {
+// global
std::map<string, latexkeys> theWordList;
///
char const * name;
///
- short token;
+ MathTokenEnum token;
///
unsigned int id;
};
+
key_type wordlist_array[] =
{
{"!", LM_TK_SPACE, 0},
class MathInset {
public:
/// short of anything else reasonable
- typedef MathArray::size_type size_type;
+ typedef MathArray::size_type size_type;
+ /// type for cursor positions differences within a cell
+ typedef MathArray::difference_type difference_type;
/// type for cursor positions within a cell
- typedef MathArray::size_type pos_type;
+ typedef MathArray::size_type pos_type;
/// type for cell indices
- typedef size_type idx_type;
+ typedef size_type idx_type;
/// type for row numbers
- typedef size_type row_type;
+ typedef size_type row_type;
/// type for column numbers
- typedef size_type col_type;
+ typedef size_type col_type;
/// our members behave nicely...
MathInset() {}
}
-void MathIterator::jump(int i)
+void MathIterator::jump(MathInset::difference_type i)
{
position().pos_ += i;
- lyx::Assert(position().pos_ >= 0);
+ //lyx::Assert(position().pos_ >= 0);
lyx::Assert(position().pos_ <= cell().size());
}
/// move on one step
void operator++();
/// move on several steps
- void jump(int n);
+ void jump(MathInset::difference_type);
/// read access to top most item
MathCursorPos const & position() const;
/// write access to top most item
#include "LString.h"
#include "math_defs.h"
-class MathHullInset;
-class MathMacroTemplate;
class MathAtom;
class MathArray;
class LyXLex;
enum MathTokenEnum
{
///
- LM_TK_SYM = 256,
+ LM_TK_SYM,
///
LM_TK_BOX,
///
///
struct latexkeys {
- ///
+ /// name of the macro or primitive
string name;
- ///
- short token;
- ///
+ /// one of the categories above
+ MathTokenEnum token;
+ /// an id within a category if needed (only for spaces?)
unsigned int id;
- ///
- unsigned char latex_font_id;
- ///
+ /// which font to use (optional)
+ unsigned int latex_font_id;
+ /// operator/...
string type;
- ///
+ /// how is this called as XML entity?
string xmlname;
};
-///
+/// check whether this is a well-known (La)TeX macro or primitive
latexkeys const * in_word_set(string const & str);
-///
-void ReadSymbols(string const & file);
-
+/// parse formula from a string
bool mathed_parse_normal(MathAtom &, string const &);
+/// ... a stream
bool mathed_parse_normal(MathAtom &, std::istream &);
+/// ... the LyX lexxer
bool mathed_parse_normal(MathAtom &, LyXLex &);
+/// parse a macro definition from a string, enter it into the macro table
string mathed_parse_macro(string const &);
+/// ... a stream
string mathed_parse_macro(std::istream &);
+/// ... the LyX lexxer
string mathed_parse_macro(LyXLex &);
-void mathed_parse_cell(MathArray & ar, string const & str);
-void mathed_parse_cell(MathArray & ar, std::istream & is);
+/// parse a single cell from a string
+void mathed_parse_cell(MathArray & ar, string const &);
+/// ... a stream
+void mathed_parse_cell(MathArray & ar, std::istream &);
#endif
int MathScriptInset::dx0(MathInset const * nuc) const
{
lyx::Assert(hasDown());
- return hasLimits(nuc) ? (width(nuc) - down().width()) / 2 : nwid(nuc);
+ return hasLimits(nuc) ? (width2(nuc) - down().width()) / 2 : nwid(nuc);
}
int MathScriptInset::dx1(MathInset const * nuc) const
{
lyx::Assert(hasUp());
- return hasLimits(nuc) ? (width(nuc) - up().width()) / 2 : nwid(nuc);
+ return hasLimits(nuc) ? (width2(nuc) - up().width()) / 2 : nwid(nuc);
}
int MathScriptInset::dxx(MathInset const * nuc) const
{
//lyx::Assert(nuc());
- return hasLimits(nuc) ? (width(nuc) - nwid(nuc)) / 2 : 0;
+ return hasLimits(nuc) ? (width2(nuc) - nwid(nuc)) / 2 : 0;
}
-int MathScriptInset::ascent(MathInset const * nuc) const
+int MathScriptInset::ascent2(MathInset const * nuc) const
{
return dy1(nuc) + (hasUp() ? up().ascent() : 0);
}
-int MathScriptInset::descent(MathInset const * nuc) const
+int MathScriptInset::descent2(MathInset const * nuc) const
{
return dy0(nuc) + (hasDown() ? down().descent() : 0);
}
-int MathScriptInset::width(MathInset const * nuc) const
+int MathScriptInset::width2(MathInset const * nuc) const
{
int wid = 0;
if (hasLimits(nuc)) {
MathNestInset::metrics(mi);
if (nuc)
nuc->metrics(mi);
-
- ascent_ = ascent(nuc);
- descent_ = descent(nuc);
- width_ = width(nuc);
+ ascent_ = ascent2(nuc);
+ descent_ = descent2(nuc);
+ width_ = width2(nuc);
}
///
void draw(MathInset const * nuc, Painter &, int x, int y) const;
///
- int ascent(MathInset const * nuc) const;
+ int ascent2(MathInset const * nuc) const;
///
- int descent(MathInset const * nuc) const;
+ int descent2(MathInset const * nuc) const;
///
- int width(MathInset const * nuc) const;
+ int width2(MathInset const * nuc) const;
///
bool idxLeft(idx_type &, pos_type &) const;
MathScriptInset const * q = (it + 1 == end()) ? 0 : asScript(it);
if (q) {
q->metrics(p, mi);
- ascent_ = std::max(ascent_, q->ascent(p));
- descent_ = std::max(descent_, q->descent(p));
- width_ += q->width(p);
+ ascent_ = std::max(ascent_, q->ascent2(p));
+ descent_ = std::max(descent_, q->descent2(p));
+ width_ += q->width2(p);
++it;
} else {
p->metrics(mi);
MathScriptInset const * q = (it + 1 == end()) ? 0 : asScript(it);
if (q) {
q->draw(p, pain, x, y);
- x += q->width(p);
+ x += q->width2(p);
++it;
} else {
p->draw(pain, x, y);
if (q) {
++it;
if (it < target)
- x += q->width(p);
+ x += q->width2(p);
else // "half" position
x += q->dxx(p) + q->nwid(p);
} else
if (it + 1 != end())
q = asScript(it);
if (q) {
- wid = q->width(p);
+ wid = q->width2(p);
++it;
} else
wid = p->width();