mathed23.diff

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1529 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2001-02-17 16:43:31 +00:00
parent 3d4b640a42
commit dd2c5d201a
6 changed files with 60 additions and 40 deletions

View File

@ -1,3 +1,11 @@
2001-02-14 André Pönitz <poenitz@htwm.de>
* math_iter.[Ch]: hide fcode_
* math_xiter.C:
* math_parinset.C: subsequent changes
2001-02-16 Lars Gullik Bjønnes <larsbj@lyx.org>
* Makefile.am (libmathed_la_SOURCES): remove math_write.C, add

View File

@ -1150,7 +1150,7 @@ void MathedCursor::GetPos(int & x, int & y)
short MathedCursor::GetFCode()
{
return cursor->FCode();
return cursor->fcode();
}

View File

@ -39,7 +39,7 @@ const int SizeInset = sizeof(char*) + 2;
MathedIter::MathedIter()
: flags(0), fcode(0), pos(0), row(0), col(0), ncols(0), array(0)
: flags(0), fcode_(0), pos(0), row(0), col(0), ncols(0), array(0)
{}
@ -54,6 +54,16 @@ MathedArray * MathedIter::GetData() const
return array;
}
short MathedIter::fcode() const
{
return fcode_;
}
void MathedIter::fcode(short c) const
{
fcode_ = c;
}
int MathedIter::Empty() const
{
@ -70,10 +80,10 @@ int MathedIter::OK() const
void MathedIter::Reset()
{
if (array->last() > 0 && MathIsFont((*array)[0])) {
fcode = (*array)[0];
fcode((*array)[0]);
pos = 1;
} else {
fcode = -1;
fcode(-1);
pos = 0;
}
col = 0;
@ -84,7 +94,7 @@ void MathedIter::Reset()
byte MathedIter::GetChar() const
{
if (IsFont()) {
fcode = (*array)[pos];
fcode((*array)[pos]);
++pos;
}
return (*array)[pos];
@ -94,7 +104,7 @@ byte MathedIter::GetChar() const
string const MathedIter::GetString() const
{
if (IsFont()) {
fcode = (*array)[++pos];
fcode((*array)[++pos]);
++pos;
}
@ -138,7 +148,7 @@ bool MathedIter::Next()
return false;
if ((*array)[pos] < ' ') {
fcode = -1;
fcode(-1);
if (IsTab())
++col;
if (IsCR()) {
@ -153,7 +163,7 @@ bool MathedIter::Next()
++pos;
if (IsFont())
fcode = (*array)[pos++];
fcode((*array)[pos++]);
return true;
}
@ -196,20 +206,20 @@ void MathedIter::Insert(byte c, MathedTextCodes t)
return;
if (IsFont() && (*array)[pos] == t) {
fcode = t;
fcode(t);
++pos;
} else {
if (t != fcode && pos > 0 && MathIsFont((*array)[pos - 1])) {
if (t != fcode() && pos > 0 && MathIsFont((*array)[pos - 1])) {
--pos;
int k = pos - 1;
for (; k >= 0 && (*array)[k] >= ' '; --k)
;
fcode = (k >= 0 && MathIsFont((*array)[k])) ? (*array)[k] : -1;
fcode( (k >= 0 && MathIsFont((*array)[k])) ? (*array)[k] : -1 );
}
}
short const f = ((*array)[pos] < ' ') ? 0 : fcode;
int shift = (t == fcode) ? 1 : ((f) ? 3 : 2);
short const f = ((*array)[pos] < ' ') ? 0 : fcode();
int shift = (t == fcode()) ? 1 : ((f) ? 3 : 2);
if (t == LM_TC_TAB || t == LM_TC_CR) {
--shift;
@ -229,15 +239,15 @@ void MathedIter::Insert(byte c, MathedTextCodes t)
(*array)[array->last()] = '\0';
}
if (t != fcode) {
if (t != fcode()) {
if (f)
(*array)[pos + shift - 1] = fcode;
(*array)[pos + shift - 1] = fcode();
if (c >= ' ') {
(*array)[pos++] = t;
fcode = t;
fcode(t);
} else
fcode = 0;
fcode(0);
}
(*array)[pos++] = c;
@ -262,7 +272,7 @@ void MathedIter::split(int shift)
array->move(pos, shift);
if (fg)
(*array)[pos + shift - 1] = fcode;
(*array)[pos + shift - 1] = fcode();
} else {
@ -280,7 +290,7 @@ void MathedIter::join(int pos2)
if (!OK() || pos2 <= pos)
return;
short f = fcode;
short f = fcode();
if (pos > 0 && (*array)[pos] >= ' ' && MathIsFont((*array)[pos - 1]))
--pos;
@ -315,7 +325,7 @@ void MathedIter::Insert(MathedInset * p, int type)
pos += SizeInset;
(*array)[pos - 1] = type;
(*array)[array->last()] = '\0';
fcode = -1;
fcode(-1);
}
@ -335,7 +345,7 @@ bool MathedIter::Delete()
for (; i > 0 && !MathIsFont((*array)[i]); --i)
;
if (i > 0 && MathIsFont((*array)[i]))
fcode = (*array)[i];
fcode((*array)[i]);
} else
shift = 1;
@ -515,13 +525,13 @@ MathedIter::MathedIter(MathedArray * d)
pos = 0;
row = 0;
col = 0;
fcode = (array && IsFont()) ? (*array)[0]: 0;
fcode( (array && IsFont()) ? (*array)[0] : 0 );
}
void MathedIter::ipush()
{
stck.fcode = fcode;
stck.fcode = fcode();
stck.pos = pos;
stck.row = row;
stck.col = col;
@ -530,7 +540,7 @@ void MathedIter::ipush()
void MathedIter::ipop()
{
fcode = stck.fcode;
fcode(stck.fcode);
pos = stck.pos;
row = stck.row;
col = stck.col;

View File

@ -97,7 +97,9 @@ public:
/// Try to adjust tabs in the expected place, as in eqnarrays
void adjustTabs();
///
short FCode() const { return fcode; }
short fcode() const;
///
void fcode(short) const;
///
int getPos() const { return pos; }
///
@ -122,7 +124,7 @@ protected:
///
int flags;
///
mutable short fcode;
mutable short fcode_;
///
mutable int pos;
///

View File

@ -106,7 +106,7 @@ MathParInset::draw(Painter & pain, int x, int y)
byte cx = data.GetChar();
if (cx >= ' ') {
string s = data.GetString();
drawStr(pain, data.FCode(), size(), x, y, s);
drawStr(pain, data.fcode(), size(), x, y, s);
mathed_char_height(LM_TC_CONST, size(), 'y', asc, des);
limits = false;
}
@ -197,7 +197,7 @@ MathParInset::Metrics()
cx = data.GetChar();
if (cx >= ' ') {
string s = data.GetString();
mathed_string_height(data.FCode(),
mathed_string_height(data.fcode(),
size(), s, asc, des);
if (asc > ascent) ascent = asc;
if (des > descent) descent = des;
@ -303,39 +303,39 @@ void MathParInset::Write(ostream & os, bool fragile)
if (cx >= ' ') {
string str = data.GetString();
if (data.FCode() >= LM_TC_RM && data.FCode() <= LM_TC_TEXTRM) {
os << '\\' << math_font_name[data.FCode()-LM_TC_RM] << '{';
if (data.fcode() >= LM_TC_RM && data.fcode() <= LM_TC_TEXTRM) {
os << '\\' << math_font_name[data.fcode()-LM_TC_RM] << '{';
}
for (string::const_iterator s = str.begin();
s != str.end(); ++s) {
byte c = *s;
if (MathIsSymbol(data.FCode())) {
l = lm_get_key_by_id(c, (data.FCode() == LM_TC_BSYM) ?
if (MathIsSymbol(data.fcode())) {
l = lm_get_key_by_id(c, (data.fcode() == LM_TC_BSYM) ?
LM_TK_BIGSYM : LM_TK_SYM);
if (l) {
os << '\\' << l->name << ' ';
} else {
#warning this does not compile on gcc 2.97
//lyxerr << "Illegal symbol code[" << c
// << " " << str.end() - s << " " << data.FCode() << "]";
// << " " << str.end() - s << " " << data.fcode() << "]";
}
} else {
// Is there a standard logical XOR?
if ((data.FCode() == LM_TC_TEX && c != '{' && c != '}') ||
(data.FCode() == LM_TC_SPECIAL))
if ((data.fcode() == LM_TC_TEX && c != '{' && c != '}') ||
(data.fcode() == LM_TC_SPECIAL))
os << '\\';
else {
if (c == '{') ++brace;
if (c == '}') --brace;
}
if (c == '}' && data.FCode() == LM_TC_TEX && brace < 0)
if (c == '}' && data.fcode() == LM_TC_TEX && brace < 0)
lyxerr <<"Math warning: Unexpected closing brace."
<< endl;
else
os << char(c);
}
}
if (data.FCode()>= LM_TC_RM && data.FCode()<= LM_TC_TEXTRM)
if (data.fcode()>= LM_TC_RM && data.fcode()<= LM_TC_TEXTRM)
os << '}';
} else
if (MathIsInset(cx)) {

View File

@ -224,7 +224,7 @@ void MathedXIter::SetData(MathParInset * pp)
string const MathedXIter::GetString() const
{
string s = MathedIter::GetString();
x += mathed_string_width(fcode, size, s);
x += mathed_string_width(fcode(), size, s);
return s;
}
@ -247,7 +247,7 @@ bool MathedXIter::Next()
byte c = GetChar();
if (c >= ' ') {
// lyxerr << "WD[" << fcode << " " << size << " " << c << endl;
w = mathed_char_width(fcode, size, c);
w = mathed_char_width(fcode(), size, c);
} else
if (c == LM_TC_TAB && p) {
// w = p->GetTab(col + 1);
@ -530,7 +530,7 @@ void MathedXIter::IMetrics(int pos2, int & width, int & ascent, int & descent)
while (pos < pos2) {
cx = GetChar();
if (cx >= ' ') {
mathed_char_height(FCode(), size, cx, asc, des);
mathed_char_height(fcode(), size, cx, asc, des);
if (asc > ascent) ascent = asc;
if (des > descent) descent = des;
limit = false;