From: André Pönitz Date: Fri, 13 Jul 2001 14:54:56 +0000 (+0000) Subject: prepare re-enabling LaTeX feature validation X-Git-Tag: 1.6.10~21082 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=61529b136ed5b7b2dc4ec3de2b190dc8c015a7bd;p=features.git prepare re-enabling LaTeX feature validation git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2240 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/mathed/array.C b/src/mathed/array.C index 4197abf417..3a663915d0 100644 --- a/src/mathed/array.C +++ b/src/mathed/array.C @@ -339,3 +339,11 @@ void MathArray::WriteNormal(ostream & os) const Write(os, true); } + +void MathArray::Validate(LaTeXFeatures & features) const +{ + for (int pos = 0; pos < size(); next(pos)) + if (isInset(pos)) + nextInset(pos)->Validate(features); +} + diff --git a/src/mathed/array.h b/src/mathed/array.h index 5e17de0685..631b0314a5 100644 --- a/src/mathed/array.h +++ b/src/mathed/array.h @@ -26,6 +26,7 @@ class MathInset; class MathMacro; class Painter; +class LaTeXFeatures; #ifdef __GNUG__ #pragma interface @@ -116,6 +117,8 @@ public: void Write(std::ostream &, bool) const; /// void WriteNormal(std::ostream &) const; + /// + void Validate(LaTeXFeatures &) const; private: /// typedef std::vector buffer_type; diff --git a/src/mathed/formula.C b/src/mathed/formula.C index abd83ef862..27202d0eae 100644 --- a/src/mathed/formula.C +++ b/src/mathed/formula.C @@ -123,6 +123,7 @@ void InsetFormula::draw(BufferView * bv, LyXFont const &, { int x = int(xx) - 1; y -= 2; + MathInset::workwidth = bv->workWidth(); Painter & pain = bv->painter(); @@ -130,22 +131,20 @@ void InsetFormula::draw(BufferView * bv, LyXFont const &, int w = par()->width(); int h = par()->height(); int a = par()->ascent(); - pain.fillRectangle(int(x), y - a, w, h, LColor::mathbg); - - if (mathcursor) { - if (mathcursor->formula() == this) { - if (mathcursor->Selection()) { - int xp[10]; - int yp[10]; - int n; - mathcursor->SelGetArea(xp, yp, n); - pain.fillPolygon(xp, yp, n, LColor::selection); - } - pain.rectangle(int(x), y - a, w, h, LColor::mathframe); + pain.fillRectangle(x, y - a, w, h, LColor::mathbg); + + if (mathcursor && mathcursor->formula() == this) { + if (mathcursor->Selection()) { + int xp[10]; + int yp[10]; + int n; + mathcursor->SelGetArea(xp, yp, n); + pain.fillPolygon(xp, yp, n, LColor::selection); } + pain.rectangle(x, y - a, w, h, LColor::mathframe); } - par()->draw(pain, int(x), y); + par()->draw(pain, x, y); xx += par()->width(); setCursorVisible(false); diff --git a/src/mathed/formulabase.C b/src/mathed/formulabase.C index 49db390786..be33157899 100644 --- a/src/mathed/formulabase.C +++ b/src/mathed/formulabase.C @@ -573,14 +573,14 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action, break; case LFUN_BACKSPACE: - if (!mathcursor->InMacroMode() && mathcursor->pos() == 0) { + // if (!mathcursor->InMacroMode() && mathcursor->pos() == 0) + if (mathcursor->pos() == 0) { bv->lockedInsetStoreUndo(Undo::DELETE); mathcursor->pullArg(); bv->updateInset(this, true); break; } - if (!mathcursor->Left()) - break; + mathcursor->plainLeft(); // fall through... case LFUN_DELETE: diff --git a/src/mathed/math_cursor.C b/src/mathed/math_cursor.C index 7b1f7d91c5..0f9790e62b 100644 --- a/src/mathed/math_cursor.C +++ b/src/mathed/math_cursor.C @@ -153,6 +153,11 @@ bool MathCursor::isInside(MathInset * p) const } +bool MathCursor::plainLeft() +{ + return array().prev(cursor_); +} + bool MathCursor::Left(bool sel) { dump("Left 1"); @@ -165,8 +170,8 @@ bool MathCursor::Left(bool sel) MacroModeClose(); return true; } - clearLastCode(); SelHandle(sel); + clearLastCode(); bool result = false; @@ -214,9 +219,8 @@ bool MathCursor::Right(bool sel) MacroModeClose(); return true; } - - clearLastCode(); SelHandle(sel); + clearLastCode(); bool result = false; @@ -322,9 +326,8 @@ void MathCursor::Home() if (macro_mode) MacroModeClose(); clearLastCode(); - if (!par_->idxHome(idx_, cursor_)) { + if (!par_->idxHome(idx_, cursor_)) pop(); - } dump("Home 2"); } diff --git a/src/mathed/math_cursor.h b/src/mathed/math_cursor.h index 7981662233..e47807aefe 100644 --- a/src/mathed/math_cursor.h +++ b/src/mathed/math_cursor.h @@ -56,6 +56,8 @@ public: /// Put the cursor in the last position void last(); /// + bool plainLeft(); + /// bool plainRight(); /// void Delete(); diff --git a/src/mathed/math_inset.C b/src/mathed/math_inset.C index e39af4dc2a..7a0f9cece9 100644 --- a/src/mathed/math_inset.C +++ b/src/mathed/math_inset.C @@ -357,3 +357,9 @@ bool MathInset::covers(int x, int y) const y >= yo_ - ascent_ && y <= yo_ + descent_; } + +void MathInset::Validate(LaTeXFeatures & features) const +{ + for (int i = 0; i < nargs(); ++i) + cell(i).Validate(features); +} diff --git a/src/mathed/math_inset.h b/src/mathed/math_inset.h index bd1917c040..3075ca10ba 100644 --- a/src/mathed/math_inset.h +++ b/src/mathed/math_inset.h @@ -39,6 +39,8 @@ */ +class LaTeXFeatures; + class MathInset { public: /** A math inset has a name (usually its LaTeX name), @@ -187,6 +189,8 @@ public: void dump() const; /// + void Validate(LaTeXFeatures & features) const; + /// static int workwidth; protected: diff --git a/src/mathed/math_macro.C b/src/mathed/math_macro.C index 01ce91fc4b..5085e783bf 100644 --- a/src/mathed/math_macro.C +++ b/src/mathed/math_macro.C @@ -28,6 +28,7 @@ #include "math_macrotable.h" #include "math_macrotemplate.h" #include "Painter.h" +#include "LaTeXFeatures.h" using std::endl; @@ -183,3 +184,11 @@ bool MathMacro::idxRight(int &, int &) const { return false; } + + +void MathMacro::Validate(LaTeXFeatures & features) const +{ + if (name_ == "binom") + features.binom = true; + MathInset::Validate(features); +} diff --git a/src/mathed/math_macro.h b/src/mathed/math_macro.h index 24775e0163..f40f3df829 100644 --- a/src/mathed/math_macro.h +++ b/src/mathed/math_macro.h @@ -62,6 +62,9 @@ public: /// bool idxRight(int &, int &) const; + /// + void Validate(LaTeXFeatures &) const; + private: /// MathMacroTemplate const * const tmplate_; diff --git a/src/mathed/math_matrixinset.C b/src/mathed/math_matrixinset.C index c3267d0294..a7341f7d51 100644 --- a/src/mathed/math_matrixinset.C +++ b/src/mathed/math_matrixinset.C @@ -221,7 +221,7 @@ bool MathMatrixInset::numberedType() const } -void MathMatrixInset::Validate(LaTeXFeatures & features) +void MathMatrixInset::Validate(LaTeXFeatures & features) const { features.amsstyle = ams(); @@ -230,40 +230,11 @@ void MathMatrixInset::Validate(LaTeXFeatures & features) //if (features.amsstyle) // return; - //Validate1(features); - features.boldsymbol = true; - features.binom = true; -} + //features.binom = true; -/* -void MathMatrixInset::Validate1(LaTeXFeatures & features) -{ - MathIter it(cell()); - - while (it.OK() && !(features.binom && features.boldsymbol)) { - MathInset * p = it.nextInset(); - if (p) { - p = it.GetActiveInset(); - if (p) { - if (!features.binom && p->GetType() == LM_OT_MACRO && - p->name() == "binom") { - features.binom = true; - } else { - for (int i = 0; i <= p->getMaxArgumentIdx(); ++i) { - p->setArgumentIdx(i); - Validate1(features, p); - } - } - } else { - if (!features.boldsymbol && p->name() == "boldsymbol") - features.boldsymbol = true; - } - } - it.Next(); - } + MathInset::Validate(features); } -*/ void MathMatrixInset::header_write(std::ostream & os) const diff --git a/src/mathed/math_matrixinset.h b/src/mathed/math_matrixinset.h index 379555763f..c2daa85dad 100644 --- a/src/mathed/math_matrixinset.h +++ b/src/mathed/math_matrixinset.h @@ -49,7 +49,7 @@ public: /// std::vector const getLabelList() const; /// - void Validate(LaTeXFeatures & features); + void Validate(LaTeXFeatures & features) const; /// void addRow(int);