some changes to make some compilers somewhat happier

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3310 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2002-01-08 11:03:34 +00:00
parent 13daca767e
commit faf2f08712
12 changed files with 57 additions and 49 deletions

View File

@ -503,7 +503,6 @@ InsetFormula::localDispatch(BufferView * bv, kb_action action,
bool needEqnArray(string const & extra) bool needEqnArray(string const & extra)
{ {
return false;
return extra == "dsolve"; return extra == "dsolve";
} }

View File

@ -619,7 +619,7 @@ void MathCursor::macroModeClose()
int MathCursor::macroNamePos() const 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); MathAtom & p = array().at(i);
if (p->code() == LM_TC_TEX && p->getChar() == '\\') if (p->code() == LM_TC_TEX && p->getChar() == '\\')
return i; return i;
@ -631,7 +631,8 @@ int MathCursor::macroNamePos() const
string MathCursor::macroName() const string MathCursor::macroName() const
{ {
string s; 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(); s += array().at(i)->getChar();
return s; return s;
} }

View File

@ -51,6 +51,8 @@ public:
/// ///
typedef buffer_type::size_type size_type; 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 idx_type;
/// ///
typedef buffer_type::size_type pos_type; typedef buffer_type::size_type pos_type;

View File

@ -30,7 +30,7 @@ MathAtom createMathInset(latexkeys const * l)
case LM_TK_FUNCLIM: case LM_TK_FUNCLIM:
return MathAtom(new MathFuncLimInset(l->name)); return MathAtom(new MathFuncLimInset(l->name));
case LM_TK_SPECIAL: 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_SYM:
case LM_TK_CMR: case LM_TK_CMR:
case LM_TK_CMSY: case LM_TK_CMSY:

View File

