From 2da8fcabdc695b8bb139d7252b923ef6b9aa29dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Fri, 10 Aug 2001 13:17:39 +0000 Subject: [PATCH] small stuff git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2484 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/math_charinset.C | 12 ++++++++---- src/mathed/math_charinset.h | 4 ++++ src/mathed/math_cursor.C | 12 ++++-------- src/mathed/math_inset.C | 14 +------------- src/mathed/math_inset.h | 9 ++------- src/mathed/math_parser.C | 13 ++----------- 6 files changed, 21 insertions(+), 43 deletions(-) diff --git a/src/mathed/math_charinset.C b/src/mathed/math_charinset.C index 97f6759d2b..24280e3277 100644 --- a/src/mathed/math_charinset.C +++ b/src/mathed/math_charinset.C @@ -12,10 +12,8 @@ MathCharInset::MathCharInset(char c, MathTextCodes t) - : char_(c) -{ - code(t); -} + : char_(c), code_(t) +{} MathInset * MathCharInset::clone() const @@ -82,3 +80,9 @@ bool MathCharInset::isRelOp() const { return char_ == '=' || char_ == '<' || char_ == '>'; } + + +void MathCharInset::handleFont(MathTextCodes t) +{ + code_ = (code_ == t) ? LM_TC_VAR : t; +} diff --git a/src/mathed/math_charinset.h b/src/mathed/math_charinset.h index a6fef5ed9c..c43eac2763 100644 --- a/src/mathed/math_charinset.h +++ b/src/mathed/math_charinset.h @@ -38,9 +38,13 @@ public: char getChar() const { return char_; } /// bool isRelOp() const; + /// + void handleFont(MathTextCodes t); private: /// the character char char_; + /// + MathTextCodes code_; }; #endif diff --git a/src/mathed/math_cursor.C b/src/mathed/math_cursor.C index 61889f7569..aae83c9164 100644 --- a/src/mathed/math_cursor.C +++ b/src/mathed/math_cursor.C @@ -870,7 +870,8 @@ void MathCursor::drawSelection(Painter & pain) const MathTextCodes MathCursor::nextCode() const { - return (pos() == size()) ? LM_TC_MIN : nextInset()->code(); + //return (pos() == size()) ? LM_TC_MIN : nextInset()->code(); + return LM_TC_MIN; } @@ -882,13 +883,8 @@ void MathCursor::handleFont(MathTextCodes t) getSelection(i1, i2); if (i1.idx_ == i2.idx_) { MathArray & ar = i1.cell(); - for (int pos = i1.pos_; pos != i2.pos_; ++pos) { - MathInset * p = ar.nextInset(pos); - if (isalnum(p->getChar())) { - MathTextCodes c = (p->code() == t) ? LM_TC_VAR : t; - p->code(c); - } - } + for (int pos = i1.pos_; pos != i2.pos_; ++pos) + ar.nextInset(pos)->handleFont(t); } } else lastcode_ = (lastcode_ == t) ? LM_TC_VAR : t; diff --git a/src/mathed/math_inset.C b/src/mathed/math_inset.C index b7649d8ef1..9bc2339067 100644 --- a/src/mathed/math_inset.C +++ b/src/mathed/math_inset.C @@ -27,7 +27,7 @@ int MathInset::workwidth; MathInset::MathInset() - : size_(LM_ST_DISPLAY), code_(LM_TC_MIN), xo_(0), yo_(0) + : size_(LM_ST_DISPLAY), xo_(0), yo_(0) {} @@ -283,18 +283,6 @@ std::vector MathInset::idxBetween(int from, int to) const } -MathTextCodes MathInset::code() const -{ - return code_; -} - - -void MathInset::code(MathTextCodes t) -{ - code_ = t; -} - - void MathInset::metrics(MathStyles st) const { lyxerr << "MathInset::metrics() called directly!\n"; diff --git a/src/mathed/math_inset.h b/src/mathed/math_inset.h index 6d6759e51b..86afc24191 100644 --- a/src/mathed/math_inset.h +++ b/src/mathed/math_inset.h @@ -192,22 +192,17 @@ public: /// virtual void validate(LaTeXFeatures & features) const; + /// + virtual void handleFont(MathTextCodes) {} /// static int workwidth; - /// the inherited text style - virtual MathTextCodes code() const; - /// - virtual void code(MathTextCodes t); - protected: /// _sets_ style void size(MathStyles s) const; /// the used font size mutable MathStyles size_; - /// the inherited text style - mutable MathTextCodes code_; private: /// the following are used for positioning the cursor with the mouse diff --git a/src/mathed/math_parser.C b/src/mathed/math_parser.C index bb7ef9c5be..0c8b5e79c4 100644 --- a/src/mathed/math_parser.C +++ b/src/mathed/math_parser.C @@ -556,9 +556,6 @@ latexkeys const * Parser::read_delim() void Parser::parse_into(MathArray & array, unsigned flags) { - static int plevel = -1; - - ++plevel; MathTextCodes yyvarcode = LM_TC_VAR; int t = yylex(); @@ -602,7 +599,7 @@ void Parser::parse_into(MathArray & array, unsigned flags) case LM_TK_ARGUMENT: { MathMacroArgument * p = new MathMacroArgument(ival_); - p->code(yyvarcode); + //p->code(yyvarcode); array.push_back(p); break; } @@ -670,7 +667,6 @@ void Parser::parse_into(MathArray & array, unsigned flags) case '&': if (flags & FLAG_AMPERSAND) { flags &= ~FLAG_AMPERSAND; - --plevel; return; } lyxerr[Debug::MATHED] @@ -682,7 +678,6 @@ void Parser::parse_into(MathArray & array, unsigned flags) curr_skip_ = lexArg('['); if (flags & FLAG_NEWLINE) { flags &= ~FLAG_NEWLINE; - --plevel; return; } lyxerr[Debug::MATHED] @@ -773,10 +768,8 @@ void Parser::parse_into(MathArray & array, unsigned flags) } case LM_TK_RIGHT: - if (flags & FLAG_RIGHT) { - --plevel; + if (flags & FLAG_RIGHT) return; - } error("Unmatched right delimiter"); // panic = true; break; @@ -825,7 +818,6 @@ void Parser::parse_into(MathArray & array, unsigned flags) case LM_TK_MATH: case LM_TK_END: - --plevel; return; case LM_TK_BEGIN: @@ -881,7 +873,6 @@ void Parser::parse_into(MathArray & array, unsigned flags) t = yylex(); } } - --plevel; }