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> 2001-02-16 Lars Gullik Bjønnes <larsbj@lyx.org>
* Makefile.am (libmathed_la_SOURCES): remove math_write.C, add * 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() short MathedCursor::GetFCode()
{ {
return cursor->FCode(); return cursor->fcode();
} }

View File

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

View File

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

View File

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

View File

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