From dd2c5d201a2f00f786deaf9105e7b56037aec9fe Mon Sep 17 00:00:00 2001 From: =?utf8?q?Lars=20Gullik=20Bj=C3=B8nnes?= Date: Sat, 17 Feb 2001 16:43:31 +0000 Subject: [PATCH] mathed23.diff git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1529 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/ChangeLog | 8 ++++++ src/mathed/math_cursor.C | 2 +- src/mathed/math_iter.C | 56 ++++++++++++++++++++++---------------- src/mathed/math_iter.h | 6 ++-- src/mathed/math_parinset.C | 22 +++++++-------- src/mathed/math_xiter.C | 6 ++-- 6 files changed, 60 insertions(+), 40 deletions(-) diff --git a/src/mathed/ChangeLog b/src/mathed/ChangeLog index b1e13e33a7..d975a4c99f 100644 --- a/src/mathed/ChangeLog +++ b/src/mathed/ChangeLog @@ -1,3 +1,11 @@ + +2001-02-14 André Pönitz + + * math_iter.[Ch]: hide fcode_ + * math_xiter.C: + * math_parinset.C: subsequent changes + + 2001-02-16 Lars Gullik Bjønnes * Makefile.am (libmathed_la_SOURCES): remove math_write.C, add diff --git a/src/mathed/math_cursor.C b/src/mathed/math_cursor.C index 4b747c80cf..4cb9e3dea0 100644 --- a/src/mathed/math_cursor.C +++ b/src/mathed/math_cursor.C @@ -1150,7 +1150,7 @@ void MathedCursor::GetPos(int & x, int & y) short MathedCursor::GetFCode() { - return cursor->FCode(); + return cursor->fcode(); } diff --git a/src/mathed/math_iter.C b/src/mathed/math_iter.C index a5c74f4c4b..9ba085e84e 100644 --- a/src/mathed/math_iter.C +++ b/src/mathed/math_iter.C @@ -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; diff --git a/src/mathed/math_iter.h b/src/mathed/math_iter.h index 846c845983..17ddc56d8c 100644 --- a/src/mathed/math_iter.h +++ b/src/mathed/math_iter.h @@ -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; /// diff --git a/src/mathed/math_parinset.C b/src/mathed/math_parinset.C index 4501f22ca2..8b23756a8f 100644 --- a/src/mathed/math_parinset.C +++ b/src/mathed/math_parinset.C @@ -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)) { diff --git a/src/mathed/math_xiter.C b/src/mathed/math_xiter.C index 44e5304a39..046a472f43 100644 --- a/src/mathed/math_xiter.C +++ b/src/mathed/math_xiter.C @@ -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; -- 2.39.2