@ -11,6 +11,7 @@
namespace { namespace {
// global
std::map<string, latexkeys> theWordList; std::map<string, latexkeys> theWordList;
@ -18,11 +19,12 @@ struct key_type {
/// ///
char const * name; char const * name;
/// ///
short token; MathTokenEnum token;
/// ///
unsigned int id; unsigned int id;
}; };
key_type wordlist_array[] = key_type wordlist_array[] =
{ {
{"!", LM_TK_SPACE, 0}, {"!", LM_TK_SPACE, 0},

View File

@ -78,15 +78,17 @@ class MathPosFinder;
class MathInset { class MathInset {
public: public:
/// short of anything else reasonable /// 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 /// type for cursor positions within a cell
typedef MathArray::size_type pos_type; typedef MathArray::size_type pos_type;
/// type for cell indices /// type for cell indices
typedef size_type idx_type; typedef size_type idx_type;
/// type for row numbers /// type for row numbers
typedef size_type row_type; typedef size_type row_type;
/// type for column numbers /// type for column numbers
typedef size_type col_type; typedef size_type col_type;
/// our members behave nicely... /// our members behave nicely...
MathInset() {} MathInset() {}

View File

@ -138,10 +138,10 @@ void MathIterator::operator++()
} }
void MathIterator::jump(int i) void MathIterator::jump(MathInset::difference_type i)
{ {
position().pos_ += i; position().pos_ += i;
lyx::Assert(position().pos_ >= 0); //lyx::Assert(position().pos_ >= 0);
lyx::Assert(position().pos_ <= cell().size()); lyx::Assert(position().pos_ <= cell().size());
} }

View File

@ -21,7 +21,7 @@ public:
/// move on one step /// move on one step
void operator++(); void operator++();
/// move on several steps /// move on several steps
void jump(int n); void jump(MathInset::difference_type);
/// read access to top most item /// read access to top most item
MathCursorPos const & position() const; MathCursorPos const & position() const;
/// write access to top most item /// write access to top most item

View File

@ -26,8 +26,6 @@
#include "LString.h" #include "LString.h"
#include "math_defs.h" #include "math_defs.h"
class MathHullInset;
class MathMacroTemplate;
class MathAtom; class MathAtom;
class MathArray; class MathArray;
class LyXLex; class LyXLex;
@ -36,7 +34,7 @@ class LyXLex;
enum MathTokenEnum enum MathTokenEnum
{ {
/// ///
LM_TK_SYM = 256, LM_TK_SYM,
/// ///
LM_TK_BOX, LM_TK_BOX,
/// ///
@ -118,36 +116,41 @@ enum MathTokenEnum
/// ///
struct latexkeys { struct latexkeys {
/// /// name of the macro or primitive
string name; string name;
/// /// one of the categories above
short token; MathTokenEnum token;
/// /// an id within a category if needed (only for spaces?)
unsigned int id; unsigned int id;
/// /// which font to use (optional)
unsigned char latex_font_id; unsigned int latex_font_id;
/// /// operator/...
string type; string type;
/// /// how is this called as XML entity?
string xmlname; string xmlname;
}; };
/// /// check whether this is a well-known (La)TeX macro or primitive
latexkeys const * in_word_set(string const & str); latexkeys const * in_word_set(string const & str);
/// /// parse formula from a string
void ReadSymbols(string const & file);
bool mathed_parse_normal(MathAtom &, string const &); bool mathed_parse_normal(MathAtom &, string const &);
/// ... a stream
bool mathed_parse_normal(MathAtom &, std::istream &); bool mathed_parse_normal(MathAtom &, std::istream &);
/// ... the LyX lexxer
bool mathed_parse_normal(MathAtom &, LyXLex &); 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 &); string mathed_parse_macro(string const &);
/// ... a stream
string mathed_parse_macro(std::istream &); string mathed_parse_macro(std::istream &);
/// ... the LyX lexxer
string mathed_parse_macro(LyXLex &); string mathed_parse_macro(LyXLex &);
void mathed_parse_cell(MathArray & ar, string const & str); /// parse a single cell from a string
void mathed_parse_cell(MathArray & ar, std::istream & is); void mathed_parse_cell(MathArray & ar, string const &);
/// ... a stream
void mathed_parse_cell(MathArray & ar, std::istream &);
#endif #endif

View File

@ -106,37 +106,37 @@ int MathScriptInset::dy1(MathInset const * nuc) const
int MathScriptInset::dx0(MathInset const * nuc) const int MathScriptInset::dx0(MathInset const * nuc) const
{ {
lyx::Assert(hasDown()); 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 int MathScriptInset::dx1(MathInset const * nuc) const
{ {
lyx::Assert(hasUp()); 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 int MathScriptInset::dxx(MathInset const * nuc) const
{ {
//lyx::Assert(nuc()); //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); 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); return dy0(nuc) + (hasDown() ? down().descent() : 0);
} }
int MathScriptInset::width(MathInset const * nuc) const int MathScriptInset::width2(MathInset const * nuc) const
{ {
int wid = 0; int wid = 0;
if (hasLimits(nuc)) { if (hasLimits(nuc)) {
@ -190,10 +190,9 @@ void MathScriptInset::metrics(MathInset const * nuc,
MathNestInset::metrics(mi); MathNestInset::metrics(mi);
if (nuc) if (nuc)
nuc->metrics(mi); nuc->metrics(mi);
ascent_ = ascent2(nuc);
ascent_ = ascent(nuc); descent_ = descent2(nuc);
descent_ = descent(nuc); width_ = width2(nuc);
width_ = width(nuc);
} }

View File

@ -34,11 +34,11 @@ public:
/// ///
void draw(MathInset const * nuc, Painter &, int x, int y) const; 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; bool idxLeft(idx_type &, pos_type &) const;

View File

@ -36,9 +36,9 @@ void MathXArray::metrics(MathMetricsInfo const & mi) const
MathScriptInset const * q = (it + 1 == end()) ? 0 : asScript(it); MathScriptInset const * q = (it + 1 == end()) ? 0 : asScript(it);
if (q) { if (q) {
q->metrics(p, mi); q->metrics(p, mi);
ascent_ = std::max(ascent_, q->ascent(p)); ascent_ = std::max(ascent_, q->ascent2(p));
descent_ = std::max(descent_, q->descent(p)); descent_ = std::max(descent_, q->descent2(p));
width_ += q->width(p); width_ += q->width2(p);
++it; ++it;
} else { } else {
p->metrics(mi); p->metrics(mi);
@ -67,7 +67,7 @@ void MathXArray::draw(Painter & pain, int x, int y) const
MathScriptInset const * q = (it + 1 == end()) ? 0 : asScript(it); MathScriptInset const * q = (it + 1 == end()) ? 0 : asScript(it);
if (q) { if (q) {
q->draw(p, pain, x, y); q->draw(p, pain, x, y);
x += q->width(p); x += q->width2(p);
++it; ++it;
} else { } else {
p->draw(pain, x, y); p->draw(pain, x, y);
@ -87,7 +87,7 @@ int MathXArray::pos2x(size_type targetpos) const
if (q) { if (q) {
++it; ++it;
if (it < target) if (it < target)
x += q->width(p); x += q->width2(p);
else // "half" position else // "half" position
x += q->dxx(p) + q->nwid(p); x += q->dxx(p) + q->nwid(p);
} else } else
@ -111,7 +111,7 @@ MathArray::size_type MathXArray::x2pos(int targetx) const
if (it + 1 != end()) if (it + 1 != end())
q = asScript(it); q = asScript(it);
if (q) { if (q) {
wid = q->width(p); wid = q->width2(p);
++it; ++it;
} else } else
wid = p->width(); wid = p->width();